Login | |
|
 |
Vbscript to microsoft access connection - 8/5/2008 5:18:18 AM
|
|
 |
|
| |
serioussam13x
Posts: 4
Score: 0
Joined: 8/5/2008
Status: offline
|
Hello, I have been searching and performing trial and error for the last three hours. I am trying to use a simple Vbscript form to connect to a access database for the purpose of adding, updating, and deleting records. Unfortunately I have been unsuccesful. I have taken bits and pieces from examples found on the internet to create a working guideline that I can work off of. Here is what I have. <html> <Script Language="VBScript"> Sub DBAdd dim a dim b dim c dim d dim e dim f a = document.DBAddForm.account.value b = document.DBAddForm.url.value c = document.DBAddForm.category.value d = document.DBAddForm.leadsource.value e = document.DBAddForm.notes.value f = document.write(Date) Dim objConnection Dim objRecordSet Set objConnection = CreateObject("ADODB.Connection") Set objRecordSet = CreateObject("ADODB.Recordset") objConnection.Open _ "Provider = Microsoft.Jet.OLEDB.4.0; " & _ "Data Source = H:\queue13x.mdb" dim ar as ADODB.recordset set ar=new adodb.recordset ar.open {select * from queue13xtbl} ar.execute "INSERT INTO queue13xtbl(account,url,category,leadsource,notes) VALUES ('"& a &"','"& b &"','"& c &"','"& d &"','"& e &"','"& f &"')" End Sub </script> </head> <body> <h3>Me</h3> <FORM NAME="DBAddForm" OnSubmit="DBAdd()"> <table cellspacing=0 cellpadding=5 border=0> <tr><td>Enter Account Number:</td><td><INPUT TYPE="TEXT" NAME="account"></td></tr> <tr><td>Enter URL:</td><td><INPUT TYPE="TEXT" NAME="url"></td></tr> <tr><td>Enter Category:</td><td><INPUT TYPE="TEXT" NAME="category"></td></tr> <tr><td>Enter Lead Source:</td><td><INPUT TYPE="TEXT" NAME="leadsource"></td></tr> <tr><td>Enter Notes:</td><td><textarea name ="notes" rows=8 cols=30></textarea></td></tr> <tr><td><br></td><td><input TYPE="Submit" VALUE="Submit"></td></tr> </table> </FORM> </html>
|
|
| |
|
|
|
 |
RE: Vbscript to microsoft access connection - 8/5/2008 7:09:38 AM
|
|
 |
|
| |
ehvbs
Posts: 2201
Score: 50
Joined: 6/22/2005
From: Germany
Status: offline
|
Hi serioussam13x, the most blatant errors: objConnection.Open _ "Provider=Microsoft.Jet.OLEDB.4.0; " & _ "Data Source=H:\queue13x.mdb" (no spaces) set ar=new adodb.recordset (that's VBA, not VBScript; you'll have to use CreateObject) ar.open {select * from queue13xtbl} (VBScript string literals are delimited by ") ar.execute "INSERT INTO queue13xtbl(account,url,category,leadsource,notes) VALUES ('"& a &"','"& b &"','"& c &"','"& d &"','"& e &"','"& f &"')" (.Execute is a method of ADODB.Connection, not ADODB.Recordset) In your shoes, I'd start with a simple command line script (cscript) to read and display a recordset; then move on to updates, insertions, and deletions. Good luck! ehvbs
|
|
| |
|
|
|
|
|