|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| ||||||||||||||||||||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Sending Information to a database
Hi All,
I have created a Microsoft Access Database on my PC and also have an online form on my site. I want this information to be sent directly to my database when a person hits the submit button on my page. I have nothing launched yet on the network but it's just temporarily on my pc. How would I set this up. I have all the fields in the database set up in 1 table and matching the fields in the form. Would anyone have code for this. I would be very grateful if someone could help me out. Cheers |
|
#2
|
||||
|
||||
|
Hi,
To really understand this, you'll need to find some tutorials and a good ASP/Database book. But here's a start. 1) First you need to setup the form properly: <form name="form1" method="post" action="submitform.asp"> <input type="text" name="text1"> <input type="text" name="text2"> <input type="submit" name="go" value="Submit"> </form> 2) Then you submitform.asp page needs to grab the values. <% strText1 = Trim(Request.Form("text1")) strText2 = Trim(Request.Form("text2")) '---Remove single quotes - breaks queries strText1 = Replace(strText1, "'", "''") strText2 = Replace(strText2, "'", "''") '---Database code to insert into database Set objConn = Server.CreateObject("ADODB.Connection") Set objRec = Server.CreateObject("ADODB.Recordset") objConn.Open "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=c:\databasepath\Database1.mdb" strSQL = "INSERT INTO TABLE1 (field1, field2) VALUES ('"&strText1&"', '"&strText2&"') Set objCmd = Server.CreateObject("ADODB.Command") With objCmd .ActiveConnection = objConn .CommandType = 1 .CommandText = strSQL .Execute End With %> Let me know what doesn't make sense. Danny |
![]() |
| Viewing: ASP Free Forums > Database > SQL Development > Sending Information to a database |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|