I am also doing this just above my sub() but before the class declaration:
Friend WithEvents sqlCmd_spf_Update As System.Data.SqlClient.SqlCommand
Friend WithEvents cnAs System.Data.SqlClient.SqlConnection
Friend WithEvents cn2 As System.Data.SqlClient.SqlConnection
Friend WithEvents cn3 As System.Data.SqlClient.SqlConnection
Friend WithEvents SqlCmd_BlacklistUpdateStatus As
System.Data.SqlClient.SqlCommand
Friend WithEvents SqlCmd_SpamUpdate_spfBlackUnprocessed As
System.Data.SqlClient.SqlCommand
Friend WithEvents SqlCmd_spamBlacklist_Insert As
System.Data.SqlClient.SqlCommand
Will the above effect anything?
Here's where this all started: I originally had everything in one form. It
worked fine. I needed to free up the form so I created a class file and put
all the database object code in the class file. I just cut and pasted the
code created from dragging and dropping into the form. I wasn't sure how
else to get database objects into the class file since these aren't
available on the toolbar. From the form, I push a button, which starts a
new thread for the class file.
Thanks,
Brett
"W.G. Ryan eMVP" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> If you just use Command.ExecuteReader() will that work? It looks like cn2
> is already associated with SqlCmd_BlacklistUpdateStatus - but is there a
> connection associated with SqlCmd_SpamUpdate_spfBlackUnprocessed.
>
> Just to be sure, use a new SqlConnection (just for testing) using the same
> connection string as cn2- but use this connection for the command you're
> calling ExecuteReader against. See if this doesn't fix it.
>
> Also, is it blowing up on the Read() line or is it the ExecuteReader line?
>
> --
> W.G. Ryan, MVP
>
> www.tibasolutions.com | www.devbuzz.com | www.knowdotnet.com
> "Brett" <(E-Mail Removed)> wrote in message
> news:%(E-Mail Removed)...
>> I'm using this code in VS .NET 2003
>>
>>
Code:
>>
>> Me.SqlCmd_BlacklistUpdateStatus.CommandText =
>> "dbo.[SpamUpdateReport_blacklist]"
>> Me.SqlCmd_BlacklistUpdateStatus.CommandType =
>> System.Data.CommandType.StoredProcedure
>> Me.SqlCmd_BlacklistUpdateStatus.Connection = Me.cn2
>> Me.SqlCmd_BlacklistUpdateStatus.Parameters.Add(New
>> System.Data.SqlClient.SqlParameter("@RETURN_VALUE",
>> System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.ReturnValue,
>> False, CType(0, Byte), CType(0, Byte), "",
>> System.Data.DataRowVersion.Current, Nothing))
>> Me.SqlCmd_BlacklistUpdateStatus.Parameters.Add(New
>> System.Data.SqlClient.SqlParameter("@messageid",
Code:
> System.Data.SqlDbType.Int,
>> 4))
>> Me.SqlCmd_BlacklistUpdateStatus.Parameters.Add(New
>> System.Data.SqlClient.SqlParameter("@subpart",
>> System.Data.SqlDbType.SmallInt, 2))
>> '
>>
>>
>> cn2.Open()
>>
>> 'loop through returned records
>> Dim drspfblacklist As SqlDataReader
>> drspfblacklist = SqlCmd_SpamUpdate_spfBlackUnprocessed.ExecuteReader()
>> While drspfblacklist.Read
>>
>>
>> At the while statement, I get a data ready already open for this
> connection
>> error. If I remove the line cn2.open(), I get an error about the
> connection
>> being closed. This should say that no other resource is using the
>> connection. What else could be wrong?
>>
>> Thanks,
>> Brett
>>
>>
>
>