Click here to Skip to main content
15,896,207 members
Home / Discussions / Database
   

Database

 
GeneralUploading Large numbers of records Pin
mjackson113-Dec-04 8:07
mjackson113-Dec-04 8:07 
GeneralRe: Uploading Large numbers of records Pin
Alex Korchemniy4-Dec-04 16:56
Alex Korchemniy4-Dec-04 16:56 
GeneralRe: Uploading Large numbers of records Pin
mjackson118-Dec-04 9:42
mjackson118-Dec-04 9:42 
GeneralADO.NET columns are magic numbers.. Pin
giorgos_gr3-Dec-04 5:09
giorgos_gr3-Dec-04 5:09 
GeneralSQL Tree Hierarchy Problem Pin
Dirk Kok2-Dec-04 22:24
sussDirk Kok2-Dec-04 22:24 
GeneralRe: SQL Tree Hierarchy Problem Pin
Michael Potter3-Dec-04 4:34
Michael Potter3-Dec-04 4:34 
GeneralRe: SQL Tree Hierarchy Problem Pin
Chris Meech3-Dec-04 6:44
Chris Meech3-Dec-04 6:44 
GeneralStored Proc and SqlDataAdapter Pin
ccosser2-Dec-04 22:03
ccosser2-Dec-04 22:03 
Hi,

Hoping someone can help me. I am trying to implement a custom built paging control. I need to retrieve the total number of records as well as only select the number of records I require from the stored procedure and extract these two variables using a sqlDataAdapter.

My sql query is as follows ... would prefer not to use "tomato sauce" but this is the only solution I can think of - however i'm still not getting results .....

And how do I extract these two variables into my sqldataAdapter ...?????

Any advices would be very welcome .. thank you.

My stored procedure ...

alter PROCEDURE [dbo].[prc_tbUser_GetAllPaged1]

--create variable for NumRec
@From int,
@To int

AS
DECLARE @SQL varchar
DECLARE @SQLCount varchar
DECLARE @sSQL varchar
DECLARE @NumRec varchar

set @NumRec = @To - @From

set @SQLCount = 'Declare @TotalRecords int, @NumRec int '
set @SQLCount = @SQLCount + 'SELECT @TotalRecords = count(UserId) from tbUser'

set @SQL = 'SELECT a.Name, a.UserID, a.Login, b.Name as OrganisationName, c.Description as Status
FROM tbUser a
INNER JOIN tbOrganisation b
ON a.OrganisationID = b.OrganisationID
INNER JOIN tbStatus c
ON a.StatusID = c.StatusID'

set @sSQL = @SQLCount + ' SELECT top ' + @NumRec + ' @TotalRecords as NumRecords ' + @SQL


print @sSQL


GO
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS ON
GO

--prc_tbUser_GetAllPaged1 20,40

and this is the sqlDataAdapter ...

connection = new SqlConnection( Configuration.ConnectionString );

command = new SqlCommand( "prc_tbUser_GetAllPaged1", connection );

command.CommandType = CommandType.StoredProcedure;


//From value

command.Parameters.Add( "@From", SqlDbType.Int ).Value = iFrom;

//To value

command.Parameters.Add( "@To", SqlDbType.Int ).Value = iTo;

//need to add another column to read total number of records return

command.Parameters.Add("@TotalRecords", SqlDbType.Int);



// Open the connection

connection.Open();

//create the data adapter

SqlDataAdapter oDA = new SqlDataAdapter(command);



//Gets the parameters set by the user when executing an SQL SELECT statement.

oDA.GetFillParameters();

//execute the reader

oDA.Fill(oDS,iFrom,iTo - iFrom, "tbUser");


return oDS

GeneralAttaching a database to MSDE Pin
mattie202-Dec-04 20:31
mattie202-Dec-04 20:31 
GeneralNested Transaction with SQL Server Pin
Wouter van Eck2-Dec-04 5:21
Wouter van Eck2-Dec-04 5:21 
QuestionHow can i avaoid negative values in SQL? Pin
john kuruvila2-Dec-04 5:14
john kuruvila2-Dec-04 5:14 
AnswerRe: How can i avaoid negative values in SQL? Pin
Colin Angus Mackay2-Dec-04 6:42
Colin Angus Mackay2-Dec-04 6:42 
GeneralRe: How can i avaoid negative values in SQL? Pin
john kuruvila2-Dec-04 7:30
john kuruvila2-Dec-04 7:30 
Generalnot allowing negative values Pin
sujithapril2-Dec-04 5:10
sujithapril2-Dec-04 5:10 
GeneralRe: not allowing negative values Pin
Colin Angus Mackay2-Dec-04 6:41
Colin Angus Mackay2-Dec-04 6:41 
GeneralRe: not allowing negative values Pin
sujithapril2-Dec-04 7:23
sujithapril2-Dec-04 7:23 
GeneralRe: not allowing negative values Pin
Colin Angus Mackay2-Dec-04 7:26
Colin Angus Mackay2-Dec-04 7:26 
GeneralRe: not allowing negative values Pin
sujithapril2-Dec-04 7:50
sujithapril2-Dec-04 7:50 
GeneralRe: not allowing negative values Pin
Colin Angus Mackay2-Dec-04 7:59
Colin Angus Mackay2-Dec-04 7:59 
GeneralRecordset "LIKE" filter of a number column Pin
Menny Even Danan1-Dec-04 21:51
Menny Even Danan1-Dec-04 21:51 
GeneralRe: Recordset "LIKE" filter of a number column Pin
jlawren72-Dec-04 5:27
jlawren72-Dec-04 5:27 
Generalcan't DELETE records in excel Pin
scoroop1-Dec-04 11:15
scoroop1-Dec-04 11:15 
GeneralRe: can't DELETE records in excel Pin
Christian Graus1-Dec-04 12:27
protectorChristian Graus1-Dec-04 12:27 
GeneralRe: can't DELETE records in excel Pin
scoroop1-Dec-04 12:36
scoroop1-Dec-04 12:36 
GeneralRe: can't DELETE records in excel Pin
jonathan152-Dec-04 23:21
jonathan152-Dec-04 23:21 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.