DataSource Controls :: DataReader Telling Me It Needs To Be Closed
Jun 28, 2010Dim sqlc1 As New SqlCommand("sp_navmenu 275,1,21", ERIKSDbCon)
View 4 RepliesDim sqlc1 As New SqlCommand("sp_navmenu 275,1,21", ERIKSDbCon)
View 4 Repliesprotected void Page_Load(object sender, EventArgs e)
View 7 RepliesI 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]....
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]...
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.
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
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
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.
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 Replieswhy 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.
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]....
Any one can suggest a method to convert Datareader to dataset or any alternate method
View 7 RepliesdataTable with dataReader not working
[Code]....
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
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.
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 Repliesi 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 RepliesI 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]....
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
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]...
Environment is : vwd2008, asp.net 3.5, linq to sql object model, formview, stored procedure used for query.On going problem... I have a simplified page with a webform content area from a master page. The content area contains a FormView connected to an object data source thru the design view tag. The O/R designer has the Lease Table and the stored procedure in the method area.
The stored procedure selects all records from a single table. I an using the DatabaseDataContext and selecting stored procedure name which has "return SingleResult".. There is no code written; the design view was used to create everything. The stored procedure executes in VWD 2008 express tab and shows desired records. I would like to use the O/R and Linq to SQL, and objectdatasource BUT.
I get the following error when I try to update rows in the DebtorList table : Invalid attempt to call FieldCount when reader is closed with LINQ
// Query the database for the row to be updated.//USE DL TEST VERSION...
var queryUpdateWithoutExclusions = (
[Code]....
How can you tell the difference between a request going to 127.0.0.1 and localhost.
This line of code on Windows 7 and VS2010 built-in web server can not tell the difference.
if (Request.ServerVariables["SERVER_NAME"].ToLower() == "localhost")
{
}
try hitting your own built-in web server with:
http://127.0.0.1/
and then
http://localhost/
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 RepliesI have some code in umbraco that is run and creates a javascript file for looking up there IP and sending them to the correct site for there language, now this worked but i'm trying to add an override system into it so a user of the site can force them self's out of the redirect using cookies but for some reason when i try to right the response it tells me that the Response local variable cant be used before it is set
<%@ Master Language="C#" MasterPageFile="/umbraco/masterpages/default.master" AutoEventWireup="true" Debug="true" %>
<%@ Import Namespace="System" %>
<%@ Import Namespace="System.Net" %>
<%@ Import Namespace="System.IO" %>
<asp:Content ContentPlaceHolderID="ContentPlaceHolderDefault" runat="server">
<script runat="server">
string getOutput(){
HttpCookieCollection MyCookieColl;
[Code].....