DSN is a data structure containing the information of a specific database that ODBC(Open Database Connectivity) driver needs when it connects to the database. There are several kinds of DSN, including user DSNs, system DSNs and file DSNs. The former 2 kinds are particular to a specific computer, and they also store DSN information in the registry. However, the third type DSNs contain related information within a text file wth a .DSN file extension, which can be shared by users of multiple computers who have installed the same drivers.
In below, we have listed the steps of creating ODBC DSN in WebSitePanel. Besides, we also have shown how to query a SQL Server with DSN/ODBC name source.
Create ODBC DSN in WebSitePanel
1.Log into your WebSitePanel and scroll down to Databases section. Then, click ODBC DSNs icon.
2.In the new page, click Create ODBC DSN button.
3.In the new page, enter a data source name and choose a ODBC Drive between SQL Server and MySQL. Then, click Save button.
4.In the ODBS DSN Properties part, select a database name and a database user. Then, click Save button.
5.Then, you will see you have created a ODBS DSN successfully.
To query a SQL Server with DSN/ODBC name source, you just need to use the following sample code.
<%
Dim cnnSimple ‘ ADO connection
Dim rstSimple ‘ ADO recordset
Set cnnSimple = Server.CreateObject(“ADODB.Connection”)
‘ DSNLess
cnnSimple.Open (“DSN=[DSN Source Name]; User Id=[DB Login];Password=[DB password];”)
Set rstSimple = cnnSimple.Execute(“select * from sysfiles”)
%>
<P> Connecting to Access with Ole connection </P>
<table border=”1″>
<%
Do While Not rstSimple.EOF
%>
<tr>
<td><%= rstSimple.Fields(0).Value %></td>
<td><%= rstSimple.Fields(1).Value %></td>
</tr>
<%
rstSimple.MoveNext
Loop
%>
</table>
<%
rstSimple.Close
Set rstSimple = Nothing
cnnSimple.Close
Set cnnSimple = Nothing
%>