Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

storing records in temp table in sql server and using LINQ in C# to access these records

Posted on 2011-09-09
6
Medium Priority
?
385 Views
Last Modified: 2013-11-11
I am using LINQ with c# and pulling certain questions (say 25) from a table randomly and need to store these questions some where in database say in a temp table. Now on every next or previous button clicks I need records from this temp table. On finish button click i need to drop this table. I created one stored procedure, used select into statement and filled this temp table. Second stored procedure to pull the values from this sp but I got an error reading through this stored procedure. Any ideas how can we fix the following error or is there better way of dealing this issue

Error: Stored procedure returning integer instead of ISingleResult


I also tried creating a table variable as mentioned on this site http://odetocode.com/code/365.aspx  but I can't access this Table variable in other stored procedures on next previous clicks

Any ideas
0
Comment
Question by:mmalik15
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 64

Expert Comment

by:Fernando Soto
ID: 36510812

Can you post the Stored Procedure.
0
 

Author Comment

by:mmalik15
ID: 36513409
sure following is my sp
ALTER PROCEDURE [dbo].[sp_GetRandomQuestionsAndStoreInTempTable]
	-- Add the parameters for the stored procedure here
	@QuizID varchar(500)
	
AS
BEGIN
	
Create table #UserQuestionstmp 
(
QuestionID int,
Question varchar(8000),
Choices varchar(8000),
CorrectAnswer varchar(5000),
RelatedInfo varchar(8000),
QuestionType varchar(50),
Section varchar(5000),
QuestionNo int
)

INSERT INTO #UserQuestionstmp
exec dbo.sp_GetQuestionsByChapterID @QuizID



END

Open in new window

0
 

Author Comment

by:mmalik15
ID: 36513425
And the error I am getting is

The return types for the following stored procedures could not be detected. Set the return type for each stored procedure in the Properties window.
0
NFR key for Veeam Agent for Linux

Veeam is happy to provide a free NFR license for one year.  It allows for the non‑production use and valid for five workstations and two servers. Veeam Agent for Linux is a simple backup tool for your Linux installations, both on‑premises and in the public cloud.

 
LVL 64

Expert Comment

by:Fernando Soto
ID: 36514983

Are you sure that this is the correct SP. I am not a SQL Guru but it looks like to be it creates a table and insert record into it?
0
 

Author Comment

by:mmalik15
ID: 36515931
After inserting recrods in temp table i want to pull records on subsequent requests from this table(don't know if thats possible). The reason i am doing this is becasue the sp below generates random records and after generating these records I need to save them some where to access them during the user's session quiz

ALTER PROCEDURE [dbo].[sp_GetQuestionsByChapterID]
      -- Add the parameters for the stored procedure here
      @QuizID varchar(5000)
      
AS
BEGIN
      

    -- Insert statements for procedure here

select top 24 QuestionID,Question, Choices,CorrectAnswer,RelatedInfo,QuestionType, Section, row_number() over(order by QuestionNo) AS QuestionNo  from (
Select Q.QuestionID,Q.Question,Q.Choices,Q.CorrectAnswer,
Q.RelatedInfo,Q.QuestionType,Q.Section, newid() QuestionNo
FROM dbo.Questions Q
where  (CHARINDEX( ',' + convert(varchar,Q.Chapter) + ',', ',' + @QuizID + ',' ) > 0)
) x
END
0
 
LVL 9

Accepted Solution

by:
teebon earned 2000 total points
ID: 36895472
Why don't you pull out the random questions and store in a session variable instead?
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …

618 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question