|
-
Sep 21st, 2005, 02:05 AM
#1
Thread Starter
Addicted Member
Try This...
'create a dataadapater and connectionobject
Public Function x()
dim x1 as oledbcommand
'statements to execute the command object here
'don't dispose or close
end function
public function y()
dim x1 as oledbcommand
'statements to execute the command object here
'don't dispose or close
end function
'execute both function simulteniously what will happen?
-
Sep 21st, 2005, 02:11 AM
#2
Re: Try This...
Object reference not set to an instance of an object.
-
Sep 21st, 2005, 02:14 AM
#3
Re: Try This...
What are you asking? Whether there might be concurrency issues occur with the database?
-
Sep 21st, 2005, 02:19 AM
#4
Thread Starter
Addicted Member
Re: Try This...
Private Sub MainFormLoad(sender As System.Object, e As System.EventArgs)
mycon.ConnectionString = "Provider=Microsoft.jet.oledb.4.0;Data source=dbchat.mdb;persist security info=false"
mycon.Open()
End Sub
Private Function x()
Dim x1 As New System.Data.OleDb.OleDbCommand("select * from Members",mycon)
x1.ExecuteNonQuery()
End Function
Private Function y()
Dim x1 As New System.Data.OleDb.OleDbCommand("select * from Members",mycon)
x1.ExecuteNonQuery()
End Function
Private Sub Button1Click(sender As System.Object, e As System.EventArgs)
Call x
Call y
End Sub
Try in vs.net
-
Sep 21st, 2005, 02:19 AM
#5
Re: Try This...
If you open a connection that is already open then there will be a problem.
Rule: Close the connection after using and just open it when it is needed.
-
Sep 21st, 2005, 02:21 AM
#6
Thread Starter
Addicted Member
Re: Try This...
its not the connection the oledbcommand name. use it twice and don't dispose in one function just keep on using it.
-
Sep 21st, 2005, 02:23 AM
#7
Re: Try This...
 Originally Posted by iehjsucker
Private Sub MainFormLoad(sender As System.Object, e As System.EventArgs)
mycon.ConnectionString = "Provider=Microsoft.jet.oledb.4.0;Data source=dbchat.mdb;persist security info=false"
mycon.Open()
End Sub
Private Function x()
Dim x1 As New System.Data.OleDb.OleDbCommand("select * from Members",mycon)
x1.ExecuteNonQuery()
End Function
Private Function y()
Dim x1 As New System.Data.OleDb.OleDbCommand("select * from Members",mycon)
x1.ExecuteNonQuery()
End Function
Private Sub Button1Click(sender As System.Object, e As System.EventArgs)
Call x
Call y
End Sub
Try in vs.net
There is no problem about the code, it is just the connection is simultaenously open which not a good practice.
-
Sep 21st, 2005, 02:29 AM
#8
Thread Starter
Addicted Member
-
Sep 21st, 2005, 02:38 AM
#9
Re: Try This...
Yep, Since your using a variable that declared inside a sub then it is exclusive only in that sub and outside of that sub the variable is not recognized.
I tried it and no problem occur.
-
Sep 21st, 2005, 03:21 AM
#10
Re: Try This...
You still haven't told us exactly what it is you want to know. If you're going to make us guess then why should we care?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|