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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Connecting ASP to SQL Server 1

Status
Not open for further replies.

tiramisu01

Programmer
Feb 11, 2000
19
SG
<br>
I know I'm getting way ahead of things and my SQL server has not even been set up yet. But I was just wondering ... is the setting for connection to the database the same as setting it up for access? If not, do you think you can provide me with the code? Thanx. <p>Jasper<br><a href=mailto:tiramisu01@hotmail.com>tiramisu01@hotmail.com</a><br><a href= > </a><br>
 
It's essentially the same, except, of course, that you'll be referencing a different driver. You'll also need to supply log in information, which you may not be doing with Access.<br>
<br>
<p>nick bulka<br><a href=mailto:nick@bulka.com>nick@bulka.com</a><br><a href= > </a><br>
 
Oh good. The server is up. 8)<br>
So is the info supplied along with code or configure on the server end? If it's code, do you have a sample or something? Thanx again. 8) <p>Jasper<br><a href=mailto:tiramisu01@hotmail.com>tiramisu01@hotmail.com</a><br><a href= > </a><br>
 
Do you know ASP101?<br>
<br>
Try<br>
<A HREF=" TARGET="_new"><br>
This is a piece of code from<br>
<A HREF=" TARGET="_new"><br>
&lt;%<br>
Dim DataConn, cmdDC, rsDC<br>
Dim Item<br>
Dim iFieldCount, iLoopVar<br>
Dim strLTorGT, iCriteria, strSortBy, strOrder<br>
<br>
' Retrieve QueryString Variables and convert them to a usable form<br>
strLTorGT = Request.QueryString(&quot;LTorGT&quot;)<br>
Select Case strLTorGT<br>
Case &quot;LT&quot;<br>
strLTorGT = &quot;&lt;&quot;<br>
Case &quot;GT&quot;<br>
strLTorGT = &quot;&gt;&quot;<br>
Case Else<br>
strLTorGT = &quot;&lt;&gt;&quot;<br>
End Select<br>
<br>
iCriteria = Request.QueryString(&quot;criteria&quot;)<br>
If IsNumeric(iCriteria) Then<br>
iCriteria = CLng(iCriteria)<br>
Else<br>
iCriteria = 0<br>
End If<br>
<br>
strSortBy = Request.QueryString(&quot;sortby&quot;)<br>
If strSortBy = &quot;&quot; Then strSortBy = &quot;last_name&quot;<br>
<br>
strOrder = Request.QueryString(&quot;order&quot;)<br>
' Finally we've got all our info, now to the cool stuff<br>
<br>
<br>
' Create and establish data connection<br>
Set DataConn = Server.CreateObject(&quot;ADODB.Connection&quot;)<br>
DataConn.ConnectionTimeout = 15<br>
DataConn.CommandTimeout = 30<br>
<br>
'Access connection code<br>
'DataConn.Open &quot;DBQ=&quot; & Server.MapPath(&quot;database.mdb&quot;) & &quot;;Driver={Microsoft Access Driver (*.mdb)};DriverId=25;MaxBufferSize=8192;Threads=20;&quot;, &quot;username&quot;, &quot;password&quot;<br>
<br>
'Our SQL Server code - use above line to use sample on your server<br>
DataConn.Open Application(&quot;SQLConnString&quot;), Application(&quot;SQLUsername&quot;), Application(&quot;SQLPassword&quot;)<br>
<br>
<br>
<br>
Try this!!<br>
Good Luck<br>
<br>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top