Putting data into Database.

Wanted to ad data into a database via vbscript, and I have worked it out now. Thank you very much. :)

0 Comments   [ + ] Show comments

Answers (2)

Posted by: anonymous_9363 12 years ago
Red Belt
Go to computerperformance.co.uk. There's a ton of scripts there dealing with ADO.
Posted by: JohnCena83 12 years ago
Senior Yellow Belt
[/align]if request.form("submit") <>"" then
[/align] set conn=Server.CreateObject("ADODB.Connection")
[/align] conn.Provider="Microsoft.Jet.OLEDB.4.0"
[/align] conn.Open server.mapPath("northwind.mdb")
[/align] sql="INSERT INTO customers (customerID,companyname,"
[/align] sql=sql & "contactname,address,city,postalcode,country)"
[/align] sql=sql & " VALUES "
[/align] sql=sql & "('" & Request.Form("custid") & "',"
[/align] sql=sql & "'" & Request.Form("compname") & "',"
[/align] sql=sql & "'" & Request.Form("contname") & "',"
[/align] sql=sql & "'" & Request.Form("address") & "',"
[/align] sql=sql & "'" & Request.Form("city") & "',"
[/align] sql=sql & "'" & Request.Form("postcode") & "',"
[/align] sql=sql & "'" & Request.Form("country") & "')"
[/align] response.write "sql = " & sql
[/align] on error resume next
[/align] conn.Execute sql,recaffected
[/align] if err<>0 then
[/align] Response.Write(err.description)
[/align] else
[/align] Response.Write("<h3>" & recaffected & " record added</h3>")
[/align] end if
[/align] conn.close
[/align] response.write "no record added"
[/align]end if
[/align]<form method="post" action="">
[/align]<td><input name="custid" value="1111"></td>
[/align]<td>Company Name:</td>
[/align]<td><input name="compname" value="myName"></td>
[/align]<td>Contact Name:</td>
[/align]<td><input name="contname" value="myContactName"></td>
[/align]<td><input name="address" value="myAddress"></td>
[/align]<td><input name="city" value="myCity"></td>
[/align]<td>Postal Code:</td>
[/align]<td><input name="postcode" value="12345"></td>
[/align]<td><input name="country" value="myCountry"></td>
[/align]<br /><br />
[/align]<input name ="submit" type="submit" value="Add New">
[/align]<input type="reset" value="Cancel">
Rating comments in this legacy AppDeploy message board thread won't reorder them,
so that the conversation will remain readable.
This website uses cookies. By continuing to use this site and/or clicking the "Accept" button you are providing consent Quest Software and its affiliates do NOT sell the Personal Data you provide to us either when you register on our websites or when you do business with us. For more information about our Privacy Policy and our data protection efforts, please visit GDPR-HQ