VS 2008 Recursion Failing With Command/DataReader Objects Already Open
Jun 26, 2009
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.
View 5 Replies
ADVERTISEMENT
Mar 13, 2012
There is already an open DataReader associated with this Command which must be closed first
Dim staffid = TextBox1.Text
Dim conn As New SqlConnection
conn.ConnectionString = SqlDataSource1.ConnectionString
[code]....
View 4 Replies
Jul 12, 2009
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?
View 13 Replies
Feb 7, 2011
Ok...i have read all posts..and no solution...on main form I have...
adapSB.Connection.ConnectionString = "Password=xxx;Persist Security Info=True;User ID=xxx;Initial Catalog=dbone;Data Source=xxx
adapSB.Fill(DTSB)
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.
View 4 Replies
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
Reader_Customer = command.ExecuteReader() line:
Module Globals
Public g_strConnectionString As String = "workstation id=" & System.Environment.MachineName & ;" _ & "packet size=4096;Connection Timeout=60; " _
[code].....
View 4 Replies
Oct 14, 2009
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()
[code]....
View 3 Replies
Jun 24, 2010
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.
View 3 Replies
Mar 29, 2011
[Code]...
Im clearly opening it there and its valid as i use the same connection to login with, anyone know the problem?
View 4 Replies
May 2, 2012
I just started playing around with VB today and have been working on getting a very simple program running. I am trying to create a program where when I hit a button it will open a command window and run a command. I have worked on this for a a good portion of today, and have not been able to find a solution to do this.[code]I have been through a few other things to get it to work, but nothing has seemed to work. Is there a better way to go about this? it seems like it should be simple, but I'm just missing it.
View 8 Replies
Jun 22, 2011
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?
View 1 Replies
Jul 30, 2009
I have both the VB and C# versions of Visual Studio 2008 Express. When I run a console application in either version, instead of the console opening in an old DOS style command window like it does in VS 2005, it actually blacks out both monitors attached to my computer and treats the entire screen real estate as the console.Anyone know how to get the app to run in a small command-type window when I run it? It's like the console is running Full Screen. If I set a break point, switch from the IDE t the console and then hit Alt+Enter it switches to the small window that I want, but I still can't figure out how to make the app start with the console that way.I could post a screenshot but it would look like a big black square...no window, no frame, just the inky blackness of frustration.
View 2 Replies
Feb 24, 2010
I am using the following code to run defrag and to analyze if the C: drive requires defragmentation:
Dim analyze As Process = System.Diagnostics.Process.Start("C:WindowsSystem32defrag.exe", "C: /a /h /u /v")
This process runs through analyzing, runs it in normal mode & prints the progress to the command window.
My problem is that as soon as the process is complete the command window closes. I need it to stay open so that I can read the results.
View 3 Replies
Jul 6, 2009
I'm building application that will heavily use database (about 25k query's in few hours) , what is the best way to go:
A) use datareader and open new connection to the database on every client query.
B) load all the needed tables into dataset once the program loaded and use that dataset for the query's?
View 8 Replies
Jun 24, 2009
I have a main form, and some sub forms, and each sub form can have some sub forms. When I have multiple sub forms open, and I try to get data from the parent form, it returns the data from the wrong parent form.For example I have two instances of Mainform.subform running. If I do something like this in a child form of one instance of the subform. It returns data from the other subform.
dim l = Mainform.subform.listofdata
Edit:I am using visual Studio 2008. Winforms, form designed using designer. In my mainform I am doing this
Protected Friend frmMain as Mainform
frmmain = new mainform
In frmMain I am doing this
Protected Friend frmsub as new Subform'
frmsub = new subform
[code]....
View 1 Replies
Feb 20, 2012
I have an SQL statement like:
SELECT FNAME, LNAME, CITY from EMPLOYEE
How do I create a multi-dimensional array from a datareader which should store values like:
John, Doe, LA
Mike, Johnson, PASADENA
Freddy, Kruger, Long Beach
View 3 Replies
Jun 22, 2011
I'm confused with this piece of code listed below. This code calls the update method of the dataadapter object to save the changes made to the dataSETback to the database itself. What I don't understand about this code is that it creates an update command(cmdUpdate), insert command (cmdInsert) and delete command (cmdDelete). My understanding is that the update method saves the changes back to the database. So I don't understand why the author creates these additional commands.
View 6 Replies
Sep 16, 2010
I was just curious as to whether after you have added all of the Parameters to the SQL Command Parameters Collection. Is there a convenient way to iterate or loop through the Parameters and make Assignments to the SQL Command Parameters Values Property?
View 2 Replies
Aug 27, 2010
just hoping that someone may be able to point me to some information where I can create VBA objects in vb.net (I am using VS2008). For example, I would like to create a new object in VBA with the command (Dim x as Matrix) where 'Matrix' is an object with various properties and methods.
View 15 Replies
Dec 16, 2011
Im considering making my own command line interface with custom commands etc. I was thinking the following objects would be sufficient:
Textbox - for input
Rich text box - for showing processes and output
Button - to insert input
If it can be done, how can I provide line breaks in the output on the rich textbox e.g.
line1: input instruction
Line2: <cp><textfile.txt>
Line3: I/O error, file not found, check file root.
My version of CLI will have no integration with the windows CMD.
View 2 Replies
Feb 11, 2011
My app currently uses both SQLExpress and SQLCE, depending on the choice of the user.In my database class I have non query command objects for the CE connection and non query command objects for the express version.
Essentially, this is duplicating code as Parameters.Add etc. has to be repeated on both objects.Is there a way just to add do it once on a common object?
Dim MyConnection As SqlConnection
Dim MyCEConnection As SqlCeConnection
Dim MyNQCommand As SqlCommand
Dim MyCENQCommand As SqlCeCommand
View 2 Replies
Mar 10, 2010
I am having trouble with executing the setapprole stored procedure in VB.NET on a SQL server database. When in SQL Server Management Studio Express, if I connect to servernameinstance as MYUSER, I can create a new query on the MYDATABASE database in there, with these two lines[code]...
View 1 Replies
May 19, 2010
So, I'm trying to make a RichTextBox which makes seperate words colored as you type them (like in Visual Studio itself ).The problem is, it's absolutely not working as I want and absolutely not the same as in Visual Studio.It's constantly running over the code each 500 milliseconds (by a timer), bugging the focus and selecting the words you want to be colored quickly.
Also, when you have something selected in the textbox,it constantly unselects when it runs over the code again (tried to fix that, but failed).So, can please someone improve this code (a lot, it's coded really bad ) so the user doesn't notice the words are getting colored?I put the words into an array with a different array containing the colors of the string array on the same index (Sorry for my "not so good" english.. But I'm sure you understand it ).
[Code]...
View 12 Replies
Feb 7, 2010
I have a user control that inherits the FW ListView and I need to dispose of two objects when the form's disposing of it's objects. Here's what I've concluded already, am I on the right track?
[Code]...
View 3 Replies
Oct 2, 2011
I'm starting to make a program that will run some commands, so i need some code that will open command prompt and run the command "netstat -a".
View 11 Replies
May 15, 2012
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.
[Code]...
View 1 Replies
Mar 29, 2009
[URL] The jist of the problem is in fact that in the weka.classifiers.trees namespace you have the following members:
namespace weka.classifiers.trees.j48
and
public class J48 : weka.classifiers.Classifier (Member of weka.classifiers.trees)
Lamentably VB .NET in VS 2008 does not seem to be smart enough to distinguish betweem the two (which is odd, because there is no such problem in VS 2003, or in C# in VS 2008) because of it's lack of case sensitivity. Or possibly because of the fact that ikvmc emits an assembly compiled for the 1.1 run time... I'm not sure. I'm also not quite sure how you would resolve this particular issue and given the time sensitivity of this project I do not have the time to learn C# or Java to an extensive degree.
View 1 Replies
Aug 17, 2009
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"
View 4 Replies
Jan 27, 2010
I am working on a project which requires me to connect to a MySQL database. From there I query the database and need to do work on the returned values.
I can query the database just fine. However, now I need to do work on the results. The two columns returned are user_name and user_password. The rows are the user accounts. I would like to take my query results and put each column into its own arrary().
[code..]
Instead of writing the results to the console, I would like to write each column to an individual array. Is there an easier way to accomplish this task? Or, what is the code I must place within the loop to do this.
View 3 Replies
Mar 25, 2009
I have been automating MS Project with VB.Net. I can open .mpp files and access all the objects I need. Now the customer has asked to open these files from Project Server. I cannot get MS Project to Open with the server connection.
View 3 Replies
Oct 15, 2010
I am doing the basic reading form one table,.it is opening the connection,no problems.i got 5 rows in Categories table with two columns .i got some data as well.using datareader i am trying to read the data.It is not going into while loop
[Code]...
View 5 Replies