Wrox Home  
Search P2P Archive for: Go

  Return to Index  

asp_databases thread: What is Set rstemp=objConn.execute(SQLstr)??????? Do we need to have an INSERT query before we have this line???


Message #1 by "Lan Chi Tran" <lanchi1975@y...> on Thu, 26 Jul 2001 21:14:39
Hi Peter,



I didn't see my previous question posted regarding to this issue.  So, if 

you got this duplicate.  Please do take a look at this because it might be 

clearer.



I changes all the =3D and =20 and it seems getting better.  However, 

another error came up.  





Please look at my CreateEntries.asp, especially at the 

<INPUT type=text name= whatever> as well as my ADODB.

Second, on the response_create_entries.asp, 

Set rstemp=objConn.execute(SQLstr) is the line that displays the error.  

My understanding is that we need to have the INSERT query before this line 

in order to make it works.  Don't really know for sure.  Please advise.

********************

Microsoft OLE DB Provider for ODBC Drivers error '80040e0c' 



Command text was not set for the command object. 

********************

createentries.asp

********************

<%

Dim objConn, myDSN, SQL, rstemp

myDSN="DSN=testdata;UID=sa"

set objConn=server.createobject("adodb.connection")

    objConn.open myDSN

SQL="Select * from STANDARDS"

set rstemp=objConn.execute(SQL)

%>

<table border=1 CELLPADDING='2' BGCOLOR='#D5D0DF'>

<H3>Please fill out this form.</H3><tr>

 <%

for each frmItem in rstemp.fields

	Response.write("	<TR><TD><b>")

	Response.write(frmItem.name)

	Response.write("</b></TD><TD><INPUT TYPE=TEXT name=whatever")

	Response.write(frmItem.name)

	Response.write("'></TD></TR>")

next

%>



***********************

response_create_entries.asp

*************************

<% 

dim objConn, names, values, SQLstr, rstemp

Set objConn = Server.CreateObject ("ADODB.Connection")

    objConn.Open "testdata"

Set rstemp=objConn.execute(SQLstr)

SQLFields = ""

SQLValues = ""

For each frmItem in Request.Form

	SQLFields = SQLFields & ", " & intNumItems

	SQLValues = SQLValues & ", '" & Request.Form(intNumItems) & "'"

Next

SQLFields = mid(SQLFields, 3)

SQLValues = mid(SQLValues, 3)

 	SQLstr = "INSERT INTO Standards (" & SQLFields & ") VALUES (" & 

values & ")"

objconn.execute(SQLstr)

rstemp.close

set rstemp=nothing

objconn.close

set objconn = nothing

%>

****************

Message #2 by "Ken Schaefer" <ken@a...> on Fri, 27 Jul 2001 10:23:55 +1000
This is a multi-part message in MIME format.



------=_NextPart_000_025A_01C11686.3DA0ED70

Content-Type: text/plain;

	charset="Windows-1252"

Content-Transfer-Encoding: quoted-printable



Reponses inline



***********************

response_create_entries.asp

*************************

<%

dim objConn, names, values, SQLstr, rstemp

Set objConn =3D Server.CreateObject ("ADODB.Connection")

    objConn.Open "testdata"

Set rstemp=3DobjConn.execute(SQLstr) <- You have no SQLstr yet

                                   <- and your don't need

                                   <- a recordset

                                   <- get rid of this line



SQLFields =3D "" <- You don't need this line either

SQLValues =3D "" <- You don't need this line either

Dim SQLFields

Dim SQLValues

For each frmItem in Request.Form

SQLFields =3D SQLFields & ", " & intNumItems

SQLValues =3D SQLValues & ", '" & Request.Form(intNumItems) & "'"

Next

SQLFields =3D mid(SQLFields, 3)

SQLValues =3D mid(SQLValues, 3)

  SQLstr =3D "INSERT INTO Standards (" & SQLFields & ") VALUES (" &

values & ")" <- You are using a variable called values

             <- but you allocated your values to a variable

             <- called SQLValues

                     

objconn.execute(SQLstr)

rstemp.close <- You don't need this

set rstemp=3Dnothing <- You don't need this

objconn.close

set objconn =3D nothing

%>



Sorry for the HTML Mail every one.





Cheers

Ken









  Return to Index