View Full Version : insert in DB using for loop
ahmedsoliman
08-08-2002, 09:24 AM
how to insert in db using for loop?
please send complete code
glenngv
08-08-2002, 10:06 AM
could you be more specific of what you are trying to accomplish?
ahmedsoliman
08-08-2002, 12:01 PM
instead of using (while rs.eof) i want to use for loop
i want coplete example starting from (adodb .connection) to last of the code.
whammy
08-09-2002, 11:46 PM
I'm not sure what you're trying to do, but here you go (Access 200 db):
Set Conn = Server.CreateObject("ADODB.Connection")
sConnString = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & _
Mid(Server.MapPath("\"), 1, InStrRev(Server.MapPath("\"),"\")-1) & _
"\database\databasename.mdb;" & _
"Persist Security Info=False;"
Conn.Open sConnString
For i = 1 to 12
InsertString = "INSERT INTO table_name (myvariable) VALUES ('" & i & "')"
Conn.Execute(InsertString)
Next
Conn.Close
Set Conn = Nothing
That would insert 1-12 into a field called "myvariable"...
ahmedsoliman
08-10-2002, 07:01 AM
thank you:)
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.