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


ADVERTISEMENT

One Clarification

Jan 20, 2000

Hi friends,
How r u?..i have one clarification..Curently, i am doing one search engine stuff...for that, i have to populate data from sql server database to flat file..i got java script search engine code from one web-site,in that code,data's are fetching from flat-file only..so i have populate the data from sql server to flat-file, and then get the key-word value from that flat-file according to the user input..Is it possible?..send mail..

Bye from
Jan Reddy

View 1 Replies View Related

Clarification

Jan 22, 2008

I just finished getting a local database mirrored to an offsite "DR" server. Interesting experience getting that working, but that's another story! It's set up as "High Safety without automatic failover (synchronous) (without a witness). I was hoping I could get a sanity check in this flow....

Local database gets updated each morning with a few meg of data, so it's pretty low use. It's mirrored through a T1 (soon to be dual). My remove copy was restored from yesterday€™s backup, and the mirror was sync'd in less than 10 minutes, so I don't expect bandwidth to be an issue...

In the event that my local server or network is down, I'd be able to log into my remote server, and run my application remotely. From what I've seen, the "Failover" option is only available on the "Primary" server? Will this become an option if the remote no longer sees the primary, or do I need to do this through the command: ALTER DATABASE <dbname> SET PARTNER FORCE_SERVICE_ALLOW_DATA_LOSS?

Since the updates are so limited, I'm not too concerned with data loss, but will need to make sure I can get this running quickly if needed...

As I understand it, this will put the mirrored database as the primary, and when the old primary comes back only, it'll become the new mirror? I can then let them sync, and force a failover from the remote system to put the primary back to the local network.

I just want to make sure I understand this correctly before I start testing. Thanks for any assistance!

Steve

View 10 Replies View Related

Licensing Clarification

Jan 15, 2008

mine is a small organisation and we have deployed an ERP on windows 2003 server. their are total 60 ERP users and we have 25 concurrent licences for ERP.

at the backend we are running MS SQL 2000 standard edition. we have created one user in Database and ERP accesses data through this user only.

now i need to understand how many CAL for database i need to purchase. either 60 or 25 or 1.

thanks

View 1 Replies View Related

Clarification Needed

Jul 23, 2007

I hope someone can help here. I found that I was having replication failing due to the fact that there is a foreign key being referrenced, here is the error:
Could not drop object 'dbo.tblName' because it is referenced by a FOREIGN KEY constraint.
(Source: Database Name (Data source); Error number: 3726)





In searching for some sort of answer - I came across this:
Join Filters




Foreign key relationships are central to most database designs. For example, in a database that tracks product orders, you often see a CUSTOMER table with a CustID primary key and an ORDER table with a CustID foreign key that references the CUSTOMER table. In merge replication, if you filter the CUSTOMER table with a subset filter clause, you must also filter the ORDER table, so that only the rows that reference the filtered subset of rows from the CUSTOMER table are replicated. Filtering requirements that are based on a foreign key relationship must be explicitly represented in the merge replication configuration through a join filter (which lists the two related table articles and a logical expression that identifies the relationship), as shown in the following example:CUSTOMER.CustID = ORDER.CustIDThe effect of this join filter between the CUSTOMER table and the ORDER table, together with the subset filter
clause on the CUSTOMER table, is that Subscribers to the publication receive only those rows from the CUSTOMER
table where State = 'WA' and only those rows from the ORDER table that correspond to the CustID
values in the filtered CUSTOMER table.
________________________________________________________________________
Am I reading this right? If I have only one table that I need to replicate, I would need to included the other tables connected by
the foreign key for the replication to work, and in doing so - the table I designate for updating in this replication will be the only
one affected and the others that have go with this - won't update their corresponding dupe tables? Sorry - I hope this makes sense.

View 3 Replies View Related

Clarification On Variables!

Apr 1, 2008

I have a question , because I€™m not very experienced with VB.

The function declares

Public myString
Public myKey

When something is declared this way, what happens if two or more users happen to execute the report at the same time? Is myString and myKey public to all of those reports at the same time, or does the Report Server manage those variables separately for each of the reports running concurrently?

Any clarification on this......................?

thanks

View 7 Replies View Related

Clarification For 'WHERE' Statement In A Dropdownlist

Feb 12, 2008

My goal is to populate a dropdownlist with only with users that are "Techs".  I am using the membership database that you ccan set up through VWD.  I added this column to the aspnet_Users table: IsTech as bit datatype. I thought I had the right SQL statement but apparently not, because I get an Invalid column name 'True'.Here is my statement: <asp:SqlDataSource                                     ID="SqlDataSource3"                                     runat="server"                                     ConnectionString="<%$ ConnectionStrings:HRIServiceConnectionString1 %>"                                                                    SelectCommand="SELECT [UserID], [FirstName]+ ' ' + [LastName] AS techid FROM [aspnet_Users] WHERE [isTech] = True ORDER BY [LastName], [FirstName]">                                </asp:SqlDataSource>  

View 9 Replies View Related

Basic Concept Clarification

Oct 2, 2007

The distinction between Entity and Relationship is obvious to me. But I am confused by Table. Table describes Entity, Relationship, or both?

Thanks for any input.

View 9 Replies View Related

Clarification On Product Specification

Sep 15, 2007

http://www.microsoft.com/sql/editions/compact/sscecomparison.mspx
The above link says the pros and cons of two SQL Server 2005 editions.
Document says Compact Edition is not good for €˜When you need a multi-user database server
€™.
What is the meaning of multi-user database?
Does this means the database strictly will not support two database connections at a time?
-Thank you,
Gish

View 1 Replies View Related

Small Clarification On Indexing

Jun 2, 2006

Can come one help me how to disable an index using select query.

View 1 Replies View Related

Collation Clarification/ Internationalisation

Nov 21, 2007

Hi,

I am working on a SQL Server database that will be accessed (mainly) via a web interface that will have users from various countries. As I understand it, the best way to store data is to use 'n' (nvarchar etc) datatypes for columns, which allow users to enter data and it will be stored in the raw Unicode format. For other reasons the collation of the db has been changed (to Slovenian) but I understand that this will only affect how data is sorted. However, whenever I try to put certain data into the nvarchar field (Such as the £ symbol) the data get transferred to a letter L. Is that how it would be expected to work and if so am I missing something here - note I Know ent manager sometimes shows data incorrectly, but this happens when I add/view data from anywhere (i.e. end manager/ the website/ query analyser).

Any clarification would be much appreciated.

Kenny

View 1 Replies View Related

Clarification On Mixed Join Types

Apr 10, 2008

Hi,
I'm seeing confusing results coming back from a query and I want to make sure my joins are working as expected.

I have 3 tables, tbl_family, tbl_familyPhone, and tbl_phone. tbl_FamilyPhone is a linking table between families and phones that specifies if it's the primary number.


tbl_Family tbl_FamilyPhone tbl_Phone
--------------- ------------------------- ----------------
pk_FamilyID pk_FamilyPhoneID pk_phoneID
fName fk_FamilyID fk_TypeID
lName fk_PhoneID ...
... ...

So a family has many familyPhones and a phone has many family phones. I'm trying to get all the families and their home phone only, if they have one. I don't want families to duplicate and I don't want any left out. Here's what I've got





Code Snippet
select [whatever]

from tbl_family
LEFT OUTER JOIN tbl_familyphone on tbl_family.pk_familyid = tbl_Familyphone.fk_familyid
inner JOIN tbl_phone on tbl_familyphone.fk_phoneID = tbl_phone.pk_phoneid and tbl_phone.fk_phonetypeid = 'E6F1688E-015B-481D-8C41-DCC1FEA5D5AB'






My thinking is the inner join between tbl_Phone and tbl_FamilyPhone will cause any FamilyPhone record without a phone record to be left out (fk_phonetypeid is the id of a home phone). Though some FamilyPhone records may be left out, I will not lose any families because it is left outer joined to familyphone. Is this right? Because if I just do select count(*) from families I get 4517 records, but when running the query above with the joins, I get 4383 records.

View 13 Replies View Related

Table Lock Option Clarification

May 5, 2008

Does the Table Lock option in the OLE DB Destination task in a data flow refer to a lock on the destination table or on the source table from which the table is loading from?

The reason I ask is because I have a package run twice simultaneously pulling from the same server and table onto two different tables on two different servers. When I kick off my job to run the two data pulls, one of the jobs terminates with a

"TCP Provider: An existing connection was forcibly closed by the remote host." message. I believe this is due to a table lock on the server, but can't figure this out.

Thanks in advance for your help.

View 1 Replies View Related

DB Engine :: Clarification On MDF / LDF Sizes And Backups

Jun 7, 2015

My environment looks like:

- Windows 2008R2 SP2 VM (VMware 6)
- SQL 2012 SP2 Std.
- NetApp iSCSI LUNs, Snapmanager for SQL

So I have created a test database and configured the logs to grow to max. 120MB in size.

To check the allocated and free space I right-clicked the database -> tasks -> shrink file

I see currently allocated: 5,00MB and 2,50MB free space for the MDF Database
I see currently allocated: 1,00MB and 0,63MB free space for the LDF Logfile

Next I use a data generator to fill the database with random data.

After adding around 500k rows I check the size again:

I see currently allocated: 17,00MB and 0,44MB free space for the MDF Database
I see currently allocated: 61,94MB and 0,27MB free space for the LDF Logfile

Next I take a full backup incl. truncating log files. After that I check the size again:

I see currently allocated: 17,00MB and 0,44MB free space for the MDF Database
I see currently allocated: 61,94MB and 57,24MB free space for the LDF Logfile

So now my question is where are those 56,97MB? I imagined they should now be added to the MDF file but they seem to be just gone. I did this procedure 2x more time and the MDF stays the same size while the LDF is almost empty after backups. Then I thought maybe its in the memory of the server so I rebooted it. But still the MDF has the same size... Is this normal? How it should work?

View 2 Replies View Related

SQL Server Admin 2014 :: Modify Size For Datafile Clarification

Mar 25, 2014

From BOL, I see these remarks with respect to the MODIFY FILE subcommand (my underline added):

Initializing Files
By default, data and log files are initialized by filling the files with zeros when you perform one of the following operations:

Create a database

Add files to an existing database

Increase the size of an existing file

Restore a database or filegroup

Which leads me to believe that expanding the size of a datafile will also wipe out (my definition of 'initialize') any existing data within that file.

I may be misunderstanding 'initialize', because when I tested it out, I found this wasn't the case - my table data written to the file was still there after a resize.

Need to clarify to what degree I'd be taking a risk by increasing the file size on a datafile which already has data in it.

View 3 Replies View Related

Setup And Upgrade :: Clarification On Non-integer Constants Are Not Allowed In ORDER BY Clause In 90

May 15, 2015

We're upgrading our SQL Server database from 2005 to 2012.I ran the Upgrade Advisory report and got this issue "Non-integer constants are not allowed in the ORDER BY clause in 90" because of the script below

SELECT
gp.BRAND+' <> '+gp.CATEGORY AS 'full name',
gp.PRODCODE,
gp.CATEGORY
FROM dbo.GFK_PRODUCT gp
ORDER BY
'full name'

I tried running the same query in our test SQL Server 2012 and it ran successfully. Now I'm confuse if i still need to change it.I google the issue a bit and came across this link and mentioned this.

1.) Non-integer constants are ... constants that are not integer number.

Example: 'string1' represents
a string constant
0x01 represents
a varbinary constant
{ts
'2015-02-26 06:00:00'} represents a datetime constant

1.23 represents
a numeric constants

2) So single quotes are used to define a string constants / character string constants but SQL Server allows also to use single quotation marks use also as column identifier
delimiter:
SELECT ... expression AS 'Column1'
FROM ...

In this context is clear that 'Column1' is a column identifier but when used in ORDER BY : ORDER BY 'Column1' it generates confusion because SQL Server doesn't knows if it represents a string literal (character string constant) or it represents a column identifier / column name."Do I still need to change the existing code even though it's working fine in 2012? If yes, it is because of best practice reason or it will total get deprecated/not working in the future version?

View 4 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

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

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 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 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 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

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







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