|
"My ASP script works on my server but it does not work on
your server."
MSSQL Connection
Sometimes, you may be wondering how to make your ASP
script connect to the MSSQL database that you have just got from us. You might
have received information like this from us:
==========================================================
MsSQL2000 LOGIN INFORMATION
==========================================================
Host IP : 202.157.142.190
Database name : mydatabase_db
User name : mydbaseuser
Password : mydbpass
(Please use "SQL Server Authentication".)
==========================================================
There are many ways to connect to the database. Here is
just one example. The below is a simple example of how you can connect
to your database, using the information we gave you above, do a simple
query, and display the results.
<HTML>
<BODY>
<%
Set MyConn = Server.CreateObject("ADODB.Connection")
MyConn.Open "Driver={SQL Server};" & _
"Server=202.157.142.190;" & _
"Database=mydatabase_db;" & _
"Uid=mydbaseuser;" & _
"Pwd=mydbpass;"
SQL_query = "SELECT uid, fname, lname FROM mytable"
Set RS = MyConn.Execute(SQL_query)
WHILE NOT RS.EOF
%>
<LI><%=RS("uid")%>: <%=RS("fname")%>: <%=RS("lname")%>
<%
RS.MoveNext
WEND
%>
</BODY>
</HTML>
|