Tuesday, September 21, 2010
how to connect database within asp?
how to connect database within asp?
Set Con = Server.CreateObject("ADODB.Con...
Con.ConnectionString = "Server=servernname; database=dbname; uid=username; pwd=passoword"
Con.Open
First You hold to create File dsn
<% set myconn=Server.CreateObject("AD...
myconn.Open "filedsn=c:\program files\common files\odbc\information sources\mydata.dsn"
set rs=myconn.Execute("select * from emp")
%>
<table border=1>
<tr>
<%
for i=0 to rs.Fields.Count-1%>
<th><%=rs(i).Name%></th>
<%next%>
</tr>
<% while not rs.eof%>
<tr>
<%
for i=0 to rs.Fields.Count-1%>
<td><%=rs(i)%></td>
<%next%>
</tr>
<%rs.MoveNext
wend
rs.Close
myconn.Close
%>
</table>
</body>
</html>
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment