Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

dsnless odbc access db 1

Status
Not open for further replies.

scottRen

Technical User
Feb 4, 2005
69
0
0
CA
can't seem to get this connection stinr working....any ideas?
Code:
MyConnection.Open "Driver={Microsoft Access Driver (*.mdb)};" & _ 
           "Dbq=c:\path\dbName.mdb;"

.Write "<Select name=Myselectbox><option value="""">Please Select</option>"
	Set Myrs = MyConnection.Execute("SELECT name FROM TblName")
 	 		Do Until Myrs.eof
.Write "<option value"""&Myrs("name")&""">"&Myrs("name")&"</option>"
 	 	Myrs.movenext
			loop
.Write "</select>"
		Set Myrs = nothing
		MyConnection.close
		Set MyConnection = Nothing
 
how about
Code:
strDBPath = Server.MapPath("dbName.mdb")

Set conn = Server.CreateObject("ADODB.Connection")

conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & strDBPath & ";"

Set rs = conn.Execute("SELECT name FROM TblName")

response.Write "<Select name=Myselectbox><option value="""">Please Select</option>"

Do Until Myrs.eof
response.Write "<option value="""& rs("name")&""">"& rs("name")&"</option>"

rs.movenext
loop
response.Write "</select>"

rs.close
Set rs = nothing
conn.close
Set conn = Nothing
 
if server.mappath doesn't work well for you try

Code:
Set conn = Server.CreateObject("ADODB.Connection")

conn.Open [red]"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\path\dbName.mdb;"[/red]

Set rs = conn.Execute("SELECT name FROM TblName")

response.Write "<Select name=Myselectbox><option value="""">Please Select</option>"

Do Until Myrs.eof
response.Write "<option value="""& rs("name")&""">"& rs("name")&"</option>"

rs.movenext
loop
response.Write "</select>"

rs.close
Set rs = nothing
conn.close
Set conn = Nothing
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top