Re: .Net/SQL Drop Table Problem
- From: "Siva M" <shiva_sm@xxxxxxxxxxxxxxxxx>
- Date: Tue, 23 Aug 2005 20:35:45 +0530
Set the SqlCommand's Connection property before executing the query.
"The VanDerbeck Group" <TheVanDerbeckGroup@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote
in message news:350B75F1-9BDA-4E02-BAB6-901D98741769@xxxxxxxxxxxxxxxx
The code below generates the indicated error. As a newbie to vb and SQL I
have no idea how to track this down. I did verify that the connection state
is open. My suspicion is that I have to connect to a seperate "sysobjects"
database???
THE CODE:
Dim oSQLConnection As New SqlConnection("data source =" _
& "psi-sbs2k3 ;" _
& "initial catalog = 'JHH PRODUCT DATA' ;" _
& "Integrated Security=SSPI;" _
& "persist security info =True;")
oSQLConnection.Open()
Dim osqlCommand As New SqlCommand("if exists (select * from
dbo.sysobjects where id = object_id(N'[dbo].[dsdprod]') and
OBJECTPROPERTY(id, N'IsUserTable') = 1)" _
& " drop table [dbo].[dsdprod] ")
osqlCommand.ExecuteNonQuery()
ERROR GENERATED IS...
An unhandled exception of type 'System.InvalidOperationException' occurred
in system.data.dll
Additional information: ExecuteNonQuery: Connection property has not been
initialized.
.
- References:
- .Net/SQL Drop Table Problem
- From: The VanDerbeck Group
- .Net/SQL Drop Table Problem
- Prev by Date: Re: System.IO.FileNotFoundException
- Next by Date: Re: weird string problem
- Previous by thread: Re: .Net/SQL Drop Table Problem
- Next by thread: Help, I can't catch this exception
- Index(es):
Relevant Pages
|