PDA

Click to See Complete Forum and Search --> : Bit 'o' bother with SQL


Skeen
Sep 7th, 2000, 07:39 AM
Hi y'all - let me hear all da peeps in da house say Ho!

I'm attempting ton use asp's as a front end for my database, and I'm having dificulty inserting into a table. Can anyone tell me whats wrong with my code?

Cheers 'n' Beers

Skeen

<%

Dim cbSQL
Dim cnAcqAcc
Dim rsCName


Set cnAcqAcc = CreateObject ( "ADODB.Connection" )
cnAcqAcc.ConnectionString = "Provider=MSDASQL;DSN=AqAc;UID=AcqAcc_owner;PWD=AcqAcc_owner;"
cnAcqAcc.open


Custom_Name = Request.Form("T2")

cbSQL = "Insert Into Address_Details (Client_Nmae) values ('Custom_Name')"
Set rsCName = cnAcqAcc.Execute( cbSQL )

cnAcqAcc.Close
Set rsCatagory = Nothing

%>

dcarlson
Sep 7th, 2000, 07:57 AM
There's a problem with sql statement.


cbSQL = "Insert Into Address_Details (Client_Nmae) values ('Custom_Name')"


Should be:

cbSQL = "Insert Into Address_Details (Client_Name) "
cbSQL = cbSQL & "values ('" & Custom_Name & "')"

monte96
Sep 7th, 2000, 04:44 PM
While your at it:


Set rsCatagory = Nothing


should be:

Set rsCName = Nothing


And you are assigning a recordset to the .execute method of the connection object. This works great if you are calling a stored proc that does a select, but in this case, no recordset is returned so you will get an error.

If you want to read the recordset in to rsCName, you have to do it as a separate select statement.


/\/\onte96

Skeen
Sep 8th, 2000, 08:42 AM
Thanx,

worked just fine. NICE1