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


Similar Messages:

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

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

Aug 27, 2010

when i insert record ,There is already an open DataReader associated with this Command which must be closed first.

SqlConnection conn = new SqlConnection(@"Data Source=LocalhostSQLEXPRESS;Initial Catalog=StudentDetails;Integrated Security=True"); [code]...

View 6 Replies

WCF / ASMX :: There Is Already An Open DataReader Associated With This Command Needs To Be Closed

Nov 26, 2010

My scenario:I am using a web service which access the sql server database to provide an XML output. this part is working fine. I am using a SqlDataAdapter and DataTable with Fill method to get the data.

Problem:When more than one person access this web service at the same time i get the error message which is given in the subject line.

I understand the problem is because of the sql connection which is still open by the first user. If the first user completes his operation before the second users request then both the user receives the correct response.

My Solution:What i did was i initiated 10 connection strings and will check which connection string is closed and i have used this connection for the second persons request if they both access at the same time.

View 6 Replies

Access :: How To Avoid "There Is Already Open Datareader Associated With This Command Which Muct Be Closed

Jul 21, 2010

i am getting this error "There is already open Datareader associated with this command which muct be closed first"

what are the chances of getting this error becoz it giving me so much problem

and how can i solve this error by writing a well code

View 3 Replies

ADO.NET :: How To Handle Error : DataReader Associated With This Command Which Must Be Closed First.

Feb 21, 2011

what are the best way to handle this error

There is already an open DataReader associated with this Command which must be closed first.

i have created my own conneciton class for the same

is there any best way ,is .net manage this things if i use any inbuild class

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

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 :: DataAdapter - Issue An INSERT Command Without SELECT Command?

Jan 6, 2010

I want to issue an INSERT command for an SQL Server table using DataAdapter without first issuing a SELECT command. Could anybody send me lines of code to handle this? Also how do i manage INSERT into selective table columns (I have 10 columns but i only want to update 2 of them)?

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

C# - DataReader Already Open When Using LINQ?

Apr 22, 2010

I've got a static class containing a static field which makes reference to a wrapper object of a DataContext.

The DataContext is basically generated by Visual Studio when we created a dbml file & contains methods for each of the stored procedures we have in the DB.

Our class basically has a bunch of static methods that fire off each of these stored proc methods & then returns an array based on a LINQ query.

Example:

public static TwoFieldBarData[] GetAgesReportData(string pct)
{
return DataContext
.BreakdownOfUsersByAge(Constants.USER_MEDICAL_PROFILE_KEY, pct)
.Select(x => new TwoFieldBarData(x.DisplayName, x.LeftValue, x.RightValue, x.TotalCount))
.ToArray();
}

Every now and then, we get the following error:

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

This is happening intermittently and I'm curious as to what is going on. My guess is that when there's some lag between one method executing and the next one firing, it's locking up the DataContext and throwing the error.

Could this be a case for wrapping each of the DataContext LINQ calls in a lock(){} to obtain exclusivity to that type and ensure other requests are queued?

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

DataReader Already Open Error When Trying To Run Two Queries

Nov 10, 2010

I have a couple of queries that I need to run one to a linked server and one not like this

Dim InvestorLookup As String = "DECLARE @investor varchar(10), @linkedserver varchar(25), @sql varchar(1000) "
InvestorLookup += "SELECT @investor = '" & investor & "', @linkedserver = '" & db & "', "
InvestorLookup += "@sql = 'SELECT * FROM OPENQUERY(' +@linkedserver + ', ''SELECT * FROM db WHERE investor = ' + @investor + ' '')' EXEC(@sql)"
Dim queryInvestorLookup As SqlCommand = New SqlCommand(InvestorLookup , conn)
Dim BondNoDR As SqlDataReader = queryInvestorLookup.ExecuteReader()
Dim PasswordCheck As String = "DECLARE @investor varchar(10), @password varchar(20), @linkedserver varchar(25), @sql varchar(1000) "
PasswordCheck += "SELECT @investor = '" + investor + "', @password = '" + password + "', @server = '" + db2 + "', "
PasswordCheck += "@sql = 'SELECT * FROM @server WHERE investor = @investor AND password = ' + @password + ' '' EXEC(@sql)"
Dim queryPasswordCheck As SqlCommand = New SqlCommand(PasswordCheck, conn)
Dim PasswordDR As SqlDataReader = queryPasswordCheck.ExecuteReader()

As far as I can tell from debugging the queries both run as they should but I get the error There is already an open DataReader associated with this Command which must be closed first. Is it possible to run two queries in two different DataReaders. I need to later reference each DataReader and select values from each.

View 3 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 :: 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 :: DataTable With DataReader Not Working?

May 17, 2010

dataTable with dataReader not working

[Code]....

View 3 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 :: 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

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

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

Forms Data Controls :: Cannot Open Db Con On Gridview Row Command?

Mar 8, 2011

inside row command event of gridview i want to call a function which will open db conectn and run a stored proc to fetch value.but this gives error.

View 3 Replies







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