DataSource Controls :: DataReader.Read() Not Working?

Mar 16, 2010

I have used SqlDataReaders a million times. Someone, what is wrong with this code:

SqlConnection connection = new SqlConnection(connectionString);
try
{
connection.Open();
SqlCommand command = connection.CreateCommand();

[Code]....

I have checked this against similar classes and it is exactly the same, but this one doesn't work.

View 4 Replies


Similar Messages:

DataSource Controls :: Almost 2 Seconds To Read A Datareader Field

Apr 16, 2010

I use a SqlDataReader to get fron sqlServer a row af a table. This table have a text field where I store a Xml configuration. In one case this Xml grow up to 650Kb. When I get the field from the datareader it cost amost 2 seconds:

INFO 2010-04-16 09:46:40,559 [12] Cms.dataContenido - readed
INFO 2010-04-16 09:46:42,356 [12] Cms.dataContenido - XMLContent

This is my code:

[Code]....

View 1 Replies

DataSource Controls :: DataTable With DataReader Not Working?

May 17, 2010

dataTable with dataReader not working

[Code]....

View 3 Replies

DataSource Controls :: ODBC Datareader Is Not Working With DB2 Some Tables?

Jun 2, 2010

This is the code i am used for fetching data from DB2 server (windows based server)In the same server tables created by me is working fine...eg:

oCommand.CommandText = "SELECT * from DEB.TESTUSER";

below is a table created by another application but the data reader is not working with this query ( table in the same server with same DB as above)

oCommand.CommandText = "SELECT * FROM DEB.RULE_GROUP";

If any permission or any other things i want to check .....i mean security related.....odbcadapter is also working fine....pls help regarding the datareader.....below is the complete code......

private void btnSelectRecord_Click(object sender, EventArgs e)
{
OdbcConnection oConnection = null;

[code]...

View 3 Replies

DataSource Controls :: Use A DataReader With SQL?

Mar 29, 2011

I have put a SQLDataSource on my page and everything is adjusted and it works properly. I read an article
here which was indicating that you can use a DataReader in order to get data from sqldatasource, but it doesn't say how, the only thing that is said is to use DataSourceMode property in order to adjust it for a DataReader.

View 1 Replies

DataSource Controls :: How To Load A DataReader

Apr 21, 2010

How do I load a datareader in a defult.aspx page using while using a database connection that is defined in the web.config file?

View 3 Replies

ADO.NET :: DataReader Or DataSet To Read An Output Parameter Not Essential?

Nov 4, 2010

I always thought we had to use a DataReader or a Dataset to read a given SQL data but i realized that it is not necessary to use them to read an SQL Output Parameter(im not a SQL expert).

View 1 Replies

DataSource Controls :: Create ConnectionString Using SQL DataReader

Sep 11, 2010

why this first connection works but the second doesn't?

[Code]....

I'm trying to use <asp:FileUpload> to upload images and as far as I know you have to use <asp:SqlDataSource> to do it but I need to create the connections string using entries stored in a database.

View 2 Replies

DataSource Controls :: DataReader Telling Me It Needs To Be Closed

Jun 28, 2010

Dim sqlc1 As New SqlCommand("sp_navmenu 275,1,21", ERIKSDbCon)

View 4 Replies

DataSource Controls :: How To Evaluate Nothing Value Returned By Sql Datareader In Vb.net

Aug 24, 2010

When a sql query returns NULL , I can use the following code to evaluate:

[Code]....

When a sql query returns nothing, neither IsDBNull nor is Nothing works. I don't know why some sql queries return null while some return nothing when there are no data returned. But anyway, can somebody tell me how to evaluate nothing value returned in sql datareader in vb.net? When I put the cursor over signInfo variable in debug mode, I can see Nothing show as its value. But the line does not work

[Code]....

View 3 Replies

DataSource Controls :: How To Convert Datareader To Dataset

May 11, 2010

Any one can suggest a method to convert Datareader to dataset or any alternate method

View 7 Replies

DataSource Controls :: Datareader - Loop Through Results In VB?

Feb 1, 2010

I would like to loop through my result set and generate a menu structure like this:

pagetitle
pagetitle
subtitle
subtitle
pagetitle
pagetitle

So far I have the following code but it doesn't generate the menu?

While reader.Read()
' set title
sitetitle = reader.Item("siteName")
mydata &= reader.Item("pagetitle")
' check subtitle exists, if so, build menu, loop though subtitles somehow?
if not IsDBNull(reader.Item("subtitle"))
mydata = "<ul>"
mydata &= "<li>" & reader.Item("subtitle") & "</li>"
mydata &= "</ul>"
end if
End while

Qeury and result set below:

sql:

SELECT subpages.subpageid, pages.pageid, sites.sitename, sites.siteid, pages.siteid,pages.pagetitle, subPages.subtitle FROM pages LEFT JOIN sites ON pages.siteid = sites.siteid LEFT JOIN subpages ON subpages.subpageid= pages.pageid WHERE sites.siteID = 1 ORDER BY sites.siteid, pages.pageid, subpages.subpageid ASC

results:

subpageid | pageid | siteid | siteid | pagetitle | subtitle
NULL 1 SCHS 1 1 Sandwell Community Healthcare Services NULL
NULL 2 SCHS 1 1 About Us NULL
NULL 3 SCHS 1 1 Your Services NULL
4 4 SCHS 1 1 Equality and Diversity Team at SCHS 1111
4 4 SCHS 1 1 Equality and Diversity Team at SCHS 2222
4 4 SCHS 1 1 Equality and Diversity Team at SCHS 333
4 4 SCHS 1 1 Equality and Diversity Team at SCHS 44444
NULL 5 SCHS 1 1 Single Equality Scheme NULL
NULL 6 SCHS 1 1 Diversity Strands NULL
NULL 7 SCHS 1 1 Equality Impact Assessments NULL
NULL 8 SCHS 1 1 Quality and Safety Committee NULL
NULL 9 SCHS 1 1 Contact Us NULL

View 5 Replies

DataSource Controls :: There Is Already An Open DataReader Associated With This Command Which Must Be Closed First.

May 27, 2010

protected void Page_Load(object sender, EventArgs e)

View 7 Replies

DataSource Controls :: Retrieve Text Field Using Datareader

Feb 25, 2010

I have text field on a sql server table and I retrieve it on string variable using datareader : string result = reader["MyTextfied"] but I have this errors ( text or binary field cannot be troncated ) My text fied contains a large of text

View 5 Replies

DataSource Controls :: Manage A Datareader With Data Field?

Mar 25, 2010

i have a datareader who read from data field from sql server, this field is datetime format now, when this field is null it returns 01/01/1900!! how can i manage it without if or some check, is there a property in datareader or sqlserver properties who i can return null value from datetime field?

View 4 Replies

DataSource Controls :: Reading With DataReader Into List And OutOfMemoryException

Sep 23, 2010

I'm Using a DataReader to Read about 100,000 records, my code look like :

[Code]....

I have a per row computation in reading the rows on GetMyType2Info() method, and this method also another method that I return only one record by ExecuteReader(). the problem is that when the MyTypeList (List<T>) has about 21,000 Items of MyType (<T>) System.OutOfMemoryException is thrown. wanted to know how to resolve this and wanted to know more about the maximum size of List<T> capacity. in addition the execution of the main Query with 100,000 records take about 4 seconds in SQLServer a record has only types of nvarchar , float,datetime and int

View 1 Replies

Web Forms :: Datareader Error: Invalid Attempt To Read When No Data Is Present

Apr 3, 2010

I am getting the following error when i am trying to assign values to controls on form via datareader, i know i got one row. but this particular field has no data in it.

I do have lot of other forms where i use the same style

getting this error: invalid attempt to read when no data is present

on this line: If gDatareader("CutoffDate") Is DBNull.Value Then

View 4 Replies

DataSource Controls :: MARS - "There Is Already An Open DataReader Associated With This Command Which Must Be Closed "

Feb 23, 2010

I am using MS SQL Server 2005 and i added "" to my connection string and i still have the problem

"There is already an open DataReader associated with this Command which must be closed" ;

SqlDataReader dr2;
StrSql = " SELECT * from Modules";
cmd.Connection = conn;
cmd.CommandText = StrSql; [code]....

View 1 Replies

Datareader Vs Dataset - Get The Number Of Rows From The Datareader?

Nov 15, 2010

I'm having a method that exports content from the database to excel files. The method taks as paramaters a DataReader param and a int param - the number of rows. For the number of rows i'm using a dataset, wich i fill using the same query as for the datareader. So I'm executing it twice... Is there a way I can avoid that? get the number of rows from the datareader?

View 1 Replies

C# - Already An Open DataReader Associated With This Command - When I'm Not Using Datareader

Jul 28, 2010

I am getting an error that an open DataReader associated with this Command, when I'm not using datareader(though probably executereader() is the same thing) how would I close this if I don't have a datareader present?

using (SqlConnection conn = new SqlConnection(ConnectionString))
{
SqlCommand cmd = new SqlCommand("spSelectAllTypes",conn);
cmd.CommandType = CommandType.StoredProcedure;
[code]...

I just want to be able to databind a bunch of dropdownlist in one open connection. (before I had multiple open and closes for each control)

View 2 Replies

DataSource Controls :: What's Faster Working With DataSet OR Working With Collections (LINQ To Entities)

May 21, 2010

I mean, what is the faster way to get as fast as I can more than one table with stored procedure? Is there any study what is faster and why? There is a big problem getting more than one table at once with Entities, so the only way is DataSet. But I was told DataSet work very slow. Is that true?

View 2 Replies

DataSource Controls :: Entity FK Setup Via VS2010 / Working Enity Model With Foreign Keys Working?

Jul 9, 2010

Am trying to get a working enity model with foreign keys working but have run into a problem. I have imported 3 tables with content and some data.Lets call these tables geo_countries, geo_counties, geo_municipalities and the FK are:1. geo_county have a column country_id wich corresponds to country_id in geo_country 2. geo_municipality have a column county_id wich correspond to the county_id in geo_county.The problem i have is when i try to get correspondig child items with the following code i run into trouble:

[Code]....

The problem above is that 'test' generates results but not 'test2', wich never return anything. Am i not supposed to be able to do it like i do in 'test2'? I earlier tried to add a child object by replacing ToList() with Add() and that worked. But i cant seem to get anything out of it.

View 4 Replies

DataSource Controls :: How To Read A Single Row

Feb 5, 2011

I wanted to know is it possible to pass "SqlDataSource" data to a variable? if not how can i use datareader to do this?

i couldn't figure out how to pass SqlDataSource to a varialbe so i tried use datareader and i'm stuck in middle of it, also my query only returns one row and one column so i rather not to use array if possible. here is my code:

[Code]....

View 3 Replies

DataSource Controls :: How To Know Mail Is Read

Mar 27, 2010

I want to achieve that when a user click on the subject to open the email, then i want to update the database. I want to update the database on the click of the subject only.

View 2 Replies

DataSource Controls :: Read A Bit Value From DB With SqlDataReader?

May 2, 2010

In SQL Server 2008 bit is like boolean (true/false), but I tried to read the bit value (0 or 1) and got error. How can I read it?

[Code]....

View 1 Replies







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