|
 |
aspx thread: Connection Property has not been initialized ?#$%
Message #1 by "Jose Haymaker" <ehaymaker@a...> on Fri, 12 Oct 2001 20:55:17
|
|
My Connection is declared and opened. What is this Error Msg about?
<%@ Page Language="vb" Debug="true" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.SqlClient" %>
<%
dim x as integer
dim item as string
Dim myConnection As SQLConnection
Dim myCommand As SQLCommand
myConnection = New SQLConnection
( "Server=srvr;uid=sa;pwd=;Database=db" )
myConnection.Open()
x=1
For each item in request.form
if request.form("myRepeater:ctrl" & trim(str(x)) & ":approved") = "on" then
dim extra as string = request.form("myRepeater:ctrl" & trim(str(x))
& ":prodid")
dim eggstra as string = request.form("myRepeater:ctrl" & trim(str(x))
& ":proddesc")
myCommand = NEW SQLCommand("INSERT INTO SQLADD (name,lastname) values
('extra','eggstra')")
'response.write (request.form("myRepeater:ctrl" & trim(str(x))
& ":prodid"))
'response.write (request.form("myRepeater:ctrl" & trim(str(x))
& ":proddesc"))
myCommand.ExecuteNonQuery()
end if
x = x+1
next
myCommand.ExecuteNonQuery()
MyConnection.Close()
%>
Message #2 by "Chris Scott" <chris@e...> on Mon, 15 Oct 2001 08:45:46 -0700
|
|
You need to set the connection property of the command object, this can be
done when creating the command object:
myCommand = NEW SQLCommand(myCommandText, myConnection)
or via the property direct after creating the command object:
myCommand = NEW SQLCommand(myCommandText)
myCommand.Connection=myConnection
----- Original Message -----
From: "Jose Haymaker" <ehaymaker@a...>
To: "ASP+" <aspx@p...>
Sent: Friday, October 12, 2001 8:55 PM
Subject: [aspx] Connection Property has not been initialized ?#$%
> My Connection is declared and opened. What is this Error Msg about?
>
> <%@ Page Language="vb" Debug="true" %>
> <%@ Import Namespace="System.Data" %>
> <%@ Import Namespace="System.Data.SqlClient" %>
>
>
>
> <%
> dim x as integer
> dim item as string
> Dim myConnection As SQLConnection
> Dim myCommand As SQLCommand
> myConnection = New SQLConnection
> ( "Server=srvr;uid=sa;pwd=;Database=db" )
>
> myConnection.Open()
>
> x=1
> For each item in request.form
>
> if request.form("myRepeater:ctrl" & trim(str(x)) & ":approved") = "on"
then
>
> dim extra as string = request.form("myRepeater:ctrl" & trim(str(x))
> & ":prodid")
> dim eggstra as string = request.form("myRepeater:ctrl" & trim(str(x))
> & ":proddesc")
>
> myCommand = NEW SQLCommand("INSERT INTO SQLADD (name,lastname) values
> ('extra','eggstra')")
> 'response.write (request.form("myRepeater:ctrl" & trim(str(x))
> & ":prodid"))
> 'response.write (request.form("myRepeater:ctrl" & trim(str(x))
> & ":proddesc"))
> myCommand.ExecuteNonQuery()
>
> end if
> x = x+1
>
> next
>
> myCommand.ExecuteNonQuery()
> MyConnection.Close()
>
> %>
|
|
 |