测试ASP链接MYSQL代码,高手帮我看看对不对?
<%'测试读取MySql数据库的内容strconnection="driver={mysqlodbc3.51driver};database=mysql;server=1...
<%
'测试读取MySql数据库的内容
strconnection="driver={ mysql odbc 3.51 driver };database=mysql;server=192.168.0.202;uid=root;password="
'无需配置dsn
set adodataconn = server.createobject("adodb.connection")
adodataconn.open strconnection
strquery = "select * from News"
set rs = adodataconn.execute(strquery)
if not rs.bof then
%>
<table border="1">
<tr>
<td><b>序列号</b></td>
<td><b>标 题</b></td>
</tr>
<%
do while not rs.eof
%>
<tr>
<td><%=rs("News_id")%></td>
<td><%=rs("News_Title")%></td>
</tr>
<%
rs.movenext
loop
%>
</table>
<%
else
response.write("无数据.")
end if
rs.close
adodataconn.close
set adodataconn = nothing
set rsemaildata = nothing
%>
还有下边这段代码对吗?都是我在网上搜的!
我的网站跟数据库不在同一服务器,我想让在WEB上的注册,把信息提交到MYSQL数据库下.我都需要做些什么设置啊...
高手帮我解决一下,好了我也可以付人民币.只要能帮我解决问题.
<%
strConnection = "dsn=mysql;driver={myodbd driver};server=192.168.0.201;uid=user;pwd=user; database=mysql"'创建netgoing数据库
'strconnection="DefaultDir=;Driver={myodbc driver};server=192.168.0.201;database=abcce"
Set adoDataConn = Server.CreateObject("ADODB.Connection")
adoDataConn.Open strConnection
%> 展开
'测试读取MySql数据库的内容
strconnection="driver={ mysql odbc 3.51 driver };database=mysql;server=192.168.0.202;uid=root;password="
'无需配置dsn
set adodataconn = server.createobject("adodb.connection")
adodataconn.open strconnection
strquery = "select * from News"
set rs = adodataconn.execute(strquery)
if not rs.bof then
%>
<table border="1">
<tr>
<td><b>序列号</b></td>
<td><b>标 题</b></td>
</tr>
<%
do while not rs.eof
%>
<tr>
<td><%=rs("News_id")%></td>
<td><%=rs("News_Title")%></td>
</tr>
<%
rs.movenext
loop
%>
</table>
<%
else
response.write("无数据.")
end if
rs.close
adodataconn.close
set adodataconn = nothing
set rsemaildata = nothing
%>
还有下边这段代码对吗?都是我在网上搜的!
我的网站跟数据库不在同一服务器,我想让在WEB上的注册,把信息提交到MYSQL数据库下.我都需要做些什么设置啊...
高手帮我解决一下,好了我也可以付人民币.只要能帮我解决问题.
<%
strConnection = "dsn=mysql;driver={myodbd driver};server=192.168.0.201;uid=user;pwd=user; database=mysql"'创建netgoing数据库
'strconnection="DefaultDir=;Driver={myodbc driver};server=192.168.0.201;database=abcce"
Set adoDataConn = Server.CreateObject("ADODB.Connection")
adoDataConn.Open strConnection
%> 展开
2个回答
展开全部
MyODBC 2.50 Local database
Driver={mySQL};Server=localhost;Option=16834;Database=myDataBase;
MyODBC 2.50 Remote database
Driver={mySQL};Server=myServerAddress;Port=3306;Option=131072;Stmt=; Database=myDataBase;Uid=myUsername;Pwd=myPassword;
MyODBC 3.51 Local database
Driver={MySQL ODBC 3.51 Driver};Server=localhost;Database=myDataBase; User=myUsername;Password=myPassword;Option=3;
MyODBC 3.51 Remote database
Driver={MySQL ODBC 3.51 Driver};Server=data.domain.com;Port=3306;Database=myDataBase;User=myUsername; Password=myPassword;Option=3;
Driver={mySQL};Server=localhost;Option=16834;Database=myDataBase;
MyODBC 2.50 Remote database
Driver={mySQL};Server=myServerAddress;Port=3306;Option=131072;Stmt=; Database=myDataBase;Uid=myUsername;Pwd=myPassword;
MyODBC 3.51 Local database
Driver={MySQL ODBC 3.51 Driver};Server=localhost;Database=myDataBase; User=myUsername;Password=myPassword;Option=3;
MyODBC 3.51 Remote database
Driver={MySQL ODBC 3.51 Driver};Server=data.domain.com;Port=3306;Database=myDataBase;User=myUsername; Password=myPassword;Option=3;
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
到mysql下载MySQL ODBC 3.51 Driver安装
连接字符串:
connstr = "DRIVER={MySQL ODBC 3.51 Driver};PORT=;UID=;PASSWORD=;SERVER=;DATABASE=;"
port -->mysql服务的端口 默认3307
uid -->用户名
password -->密码
server --->主机
database -->数据库名称
set rs = adodataconn.execute(strquery)
此句有误,应该是
set rs=server.createobject("ADODB.RECORDSET")~~~~
SOSO~~~
///////////////////////////////////
set adodataconn = server.createobject("adodb.connection")
adodataconn.open strconnection
set rs=server.createobject("adodb.recordset")
strquery = "select * from News"
'set rs = adodataconn.execute(strquery)
rs.open strquery,adodataconn,1,3
if not rs.bof then
%>
<table border="1">
<tr>
<td><b>序列号</b></td>
<td><b>标 题</b></td>
</tr>
<%
do while not rs.eof
%>
<tr>
<td><%=rs("News_id")%></td>
<td><%=rs("News_Title")%></td>
</tr>
<%
rs.movenext
loop
%>
</table>
<%
else
response.write("无数据.")
end if
rs.close
set rs = nothing
adodataconn.close
set adodataconn = nothing
%>
/////////////soso.....
连接字符串:
connstr = "DRIVER={MySQL ODBC 3.51 Driver};PORT=;UID=;PASSWORD=;SERVER=;DATABASE=;"
port -->mysql服务的端口 默认3307
uid -->用户名
password -->密码
server --->主机
database -->数据库名称
set rs = adodataconn.execute(strquery)
此句有误,应该是
set rs=server.createobject("ADODB.RECORDSET")~~~~
SOSO~~~
///////////////////////////////////
set adodataconn = server.createobject("adodb.connection")
adodataconn.open strconnection
set rs=server.createobject("adodb.recordset")
strquery = "select * from News"
'set rs = adodataconn.execute(strquery)
rs.open strquery,adodataconn,1,3
if not rs.bof then
%>
<table border="1">
<tr>
<td><b>序列号</b></td>
<td><b>标 题</b></td>
</tr>
<%
do while not rs.eof
%>
<tr>
<td><%=rs("News_id")%></td>
<td><%=rs("News_Title")%></td>
</tr>
<%
rs.movenext
loop
%>
</table>
<%
else
response.write("无数据.")
end if
rs.close
set rs = nothing
adodataconn.close
set adodataconn = nothing
%>
/////////////soso.....
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询