There Is Already An Open DataReader Associated With This Command Which Must Be Closed First
Feb 20, 2012
This reader is done in the form load event and is the very first thing done so I don't understand why it's telling me there is an open DataReader. I've also set MARS=True in my connection string so obviously it is something else.Here's my code and like I said the routine is called at the top of the form load event. The error occurs on the
and in class that starts new thread started every time users change some data(very often)
[Code]...
1. other parts of application are targeting other SQL server...just this adapter is updating only one row(table has two columns, some id and last time any of users changed something.
I get the following message "There is already an open DataReader associated with this Command which must be closed first." Is the insert statement the most effiecient way to write to the table row by row?
Dim comment As String Dim cnx As Data.SqlClient.SqlConnection = SqlCnx.SourceDB Dim cmd As New Data.SqlClient.SqlCommand("select number,comment from [Comments]", cnx) Dim daComments As New SqlClient.SqlDataAdapter Dim bsComments As New BindingSource cmd.CommandTimeout = "360" cmd.CommandType = CommandType.Text cnx.Open()
I have two datareaders: [Code] When i'm running the code i get this error in the highlighted line: "There is already an open DataReader associated with this Command which must be closed first." I used different variables in both readers, why do i get this error? do i have to open a new sqlConnection for this task?
I'm trying to put together a quick example for another thread about treeviews, and I'm getting a problem when I have a recursive routine, getting the message.
Quote:
There is already an open DataReader associated with this Command which must be closed first.
I'm a tad confused as I am explicitly creating a new command every time through the loop, so I'm not sure (unless its something ADO is doing behind the scenes) how the datareaders higher up the tree are interfering.
Here's my code :
Private Sub SetupChildren(ByVal ParentID As Integer, ByRef ParentNode As TreeNode) Dim MyCommand As New SqlCommand("SELECT * FROM Groups WHERE ParentGroup=@ParentGroup", m_myConnection)
[Code]...
Obviously I could close the data reader down before calling the next level of recursion but it would prevent the code continuing the loop at the current level when it had finished processing children.
I have a problem with my project. here is the problem:
My code for login is as follows:
dim conn as SqlConnection = New SqlConnection("Data Source.................) dim cmd as SqlCommand = New SqlCommand("Loguser",conn) cmd.CammandType = CommandType.StoredProcedure
[CODE]...
Now the error i get is that "there is a datareader associate with this connection that need to be closed"
why is the datareader closed? I had to change this from a stored procedure to dynamic because our IT guy was encountering trouble changing the sp permissions.. so there's definitely a time factor
Dim cmd3 As New SqlCommand cmd3.Connection = connect Dim dr2 As SqlDataReader
I have a datareader pulling data from Oracle. It all works fine but I have one issue. When I issue the read() command ala;
While dr.Read Column1List.Add(dr.GetValue(0).ToString().Replace(vbCrLf, "")) Column2List.Add(dr.GetValue(1).ToString().Replace(vbCrLf, ""))
[Code]....
When the code hits that " While dr.Read" line it will hang there for up to 30 minutes which is just a ridiculous amount of time to advance to the next record, which is what the documentation says is all that is happening here. It only occurs the first time it hits that line...once it gets past it once, it does not hang again as it goes through it's while loop.
I have this sub as part of my login / logout system. When this sub is called to login users it works perfectly, but on logout it throws an error that doesn't make any sense to me.
[Code]...
This sets a nonsense email address so that when validate_session searches for a valid email/session combo in the db it trips the destruction of the sensitive session data.
The question boils down to this: Why is the error being thrown when the logout sub calls validate_session?
I'm making a Visual Basic GUI application to display whether a number of my ports are open for people to know whether things like my website and my Minecraft server are open.My problem is I have absolutely no idea how to do this in Visual Basic.Basically, I'm asking for something which sends a signal to an IP with a specific port, if it is open then return true, if it's closed, return false. Similar to: http:[url]....
Simply enough, I closed a design window, and now I can't reopen it.Whenever I click on the form in the Solution Explorer, there is no option to show the design view, yet I know that there is one.When I go to the folder where the files are stored, there is a file there is supposedly the design of the form I closed, but when I open it, all that appears is another window of code.
I need to know if a form2 is already open when a button1 on form1 is clicked. I found the following code which fails when I open form2 then close form2. When I click button1 on form1 nothing happens. Is there a way to reset form2 to nothing or is this just wrong?
Sub isFormOpen() If xmlTest Is Nothing Then xmlTest.Show() OpenXML(filename) End If End Subdavidbell
I'm new to VB 2010 but have be using VB6 for many years.I'm currently stuck trying to store the state of open MDI childs at the moment the MDI parent is closed. Clicking the parent upper right close button appears to close all open MDI childs before running the parent 'Closing' or 'Disposed' events.I am therefore unable to detect which MDI childs are open and cannot restore them next time the application is run.Is there any other event for the MDI parent I can detect the start of the closing process before the children are closed?
I have been searching and trying for quite some time now but did not yet find the right way to solve my problem.Here is what I want to do:- open powerpoint with a file (an disable the UI of my app while it is opened)- make some changes to this file- save it with a new name- get notice when Powerpoint is closed (either by my app once the automatic changes are done or if the user quits Powerpoint)- enable UI once Powerpoint is closedThe notice is my problem. Is there an easy way (other than timers that check the process list) to get notice of when my started Powerpoint-Process is closed/quit?
I have an application that can read certain types of files, and I have it working so that if you do "open with" from windows, it automatically starts the application and opens the selected file.
Unfortnately, I cannot get it to work for more than one file.
System.Environment.GetCommandLineArgs() contrains the following: System.Environment.GetCommandLineArgs(0) = name and path to the .exe System.Environment.GetCommandLineArgs(1) = name and path to the first file selected to be opened
System.Environment.GetCommandLineArgs().Length is 2 when the user tries to open 1 file, which makes sense since the first argument is the .exe itself and the 2nd is the path to the file, but it does not increase to 3 if the user tries to open 2 files... meaning that System.Environment.GetCommandLineArgs(2) is never populated Here is some sample code that shows the problem: It will recognize no files or 1 file being opened, but if you try to open multiple it will only show the first.
Im using a dataset to display data in a datagrid from a sql server DB. One of the colums I have in my datagrid is "Status" the table adapter sql statment selects certain items based on whether there open or closed e.g "where = Open ". I want to remove this row entirely and instead of displaying open or closed for status column, display the open/ closed results in colour on the datagrid. Im really not sure how to go about this whether i need to do it in the table adapter or some sort of property. I presume i need to write a sql statement and selct the identity of the row where x= open etc , is there a way of assigning a colour in sql statement so it displays on my vb form ?
I'm developing a device app in VB.net that will access a SQL Server database. I need to establish a connection when the app is launched, and keep the connection open until the app is closed. I've done the following:In the Master Module:
Public CNN As SqlConnection
In the Main menu form load:
CNN = New SqlConnection(sqlConnString) CNN.Open()
Then when I want to read from the database:
Dim sqlDR As SqlDataReader SQL = "SELECT Name FROM Table"
[code]....
When I run the same code without the global CNN, but rather dim the connection inside the Select function, all works well.
I am currently working on a menu driven console program that so far has 4 menu options of checking internet connection, decrypting/encrypting a message, calculator, and a logout, and i am wondering about a few current things.
1. How do i make it to where, when a program starts for the first time, it asks for a user to enter in his data, like signing up for a site for the first time?
2. How do i make it to where the program will save the data entered, and does not delete when the user closed the program.
3. How can i make it to where when a user signs in, his/her data is read correctly? Like an array search for a multidimensional array.For my "New user" sign data i created a function...
Function createNewUser() As String() Dim name As String Dim userName As String[code]...
I'm trying to insert a new records into database, one of those records is a "datetime"...when I type a wrong date, and try to insert those values into database, i get an error (about wrong typed date etc.)...ok, that's fine, things need to work that way. But here comes the problem, I correct the date, and then try to insert values again...here I get an error from the post title. And this doesn't work until I close that form and run it again...here's part of my code:
Dim cvLicence As New SQL Try cvLicence.upis("INSERT INTO blabla (itsnotimportant) VALUES ('something')") MsgBox("everything's fine", MsgBoxStyle.Information)