asp/asp.net连接sql anywhere数据库

<%   
set conn= server.createobject("ADODB.connection")
conn.open "driver={sybase driver 10};"
"srvr=SYBASE;"
"UID=sa;"
"pwd=sybase;"
sql="select no from tab_stud"
set rs=conn.Execute("sql")
response.write rs
%>
string connStr = "Provider=SAOLEDB.10;uid=dba;pwd=sql;Links=TcpIp(host=192.168.1.2;serverport=2638);eng=mysadb";
                OleDbConnection oleConn = new OleDbConnection(connStr);
                OleDbCommand oleComm = new OleDbCommand("select count(*) from t_test");
                oleComm.Connection = oleConn;
                oleConn.Open();
                Response.Write(oleComm.ExecuteScalar());
                oleConn.Close();
其中要点(经多方尝试得出):把Sql anywhere目录win32下dboledb10.dll(版本为10.0.1)、dboledba10.dll(版本为10.0.1)注册regsvr32 ....
如果c:/windows/system32下没有这两个文件则将其复制过去。测试10.0.0版asp.net不可用总提示SAOLEDB未注册,winform可以,必须为10.0.1
posted @ 2010-05-19 20:38  网事  阅读(312)  评论(0编辑  收藏  举报