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


Please log in to comment

Rating comments in this legacy AppDeploy message board thread won't reorder them,
so that the conversation will remain readable.


Go to computerperformance.co.uk. There's a ton of scripts there dealing with ADO.
Answered 12/09/2010 by: VBScab
Red Belt

Please log in to comment
[/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">
Answered 12/09/2010 by: JohnCena83
Senior Yellow Belt

Please log in to comment
Answer this question or Comment on this question for clarity