...

View Full Version : insert in DB using for loop



ahmedsoliman
08-08-2002, 10:24 AM
how to insert in db using for loop?
please send complete code

glenngv
08-08-2002, 11:06 AM
could you be more specific of what you are trying to accomplish?

ahmedsoliman
08-08-2002, 01: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-10-2002, 12:46 AM
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, 08:01 AM
thank you:)



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum