If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ASP > SQL insert help using ASP

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 11-23-05, 11:14
baby_boomerang baby_boomerang is offline
Registered User
 
Join Date: Nov 2005
Posts: 13
SQL insert help using ASP

I have an Oracle Database called testing.

The database consists of two fields, firstname and surname.

All I am trying to do is simply insert data into the fields using a form in ASP.

The code I have is listed below - however it does nothing. It's driving me mad, any help is greatly appreciated. I think the problem is with the sql= insert ... part.

-----------------------------------------------------------------
<html>
<body>

<form action="insert.asp" method="post">
Firstname <input type="text" name="Firstname" size="20">
Surname <input type="text" name="Surname" size="20">
<input type="submit" value="Submit">
</form>

<%

dim testing
Dim objConnection
Dim objRecordset

firstname=Request.Form("firstname")
surname=Request.Form("surname")


If testing<>"" Then

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

With objConnection
.ConnectionString = "Provider=MSDAORA.1;Password=21323;User ID=21321;Data Source=stora;Persist Security Info=True"
.Open

sql="insert into testing (FIRSTNAME, SURNAME) " & _ values ("firstname ","surname")

Response.Write "<BR> sql.=" & sql & "<BR> <BR>"

Set objRecordset = .Execute(sql)


End With

End If

Set objConnection = Nothing
Set objRecordset = Nothing

%>
</body>
</html>
Reply With Quote
  #2 (permalink)  
Old 11-23-05, 13:04
fredservillon fredservillon is offline
Registered User
 
Join Date: Oct 2005
Posts: 178
The variable "testing" is blank when your script runs. YOur if statement sees this and end it without going through the data retieval

YOu just defined your variable "testing" and initially it is null
Then in your following statements you used it in your IF statement.. that if it's not "" , do the following routine, Since it is "" the following routines are bypassed. That's why nothing was happening when executed.

Last edited by fredservillon; 11-23-05 at 20:13.
Reply With Quote
  #3 (permalink)  
Old 11-23-05, 19:17
rokslide rokslide is offline
Registered User
 
Join Date: Nov 2003
Location: Christchurch, New Zealand
Posts: 1,617
Code:
firstname=Request.Form("firstname")
surname=Request.Form("surname")
Requests are case sensitive... you need this
Code:
firstname=Request.Form("Firstname")
surname=Request.Form("Surname")
you also wil have a problem with this line...
Code:
sql="insert into testing (FIRSTNAME, SURNAME) " & _ values ("firstname ","surname")
you need something like...
Code:
sql="insert into testing (FIRSTNAME, SURNAME) " & _ 
    "values ('" & firstname & "','" & surname & "')"
You will need to do something the take care of the ' character that is in some peoples names....
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On