Connection Question...!
Hello All,
Here's my situation... I have a process that is running, so there a connection to the database that's established from the start. At one point I'm wanting to grab data from a table while using the connection that's already open.
I'm running an update query then using adocmd.ExecuteNonQuery but before this I'm grabbing data from a table this is where I'm having the issue.
Any ideas?
Thanks in advance..
Jim
[504 byte] By [
jcb1269] at [2007-11-11 6:50:08]

# 1 Re: Connection Question...!
Could you be more specific as to the problem you are having? For example, are you generating some sort of error? If so, can you identify the line of code where the error occurs? Type of database you are working with?
# 2 Re: Connection Question...!
This is the error I'm getting:
Execute requires the command to have a transaction object when the connection assigned to the command is in a pending local transaction. The Transaction property of the command has not been initialized.
this is the code I'm running:
Dim adpVendorAbbrv As SqlDataAdapter = New SqlDataAdapter()
Dim cmdSuppliers As SqlCommand = _
New SqlCommand("SELECT abbr FROM Company WHERE vendor_id = '" & CompID & "'", adoCN)
cmdSuppliers.CommandType = CommandType.Text
adpVendorAbbrv.SelectCommand = cmdSuppliers
Dim ds = New DataSet("Company")
adpVendorAbbrv.Fill(ds)
sAbbrv = ds("Abbrv")
I'm trying to get the Abbrv field but I get the error above.
Thanks..
Jim
# 3 Re: Connection Question...!
Are you calling the BeginTransaction method of your Connection object elsewhere in your code? If so, you'll either need to assign the transaction object to the Transaction property of your SelectCommand, or open a new Connection for the SelectCommand to use.