About Datareader And Dataset Combine Use

Dec 26, 2007

i have 2 database queries.
One fetches data from a table and other according to first query result second query fetches record from another table both of these queries make use of datareader and while loop for inserting data to dropdownlist , but instead of that i want to add all my row fetched by second query store one by one in a dataset for some time .
in simple words i want to insert datareader record one by one in dataset. 
i am using asp.net2.0,c#, Sql server 2000 

View 2 Replies


ADVERTISEMENT

Dataset Or Datareader?

Jun 20, 2007

i need help to know what is the best practice
i have a stored proc which returns 4 different resultselts
will that be easy to use dataset or datareader?
my purpose of using dataset/datareader is to load the data in a class
thanks.
 

View 5 Replies View Related

Datareader And Dataset

Nov 3, 2003

Hi

I am using a datareader to access data via a stored procedure. The reason for using the datareader is that the stored procedure is multi level depending on the variable sent to it. However I want to do two things with the data being returned.

The first is to poulate a datagrid - which I've done.
The second is to produce an Infragistic Web Graph. However according to the background reading I have done so far, I can only populate the graph from one of the following: datatable,dataview,dataset,Array or Ilist.

I don't want to make another call to the server for the same information, so how can I get the data out of a stored procedure into a dataset or dataview?

regards

Jim

View 1 Replies View Related

Datareader Insted Of Dataset Sored Procedure

Jan 10, 2007

i m writing a stored procudrue to update my data that is onther
table.and i pass the parameter in my vb code,when i pass the data that
is insert only first record of data but second record insert the eroor
will come is data reader is colsed. now insted of data reade i have to
use data set how can i use that and update my data is ontehr
table.?below i written my vb.net2005 code.      Dim con As New SqlConnection(ConfigurationManager.ConnectionStrings("Project1connectionString").ToString())            '        con.Open()            '        Dim ggrnid As String            '        Dim acceptqty As String            '        Dim itemid As String            '        Dim grnid As TextBox = CType(GRNDetailsView.FindControl("fldgrnid"), TextBox)            '        ggrnid = grnid.Text            '        Dim sWhere As String = grnid.Text            '        If (Not String.IsNullOrEmpty(sWhere)) Then            '            For Each s As String In sWhere '            '                'Dim iRowIndex As Integer = Convert.ToInt32(s)            '                Dim sqldtr As SqlDataReader            '                sqlcmd = New SqlCommand            '                sqlcmd.Connection = con            '                sqlcmd.CommandType = CommandType.Text           
'                sqlcmd.CommandText = "select acceptqty,itemid from
grndetail  where grnid='" & Trim(ggrnid) & "'"            '                datacommand = CommandType.StoredProcedure            '                'datacommand("aaceptqtygrn", con)            '                Dim cmd As New SqlCommand("aaceptqtygrn", con)            '                sqldtr = sqlcmd.ExecuteReader()            '                'dataset = datacommand.            '                'sqldtr = sqlcmd.ExecuteScalar            '                If sqldtr.HasRows = True Then            '                        While sqldtr.Read()            '                        acceptqty = sqldtr.Item("acceptqty")            '                        itemid = sqldtr.Item("itemid")            '                        cmd.CommandType = CommandType.StoredProcedure            '                        cmd.Parameters.AddWithValue("@acceptqty", acceptqty)            '                        cmd.Parameters.AddWithValue("@itemid", itemid)            '                        sqldtr.Close()            '                        cmd.ExecuteNonQuery()            '                    End While            '                    'sqldtr.Close()            '                    'cmd.ExecuteNonQuery()            '                    'Next sqldtr.HasRows            '                End If            '            Next s            '            sqldtr.Close()            '            con.Close()            '        End If            '    End If        Catch ex As Exception            MsgBox(ex.Message)        End Try

View 2 Replies View Related

Select Case Does Not Evaluate The Value Returned By Datareader Or Dataset

Sep 13, 2006

I am working on a company sign out sheet for our Intranet. The application accesses a sql database.  I tried using a datareader as well as a dataset to access a small piece of information regarding the group that each employee belongs to in the company.  My last attempt was to assign the value to the text property of a text box and evaluate the text from the text box with the Select Case but that did not work either.The application is supposed to generate an email to our receptionist as well as to the group technical assistant responsible for each group according to the value that is passed into the Select Case statement.  With the datareader as well as the dataset and even now with creating a text box and accessing the text property, I was able to assign the group value to a variable (I can see the value in the subject of the email), but when the variable is supposed to be evaluated by the select case statement it skips right through all of the cases to case else and uses only the receptionist's address in the email as if it doesn't even see the value of the variable.   I have searched for a possible answer to the problem I am but so far have had no luck.  Any ideas?   I included the part of the code that I am having trouble with: '********************************************************************************************' New DataSet is created to determine the group the employee belongs to so that the appropriate' group technical assistant is emailed when employee signs out'******************************************************************************************** ' declare variablesDim sqlGroup As String ' string variable to store sql statement for datasetDim BLGroup As String ' string variable to store the bl group of the employeeDim emailAddress As String ' string variable to store resulting email address Dim groupDS As DataSet ' dataset variableDim groupAdapter As SqlDataAdapter ' sql data adapter variable' sql statement to access group value from the databasesqlGroup = "SELECT BLGroup FROM BLGroupsView WHERE (RTRIM(fname) + ' ' + LTRIM(lname)='" & employee & "')" ' repopen the connection (leftover from working with the datareader)Connection.Open()' create new SqlDataAdapter applying sql statement and connectiongroupAdapter = New SqlDataAdapter(sqlGroup, Connection)' create new dataset groupDS = New DataSet()' populate the datasetgroupAdapter.Fill(groupDS, "BLGroupsView") ' get the value stored in the BLGroup column (only one row is returned at a time) BLGroup = groupDS!BLGroup' Create GroupTextBox TextBox control.Dim GroupTextBox As New TextBox()' Set options for the UserTextBox TextBox control.GroupTextBox.ID = "GroupTextBox"GroupTextBox.Visible = "False"GroupTextBox.Text = BLGroup' just trying anything with this next line, even when i didn't set this the select case statement did not seem to see the value returned by the variableGroupTextBox.runat = "server"  ' use a select case statement to evaluate the value of the group (didn't work when I passed in the BLGroup variable eitherSelect Case GroupTextBox.TextCase "bh"emailAddress = "receptionist@myaddress.com; bhassistant@myaddress.com"Case "env"emailAddress = "receptionist@myaddress.com; envassistant@myaddress.com"Case "sw"emailAddress = "receptionist@myaddress.com; swassistant@myaddress.com"Case "fac"emailAddress = "receptionist@myaddress.com; facassistant@myaddress.com"Case "www"emailAddress = "receptionist@myaddress.com; wwwassistant@myaddress.com"Case ElseemailAddress = "receptionist@myaddress.com"End Select '*************************************************************************************************' set new message objectDim myMessage As System.Web.Mail.MailMessage = New System.Web.Mail.MailMessage()'**********************************************************' set message properties'********************************************************** myMessage.From = "me@myaddress.com"myMessage.To = emailAddressmyMessage.Subject = employee & " Signing Out at " & TimeOut.Text & " " & BLGroupmyMessage.Body = employee & " Signing Out at " & TimeOut.Text & " for " & Destination.Text & " will potentially return at " & EstTimeIn.Text'***********************************************************' set smtp server namesmtpMail.SmtpServer = "mailserver1"' send email using smtpsmtpMail.Send(myMessage) It sends the message and returns the BLGroup value everytime but only sends to the receptionist.  Thanks for your time! 

View 1 Replies View Related

SQL Server 2008 :: Populate One Dataset In SSRS Based On Results From Another Dataset Within Same Project?

May 26, 2015

I have a report with multiple datasets, the first of which pulls in data based on user entered parameters (sales date range and property use codes). Dataset1 pulls property id's and other sales data from a table (2014_COST) based on the user's parameters. I have set up another table (AUDITS) that I would like to use in dataset6. This table has 3 columns (Property ID's, Sales Price and Sales Date). I would like for dataset6 to pull the Property ID's that are NOT contained in the results from dataset1. In other words, I'd like the results of dataset6 to show me the property id's that are contained in the AUDITS table but which are not being pulled into dataset1. Both tables are in the same database.

View 0 Replies View Related

Integration Services :: Perform Lookup On Large Dataset Based On A Small Dataset

Oct 1, 2015

I have a small number of rows in a dataset, Table 1.  There is a CLOB on a large dataset, Table 2.  They join on a PK.  I would like to retrieve this CLOB and add it to the data flow for Table1.  In short I want to emulate the following:

Table 1:  Small table without CLOB, 10 rows. 
Table 2: Large table with CLOB, 10,000,000 rows

select CLOB
from table2
where pk = (select pk from table1)

I want this to return the CLOBs for the small number of rows in Table 1.  The PK is indexed obviously so it should be a fast look up.

Table 1 and Table 2 live on different Oracle databases.  How do I perform this operation efficiently in SSIS?  It seems the Lookup and Merge Join wont do this.

View 2 Replies View Related

Reporting Services :: Populate One Dataset In SSRS Based On Results From Another Dataset Within Same Project?

May 27, 2015

I have a report with multiple datasets, the first of which pulls in data based on user entered parameters (sales date range and property use codes). Dataset1 pulls property id's and other sales data from a table (2014_COST) based on the user's parameters.

I have set up another table (AUDITS) that I would like to use in dataset6. This table has 3 columns (Property ID's, Sales Price and Sales Date). I would like for dataset6 to pull the Property ID's that are NOT contained in the results from dataset1. In other words, I'd like the results of dataset6 to show me the property id's that are contained in the AUDITS table but which are not being pulled into dataset1. Both tables are in the same database.

View 3 Replies View Related

How Can I Use SQL Reporting Services To Get A Dynamic Dataset From Another Web Service As My Reports Dataset?

May 21, 2007

I found out the data I need for my SQL Report is already defined in a dynamic dataset on another web service. Is there a way to use web services to call another web service to get the dataset I need to generate a report? Examples would help if you have any, thanks for looking

View 2 Replies View Related

Datareader Destination As Source For Other Datareader Source ?

Aug 30, 2006

HI!

as far as I know from docs and forum datareader is for .NET data in memory. So if a use a complex dataflow to build up some data and want to use this in other dataflow componens - could i use data datareader source in the fist dataflow and then use a datareader souce in the second dataflow do read the inmemoty data from fist transform to do fursther cals ?

how to pass in memory data from one dataflow to the next one (i do not want to rebuild the logic in each dataflow to build up data data ?

Is there a way to do this ? and is the datareader the proper component ? (because its the one and only inmemory i guess, utherwise i need to write to temp table and read from temp table in next step) (I have only found examples fro .NET VB or C# programms to read a datareader, but how to do this in SSIS directly in the next dataflow?

THANKS, HANNES

View 7 Replies View Related

Listing Datasets In Report (dataset Name, Dataset's Commands)

Oct 12, 2007



Is there any way to display this information in the report?

Thanks

View 3 Replies View Related

Dataset.Tables.Count=0 Where There Are 2 Rows In The Dataset.

May 7, 2008

Hi,
I have a stored procedure attached below. It returns 2 rows in the SQL Management studio when I execute MyStorProc 0,28. But in my program which uses ADOHelper, it returns a dataset with tables.count=0.
if I comment out the line --If @Status = 0 then it returns the rows. Obviously it does not stop in
if @Status=0 even if I pass @status=0. What am I doing wrong?
Any help is appreciated.


ALTER PROCEDURE [dbo].[MyStorProc]

(

@Status smallint,

@RowCount int = NULL,

@FacilityId numeric(10,0) = NULL,

@QueueID numeric (10,0)= NULL,

@VendorId numeric(10, 0) = NULL

)

AS

SET NOCOUNT ON

SET CONCAT_NULL_YIELDS_NULL OFF



If @Status = 0

BEGIN

SELECT ......
END
If @Status = 1
BEGIN
SELECT......
END



View 4 Replies View Related

How To Transfer Data From One Dataset To Other Dataset

Apr 11, 2008

i have two datasets.one dataset have old data from some other database.second dataset have original data from sql server 2005 database.both database have same field having id as a primary key.i want to transfer all the data from first dataset to new dataset retaining the previous data but if old dataset have the same id(primary key) as in the new one then that row will not transfer.
but if the id(primary key) have changed values then the fields updated with that data.how can i do that.
 

View 4 Replies View Related

Filter One One Dataset With Values In Another Dataset?

Dec 19, 2006

Hi,

I have two datasets in my report, D1 and D2.

D1 is a list of classes with classid and title

D2 is a list of data. each row in D2 has a classid. D2 may or may not have all the classids in D1. all classids in D2 must be in D1.

I want to show fields in D2 and group the data with classids in D1 and show every group as a seperate table. If no data in D2 is available for a classid, It shows a empty table.

Is there any way to do this in RS2005?

View 2 Replies View Related

Reporting Services :: IF Statement If Dataset Field Value Equals Value Of Dataset Field

Sep 3, 2015

Using this IIF statement:

=CountDistinct(IIF(Fields!Released_DT.Value = Fields!Date2.Value, Fields!Name.Value,
Nothing))
Released_DT = a date  - 09/03/2015 or 09/02/2015
Date2 = returns another date value in this case 09/03/2015

What I'm trying to do is: count distinct number of people (Fields!Name.Value) if the Relased_DT = Date2.My IIF statement is returning a zero value.

View 4 Replies View Related

Help With Datareader

Jun 8, 2007

Hey guys, whats an easy way to pass a value into a stored procodure?
 I tried the code below but I keep on getting a "Procedure 'sp_InsertData' expects parameter '@gpiBatchNo', which was not supplied." error. My stored proc basically gets inserts the passed variable into a databaseSqlConnection sqlSecConnection = new SqlConnection(sqlPriConnString);SqlCommand sqlSecCommand = new SqlCommand();
sqlSecCommand.Connection = sqlSecConnection;
sqlSecCommand.CommandText = "sp_InsertData";sqlSecCommand.CommandType = CommandType.StoredProcedure;sqlSecCommand.Parameters.Add("@gpiBatchNo", SqlDbType.NVarChar) ;
sqlSecConnection.Open();int returntype = sqlSecCommand.ExecuteNonQuery();
sqlSecConnection.Close();

View 2 Replies View Related

How Can I Use Datareader

Oct 20, 2007

This code is currently loading my DataGridView
How can i change this to use the Datareader


Dim myConnection As SqlConnection = New SqlConnection("Data Source=ANTEC30SQLEXPRESS;Initial Catalog=test;Integrated Security=True;Pooling=False")


Dim myCmd As SqlCommand = myConnection.CreateCommand()

myConnection.Open()


myCmd.CommandType = Data.CommandType.Text

myCmd.CommandText = "Select * From tblParts"


Dim myDataAdapter As SqlDataAdapter = New SqlDataAdapter(myCmd)

Dim myDataSet As DataSet = New DataSet()

myDataAdapter.Fill(myDataSet)


DataGridView1.DataSource = myDataSet.Tables(0)

View 7 Replies View Related

DataReader Access

Feb 22, 2007

Hi,
I am facing a problem to access datareader... actually i want to get data on lables from datareader. actually i am having one table having only one column and i hav accessed all data into datareader but the problem is that i just want to get data row by row...
 
For example there are four labels Label1, Label2, Label3, Label4
and want to print the data from datareader on to thease labels....
 
 
plz do reply... i am in trouble

View 1 Replies View Related

DataReader And DataAdapter

Feb 28, 2007

Hi,    What is the difference b/w sqldatareader and sqldataadapter? For what purpose are they used in a database connection & how do they differ from each other? Pls explain me in detail.Regards Vijay.

View 1 Replies View Related

Datareader Problem

Aug 20, 2007

Hi,
I cant seem to get this working right...I have a datareader which i loop through...i want to test each value to see if its null but i cant get the syntax right.  
I know i use dr.item("columnname") or dr(0) to pick a certain column but i dont know the column names and want to check them all anyway.  What is the syntax to do this.
Thanks for any help...this is prob very simple but just cant see it.
--------------------------------------------While dr.Read
If dr(0) Is System.DBNull.Value Then
Return "test"End If
End While

View 3 Replies View Related

Problem With Datareader

Aug 25, 2007

Hello     i creae one programm, there is an two data reader and two Gridview or datagrid , and my programm have one error my programm is there  using System;using System.Data;using System.Configuration;using System.Collections;using System.Web;using System.Web.Security;using System.Web.UI;using System.Web.UI.WebControls;using System.Web.UI.WebControls.WebParts;using System.Web.UI.HtmlControls;using System.Data.SqlClient;public partial class aries : System.Web.UI.Page{    SqlConnection con;    SqlCommand cmd;    SqlDataReader dr;    SqlDataReader dr1;    SqlCommand cmd1;        protected void Page_Load(object sender, EventArgs e)    {        string str;        str = ConfigurationSettings.AppSettings["DBconnect"];        con = new SqlConnection(str);        con.Open();        cmd = new SqlCommand("select color from zodiac_color where Sno=1", con);        dr = cmd.ExecuteReader();        GridView1.DataSource = dr;        GridView1.DataBind();        cmd1=new SqlCommand("select number from zodiac_number where Sno=1",con);        dr1 = cmd.ExecuteReader();        GridView2.DataSource = dr1;        GridView2.DataBind();    }}  i want to calll two value in a same database but the table is diffrent so please help me ?The error is ::---------    There is already an open DataReader associated with this Command which must be closed first. please help me ashwani kumar 

View 2 Replies View Related

Datareader Problem

Apr 9, 2008

hi to all , check this once..this all data related to bus seats SeatNo1,SeatNo2 seats varchar in databaseSt1,St2    status(bit in database sqlserver2000) All my code is working when reader[i + 2].ToString() == "True" is remove from code ..so plz tell me solution gow to ckeck status with datareaderSqlCommand command = new SqlCommand("Select SeatNo1,SeatNo2,St1,St2 from tblSts where
BUSID='S0008'", sqlCon);

        sqlCon.Open();

 

        SqlDataReader
reader = command.ExecuteReader();

        int x =
0;

        while
(reader.Read())

        {

            for
(int i = 0; i <= reader.FieldCount - 1; i++)

            {

                x = (i + 1);

                System.Web.UI.WebControls.Label myLabel = ((System.Web.UI.WebControls.Label)(Page.FindControl(("Label"
+ x))));

                System.Web.UI.WebControls.CheckBox myCheckbox = ((System.Web.UI.WebControls.CheckBox)(Page.FindControl(("Checkbox"
+ x))));

                if
(reader[i].ToString() != "NULL"
&& reader[i + 2].ToString() == "True"))

                {

                    myLabel.Text =
reader[i].ToString();

                    myCheckbox.Checked = false;

                }

                else

                {

                    myLabel.Text =
reader[i].ToString();

                    myCheckbox.Visible = false;

                }

            }

        }

        sqlCon.Close(); 

View 8 Replies View Related

Datareader Timeout

Apr 25, 2008

 Hi
In my web site I call all the content from the database with the use of querystrings. I use datareader to call the data each time a request appears from the querystring.  Although I close all the connections I still get occasionally the following error:
Timeout expired the timeout period elapsed prior to obtaining a connection from the pool. This may have occured because all pooled connections were in use and max pool size was reached.
 
If it is not a programming error then what could it be? I use sql server 2005 and vs 2005 asp.net 2.0 .

View 6 Replies View Related

Open Datareader

May 2, 2008

"There is already an open datareader associated with this command which must be closed first." 
I have received this same error before, but I'm not sure why I'm getting it here.'Create a Connection object.
MyConnection = New SqlConnection("...............................")

'Check whether a TMPTABLE_QUERY stored procedure already exists.
MyCommand = New SqlCommand("...", MyConnection)

With MyCommand
'Set the command type that you will run.
.CommandType = CommandType.Text

'Open the connection.
.Connection.Open()

'Run the SQL statement, and then get the returned rows to the DataReader.
MyDataReader = .ExecuteReader()

'Try to create the stored procedure only if it does not exist.
If Not MyDataReader.Read() Then
.CommandText = "create procedure tmptable_query as select * from #temp_table"

MyDataReader.Close()
.ExecuteNonQuery()
Else
MyDataReader.Close()
End If

.Dispose() 'Dispose of the Command object.
MyConnection.Close() 'Close the connection.
End With
As you can see, the connection is opened and closed, and the datareader is closed.   Here's what comes next...'Create another Connection object.
ESOConnection = New SqlConnection("...")

If tx_lastname.Text <> "" Then
If (InStr(sqlwhere, "where")) Then
sqlwhere = sqlwhere & " AND lname like '" & Replace(tx_lastname.Text, "'", "''") & "%'"
Else
sqlwhere = " where lname like '" & Replace(tx_lastname.Text, "'", "''") & "%'"
End If
End If
If tx_firstname.Text <> "" Then
If (InStr(sqlwhere, "where")) Then
sqlwhere = sqlwhere & " AND fname like '" & Replace(tx_firstname.Text, "'", "''") & "%'"
Else
sqlwhere = " where fname like '" & Replace(tx_firstname.Text, "'", "''") & "%'"
End If
End If

dynamic_con = sqlwhere & " order by arr_date desc "

'create the temporary table on esosql.
CreateCommand = New SqlCommand("CREATE TABLE #TEMP_TABLE (".............", ESOConnection)

With CreateCommand
'Set the command type that you will run.
.CommandType = CommandType.Text

'Open the connection to betaserv.
ESOConnection.Open()

'Run the SQL statement.
.ExecuteNonQuery()

End With

'query our side
ESOCommand = New SqlCommand("SELECT * FROM [arrest_index]" & dynamic_con, ESOConnection)

'execute query
ESODataReader = ESOCommand.ExecuteReader()

'loop through recordset and populate temp table
While ESODataReader.Read()

MyInsert = New SqlCommand("INSERT INTO #TEMP_TABLE VALUES("......", ESOConnection)

'Set the command type that you will run.
MyInsert.CommandType = CommandType.Text

'Run the SQL statement.
MyInsert.ExecuteNonQuery()

End While

ESODataReader.Close()  'Create a DataAdapter, and then provide the name of the stored procedure.
MyDataAdapter = New SqlDataAdapter("TMPTABLE_QUERY", ESOConnection)

'Set the command type as StoredProcedure.
MyDataAdapter.SelectCommand.CommandType = CommandType.StoredProcedure

'Create a new DataSet to hold the records and fill it with the rows returned from stored procedure.
DS = New DataSet()
MyDataAdapter.Fill(DS, "arrindex")

'Assign the recordset to the gridview and bind it.
If DS.Tables(0).Rows.Count > 0 Then
GridView1.DataSource = DS
GridView1.DataBind()
End If

'Dispose of the DataAdapter
MyDataAdapter.Dispose()

'Close server connection
ESOConnection.Close() Again, a separate connection is open and closed.I've read you can only have 1 datareader available per connection. Isn't that what I have here? The error is returned on this line: MyInsert.ExecuteNonQuery()
Help is appreciated.
 

View 3 Replies View Related

DataReader Not Reading

Jan 13, 2004

Why won't this dataReader read?

Dim objCon2 As New SqlConnection()
objCon2.ConnectionString = "a standard connection string"
objCon2.Open()

Dim objCommand As SqlCommand
objCommand = New SqlCommand(strSQL, objCon2)
Dim objReader As SqlDataReader
objReader = objCommand.ExecuteReader()

Label1.Text = objReader("email")

strSQL is a select command which I've checked (using SQL Query analyzer) does return data. I know the connection string is valid (and I presume if it wasn't that it'd fail on objCon2.open, which it doesn't).

So why oh why do I get this error on the last line (and yes, there is an "email" field in the contents of the reader)

System.InvalidOperationException: Invalid attempt to read when no data is present.

View 1 Replies View Related

Datareader And Arrays

Apr 22, 2004

I have data I am retrieving using a datareader...and SQLSERVER
It could return 1 row of information or perhaps 3 rows of information
I need to know how to use an array here I would guess so I can access each element in this row or rows.

HOw might I use reader.read and get it into the array

View 4 Replies View Related

Clarification On DataReader

Jan 19, 2006

I want to create a DataList that shows products, which will be on
multiple pages. I have my stored proc to show paged results, which
contains a return value for more records.
I have found examples of coding the DataReader, defining all the
parameters etc, but what about the drag and drop SqlDataSource?? You
can select the DataSource Mode to be "DataReader". I can put select
parameters in, with input and my return value. I don't know how to then
access the return value, or output value if needed, from this? My
DataList references the SqlDataSource, but I don't know how to get the
return/output value out??? This is very frustrating, cause I can't find
any info about it anywhere. Always input parameters, but no output.
This is my current SqlDataSource...

<asp:SqlDataSource ID="SqlDataSource1" runat="server"
DataSourceMode="DataReader" ConnectionString="<%$
ConnectionStrings:Personal %>" SelectCommand="sp_PagedItems"
SelectCommandType="StoredProcedure">
        <SelectParameters>
           
<asp:QueryStringParameter Name="Page" QueryStringField="page" />
            <asp:Parameter Name="RecsPerPage" DefaultValue="10" />
           
<asp:QueryStringParameter Name="CategoryID" QueryStringField="cat"
/>
           
<asp:Parameter Name="RETURN_VALUE" Direction="ReturnValue" Size="1"
/>
        </SelectParameters>
    </asp:SqlDataSource>

If I take out the RETURN_VALUE Parameter, my results display in my data
list, but that's useless if I can't access the return value to
determine the remaining number of pages etc. Is my RETURN_VALUE
parameter wrong? How do I access that? My stored proc is shown below...

CREATE PROCEDURE sp_PagedItems
   (
    @Page int,
    @RecsPerPage int,
    @CategoryID int
   )
AS

-- We don't want to return the # of rows inserted
-- into our temporary table, so turn NOCOUNT ON
SET NOCOUNT ON


--Create a temporary table
CREATE TABLE #TempItems
(
   ID int IDENTITY,
   No varchar(100),
   Name varchar(100),
   SDescription varchar(500),
   Size varchar(10),
   ImageURL varchar(100)
)


-- Insert the rows from tblItems into the temp. table
INSERT INTO #TempItems (No, Name, SDescription, Size, ImageURL)
SELECT No, Name, SDescription, Size, ImageURL FROM Products WHERE CategoryID=@CategoryID

-- Find out the first and last record we want
DECLARE @FirstRec int, @LastRec int
SELECT @FirstRec = (@Page - 1) * @RecsPerPage
SELECT @LastRec = (@Page * @RecsPerPage + 1)

-- Now, return the set of paged records, plus, an indiciation of we
-- have more records or not!
SELECT *,
       MoreRecords =
   (
    SELECT COUNT(*)
    FROM #TempItems TI
    WHERE TI.ID >= @LastRec
   )
FROM #TempItems
WHERE ID > @FirstRec AND ID < @LastRec


-- Turn NOCOUNT back OFF
SET NOCOUNT OFF

View 3 Replies View Related

RecordCount With Datareader

Apr 22, 2006

I am very disappinted where Datareader have no RecordCount where I can get the total records it read. I guess I found a way:
 
sql = "SELECT *, ROW_NUMBER() OVER (ORDER BY id DESC) AS c FROM ACCOUNTS  ORDER BY c DESC"Dim command As SqlCommand = New SqlCommand(sql, New SqlConnection(_DBConnectionString))            command.Connection.Open()            _ReturnDataReader = command.ExecuteReader(CommandBehavior.CloseConnection)            command.Dispose()            _TotalRecord = _ReturnDataReader.GetInt64(_ReturnDataReader.GetOrdinal("c"))
Have SQL Server 2005 count for me....
 

View 1 Replies View Related

Datareader Security

Jun 15, 2007

As a beginner, I'm attempting to set up security for SQL Server But it's not working and am fairly confused at the moment.

The current problem is to do with getting SQL Security logins to work. I've added a login for a 'reader' user (no updates allowed) and have set the database user to use only the 'db_datareader' role. Yet, when I logon as that user, I can update data without a problem.

The system is a standalone PC using XP Pro with SQL Express installed.

The connection string is valid (and works, allowing access to all data) and is of the type:
"server=xxxxx;database=xxxx;Trusted_Connection=True;"

The application is written is VB.NET

I hope I'm making some simple mistake here and I'd really appreciate any thoughts ...

Many thanks

View 6 Replies View Related

DataReader.GetFloat From SQL DB

Apr 22, 2008



Hi All,
I am the following problem retrieving Float data from a Compact SQL database, it worked perfectly with 1.1 .Net CF, but since updating to 2.0 .Net CF its crashing with a "InvalidCastException" Error, have checked the DB its a Float...

// Start of code snip


cmd = conn.CreateCommand();

string cmdString ="select " +

RECORDNUMBER_COLUMN + ", "

+ FULLNAME_COLUMN + ", "

+ FPFILENAME_COLUMN + ", "

+ IMAGENAME_COLUMN + ", "

+ BMPNAME_COLUMN + ", "

+ TEMPLATENAME_COLUMN + ", "

+ SCORE_SCORE_COLUMN + " "

+ "from " + ENROLTABLE_NAME + " where " + RECORDNUMBER_COLUMN + " = " + iNumber;

cmd.CommandText = cmdString;

SqlCeDataReader DataReader = cmd.ExecuteReader(System.Data.CommandBehavior.SingleResult);

while(DataReader.Read())

{


recordnumber = DataReader.GetInt32(DS_WORD_COLUMNINDEX_RECORDNUMBER);

fullname = DataReader.GetString(DS_WORD_COLUMNINDEX_FULLNAME);

fpdataname = DataReader.GetString(DS_WORD_COLUMNINDEX_FPFILENAME);

fpimagename = DataReader.GetString(DS_WORD_COLUMNINDEX_IMAGENAME);

personbmpname = DataReader.GetString(DS_WORD_COLUMNINDEX_BMPNAME);

persontemplatename = DataReader.GetString(DS_WORD_COLUMNINDEX_TEMPLATENAME);
//*******************************************************


Score_Score = DataReader.GetFloat(DS_WORD_SCORE_COLUMNINDEX_TEMPLATESCORE);
// This generates the error : "InvalidCastException"
//*******************************************************


ReturnValue=true;

}

DataReader.Close();

conn.Dispose();

cmd.Dispose();



// End Of Snip


Cheers for any help with this

Adz

View 1 Replies View Related

SQL Command Datareader

Jul 31, 2007

I have the following SQL statement in the DataReader.SQLCommand.

select * from myTable where DataEdited > 'some hard coded date data'

I want to read the above 'some hard coded date data' from a table sitting in different database which is not the same server where the DataReader is connected.

How to do that?

I can populate the 'some hard coded date data' to a SSIS variable but do not know how to embed that in the SQL statement.

Thank you for your thoughts.

Smith

View 9 Replies View Related

DataReader And Bad Dates

Aug 9, 2006

Hello,

I am using a DataReader to read an ODBC Data Source.



Some of my dates are not valid. I would like to have the DataReader just treat the bad dates as Null. However I cannot seem to find a setting that will get me past the DataReader.



In SQL 2000 DTS I was able to use a script to skip the bad dates.



Please help because I don't want to have to run SQL 2000 DTS on SQL 2005.



Thanks,



Michael

View 2 Replies View Related

Using Parameter From XML DataSet In Another XML DataSet

Apr 5, 2007

Hi every body...
I have a probleme
I have a web Services which contains a method getValue(IDEq (int), idIndicator(int), startTime(dateTime), endTime(dateTime))
I need to call this method. But my problem is how pass parameter ?
I see the tab Param but it isn't work as I wait,... maybe I do a mistake...

I want that statTime and endTime are select by the user via a calendar for example...
now idIndicator and idEq was result of an other dataSet from a xml datasource...

But I don't how integrate dynamically... I try to enter a parameter via the param tab, and create and expression :
=First(Fields!idEq.Value, "EquipmentDataSet")
but when i execute the query, the promter display <NULL>...
So I don't know how to do and if it is possible !
I hope someone can help me !
Thank you !

View 3 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved