Help With data access without a DNS

Results 1 to 2 of 2

Thread: Help With data access without a DNS

  1. #1
    Join Date
    Dec 1969

    Default Help With data access without a DNS

    Hello folks!<BR>I&#039m a asp beginner... I create a asp search page but i need to change it to other server, but I want to create a connection without DNs.<BR><BR>Thanks..<BR><BR>Frederick

  2. #2
    JCharbneau Guest

    Default RE: Help With data access without a DNS

    Hi,<BR> If you are trying to connect to an Access database you can use this code:<BR>&#039 Connection object<BR>set cnMain = Server.CreateObject("ADODB.Connection")<BR>&#039 Open the connection, passing the driver info and the db<BR>&#039 location, if using access you use server.mappath to find<BR>&#039 the connectionstring info<BR>cnMain.Open "DRIVER={Microsoft Access Driver (*.mdb)};DBQ=" & server.mappath("yourDB.mdb")<BR><BR>&#039 This is another way to connect, notice the provider property<BR>&#039 You can pass it many different types of databases.<BR>&#039 If you need a list let me know.<BR>&#039with cnMain<BR>&#039 .Provider = "Microsoft.Jet.OLEDB.3.51"<BR>&#039 .ConnectionString = server.MapPath("yourDB.mdb")<BR>&#039 .Open<BR>&#039end with<BR><BR>vsql="SELECT * FROM yourTable" <BR>&#039 Not neccessary but useful when using InterDev (Intellisense rocks)<BR>set rsMain = server.CreateObject("ADODB.Recordset")<BR> <BR>Set rsMain = cnMain.execute(vsql)<BR> <BR>rsMain.movefirst<BR>&#039 Your Recordset is ready for use.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts