Webmaster Forum

Go Back   Webmaster Forum > Scripting/Programming & Debugging > ASP & VBScript Forum
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

ASP & VBScript Forum Need help from a webmaster with ASP or VBScript, you may ask in this forum?

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 10-11-2007, 12:52 PM
rede96 rede96 is offline
Junior Member
 
Join Date: Oct 2007
Posts: 2
rede96 is an unknown quantity at this point
Submit to Clesto Submit to Digg Submit to Reddit Submit to Furl Submit to Del.icio.us Submit to Jeqq Submit to Spurl
Default Database connection

Hi,

I am fairly new to VBscript, although I have done some VBA.

I need to connect to a database using VBScript and then read/write some data to the tables in the .mdb

I have found the following code to connect to the mdb, which works well.
Code:
Dim objConn ' Our Connection Object Dim objRS ' Our Recordset Object Dim strSQL ' Our SQL string to access the database Dim strConnection ' Our Connection Object string to access the database Set objConn = CreateObject("ADODB.Connection") Set objRS = CreateObject("ADODB.Recordset") objConn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\AdamDB\AdamDB.mdb" strSQL = "SELECT * FROM tblData" Set objRS = objConn.Execute (strSQL)
The problem is when I try and add new records to the recordset using objRS.Addnew I get an error message. ("Current recordset does not support updating.")

Can anyone help me with the correct connection method please?
Reply With Quote

This ad is part of our Revenue Sharing program
  #2 (permalink)  
Old 10-11-2007, 06:28 PM
ALL's Avatar
ALL ALL is offline
Senior Member
 
Join Date: Oct 2006
Location: Sturgis, SD
Posts: 145
ALL is on a distinguished road
Submit to Clesto Submit to Digg Submit to Reddit Submit to Furl Submit to Del.icio.us Submit to Jeqq Submit to Spurl
Default

That is becuase you should be using SQL statments to add,modify, or retrieve data from the database.

SQL has some pretty simple syntax, if you want to read more check out this

for example to add a record it would be soming like:
"INSERT INTO the_table_you_want_to_insert_into (COL1,COL2,COL3) VALUES ('COL1_value','COL2_value','COL3_value')"
to remove a record it would be something like this:
"DELETE FROM the_table_you_want_to_delete_from WHERE COL1 = '1'" (this would delete any record where COL1 equals 1)
To update data it would be like this:
"UPDATE the_table_you_want_to_update SET COL1='2' WHERE COL1='1'"
To get data from the database you do this:
"SELECT * FROM the_table_you_want_to_select_from WHERE COL1 = '2'" (but then you gotta do some stuff in VB to actually get the data)
Reply With Quote
  #3 (permalink)  
Old 10-12-2007, 10:28 AM
rede96 rede96 is offline
Junior Member
 
Join Date: Oct 2007
Posts: 2
rede96 is an unknown quantity at this point
Submit to Clesto Submit to Digg Submit to Reddit Submit to Furl Submit to Del.icio.us Submit to Jeqq Submit to Spurl
Default

Thanks ALL

By the way, as I was looking around the SQL and searching for some other stuff I found a different way to connect;
Code:
objRS.Open strSQL, objConn, adOpenStatic, adLockOptimistic
When I connect this way I can use the.AddNew method.

Typical, when I was actually looking for it I couldn't find it, look for something else and there it is!

Anyway, thanks again.
Reply With Quote
Reply


Thread Tools
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

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
53.000.000 keywords database Kevaro SEO (Search Engine Optimization) 1 09-19-2007 12:05 PM


All times are GMT. The time now is 06:19 AM.


Creative Commons License
Powered by vBulletin Version 3.6.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.0.0

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30