homepage Welcome to WebmasterWorld Guest from 54.237.213.31
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Microsoft / Microsoft IIS Web Server and ASP.NET
Forum Library, Charter, Moderators: ocean10000

Microsoft IIS Web Server and ASP.NET Forum

    
Help with autofilling an Access Db Column
BlackRaven

10+ Year Member



 
Msg#: 2456 posted 1:01 am on Feb 5, 2005 (gmt 0)

Yeah hi again, ok wondering if anyone could me out. I am trying to autofill a newly created column ("School") in my Acess DB with a defualt value ("SBC"), however i am having problems. The thing is i am guessing you would have to use a loop of some kind with a .eof restiction, but of which i dont know how to do. Here is what i got so far

<%
Response.CacheControl = "no-cache"
Response.AddHeader "Pragma", "no-cache"
Response.Expires = -1

Response.Buffer = true
dim cnn
dim rst
dim lngRecordNo
set cnn = Server.CreateObject("ADODB.Connection")
set rst = Server.CreateObject("ADODB.RecordSet")
cnn.Open "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=*****books.mdb;"

sqltext = "SELECT * FROM books"
rst.CursorType = 2
rst.LockType = 3
rst.Open sqltext,cnn

If cnn.BOF OR cnn.EOF Then

 

mattglet

WebmasterWorld Senior Member 10+ Year Member



 
Msg#: 2456 posted 5:43 am on Feb 5, 2005 (gmt 0)

<%
Response.CacheControl = "no-cache"
Response.AddHeader "Pragma", "no-cache"
Response.Expires = -1

Response.Buffer = true
dim cnn
dim rst
dim lngRecordNo
set cnn = Server.CreateObject("ADODB.Connection")
set rst = Server.CreateObject("ADODB.RecordSet")
cnn.Open "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=*****books.mdb;"

sqltext = "SELECT * FROM books"
rst.CursorType = 2
rst.LockType = 3
rst.Open sqltext,cnn

do while not rst.eof
rst("your_column") = "SBC"
rst.update()
loop

rst.close()
set rst = nothing

cnn.close()
set cnn = nothing

Zaphod Beeblebrox

10+ Year Member



 
Msg#: 2456 posted 12:17 pm on Feb 5, 2005 (gmt 0)

I'd prefer:

dim cnn
set cnn = Server.CreateObject("ADODB.Connection")
cnn.Open "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=*****books.mdb;"
cnn.Execute "UPDATE Books SET School='SBC'"
cnn.Close
Set cnn = Nothing

mattglet

WebmasterWorld Senior Member 10+ Year Member



 
Msg#: 2456 posted 3:01 pm on Feb 5, 2005 (gmt 0)

For the record, I agree with ZB's version. The only reason I made mine different was because you were looking for the loop method, using cursors (I'm assuming you're new to the game).

Do some research on using the UPDATE command, and using the Execute method of the Connection object with your queries.

BlackRaven

10+ Year Member



 
Msg#: 2456 posted 5:04 pm on Feb 5, 2005 (gmt 0)

Works Perfect for some reason was getting "Not enogh disk space error" but the new script works fine. THanks again.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Microsoft / Microsoft IIS Web Server and ASP.NET
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved