How to write Access connection strings....

Results 1 to 2 of 2

Thread: How to write Access connection strings....

  1. #1
    Join Date
    Dec 1969
    Posts
    133

    Default How to write Access connection strings....

    Thanks for the earlier response about SQl vs. Access, sorry to duplicate this.....<BR><BR>I&#039m writing a searchable database of employees, for use online by our helpdesk. I&#039d like to keep it in Access to allow easy imports from Excel by non-db people.<BR>This is the code I want to use, if someone could suggest how to modify the connection statements to use Access I would be very happy.....So far it&#039s stumped me.... <BR><BR>&#060;%@ Language=VBScript %&#062;<BR>&#060;% Option Explicit %&#062;<BR>&#060;html&#062;<BR><BR>&#060;head&#062 ;<BR>&#060;title&#062;&#060;/title&#062;<BR>&#060;/head&#062;<BR><BR>&#060;body&#062;<BR><BR>&#060;%< BR>Dim SearchText, MyConn, RS, i<BR>SearchText = Request.Form("txtSearchText")<BR>Set MyConn=Server.CreateObject("ADODB.Connection")<BR> MyConn.Open "database"<BR>Set RS = MyConn.Execute("SELECT alpha.Name From alphalist, alpha WHERE aplha.LastName LIKE &#039%" & SearchText & "%&#039 AND alpha.ID = department.ID")<BR>%&#062;<BR><BR>&#060;table border="1"&#062;<BR>&#060;tr&#062;<BR>&#060;% If SearchText &#060;&#062; "" Then %&#062;<BR>&#060;td&#062;&#039as long as data is entered into the form &#060;% If RS.BOF AND RS.EOF Then %&#062; &#060;% Response.Write "Nothing Found!" %&#062; &#060;% Else %&#062; &#039if there is no data found tell the user,<BR>otherwise write the data into a table to be viewed &#060;% for i = 0 to RS.Fields.Count - 1 %&#062; &#060;/td&#062;<BR>&#060;th&#062;&#060;% =RS(i).Name %&#062;<BR>&#060;/th&#062;<BR>&#060;% Next %&#062;<BR>&#060;/tr&#062;<BR>&#060;% While Not RS.EOF %&#062;<BR>&#060;tr&#062;<BR>&#060;% For i = 0 to RS.Fields.Count - 1 %&#062;<BR>&#060;td&#062;&#060;% = RS(i) %&#062;<BR>&#060;/td&#062;<BR>&#060;% Next %&#062;<BR>&#060;/tr&#062;<BR>&#060;%<BR>RS.MoveNext<BR>WEND<BR>RS.C lose<BR>%&#062;<BR>&#060;% End If %&#062;<BR>&#060;% Else Response.Write "No Search String Entered" %&#062;<BR>&#060;% RS.Close %&#062;<BR>&#060;% End If %&#062;<BR>&#060;tr&#062;<BR>&#060;td&#062;&#039 if no data had been entered into the form then let the user know. close the<BR>connection. &#060;/td&#062;<BR>&#060;/tr&#062;<BR>&#060;/table&#062;<BR>&#060;/body&#062;<BR>&#060;/html&#062;<BR>

  2. #2
    Jason Buck Guest

    Default RE: How to write Access connection strings....

    Here is how I do my connection string:<BR><BR>&#039------------------------Connection to the Database--------------------------<BR>strConnect = "Driver={Microsoft Access Driver (*.mdb)}; DBQ=d:pathtodbexamples.mdb"<BR><BR>dim objconn, objrec, mysql<BR>set objconn = server.createobject("ADODB.Connection")<BR><BR><BR >objConn.open strConnect<BR>&#039-------------------------End Connection to the Database---------------------<BR><BR>&#039-------------------------SQL Statement to get information from a table-------------------<BR>mysql = "SELECT tblExamples.rsID, tblExamples.rsURL, tblExamples.rsLink FROM tblExamples ORDER BY rsID;"<BR><BR>set rstemp=objConn.execute(mysql)<BR><BR>&#039------------------------End SQL Statement and the running of the statement-----------<BR><BR><BR>Basically what you are missing from your code is the following line.<BR><BR>strConnect = "Driver={Microsoft Access Driver (*.mdb)}; DBQ=d:pathtodbexamples.mdb"<BR><BR>Respectfully,<B R><BR>Jason Buck<BR>webmaster@wnj.com<BR><BR>

Posting Permissions

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