Results 1 to 4 of 4

Thread: Bit 'o' bother with SQL

  1. #1

    Thread Starter
    Addicted Member Skeen's Avatar
    Join Date
    Jul 2000
    Location
    Abingdon, Oxon
    Posts
    138

    Wink

    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

    %>
    "It wasn't the booze that made me snooze, It was the Gin that did me in!"

  2. #2
    Hyperactive Member
    Join Date
    Apr 2000
    Location
    Sudbury, Ontario, Canada
    Posts
    274
    There's a problem with sql statement.

    cbSQL = "Insert Into Address_Details (Client_Nmae) values ('Custom_Name')"
    Should be:
    Code:
    cbSQL = "Insert Into Address_Details (Client_Name) "
    cbSQL = cbSQL & "values ('" & Custom_Name & "')"

  3. #3
    Frenzied Member monte96's Avatar
    Join Date
    Sep 2000
    Location
    Somewhere in AZ
    Posts
    1,379
    While your at it:

    Code:
    Set rsCatagory = Nothing
    should be:
    Code:
    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

  4. #4

    Thread Starter
    Addicted Member Skeen's Avatar
    Join Date
    Jul 2000
    Location
    Abingdon, Oxon
    Posts
    138

    Smile Cheers Guys

    Thanx,

    worked just fine. NICE1
    "It wasn't the booze that made me snooze, It was the Gin that did me in!"

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width