Conn连接字符串[老是忘了,还是存起来吧]

2006-11-03 08:31:08

conn联接数据库字符串 '连接access <% set conn=server.cr&#101;ateobject("adodb.connection") provider="provider=microsoft.jet.oledb.4.0;" DBPath ="data source=" & Server.MapPath("exam.mdb") conn.Open provider & DBPath %> '连接sql server <% dim conn set conn=server.CreateObject("adodb.connection") conn.ConnectionString = "driver={SQL Server};server=192.168.0.1;uid=sa;Pwd=1234;database=YouDatabase" conn.open %> '连接mssql <% dim conn set conn=server.CreateObject("adodb.connection") conn.open "dsn=mysql;uid=root;pwd=;" set rs=server.CreateObject("adodb.recordset") sql="sel&#101;ct * from user" rs.open sql,conn,3,3 %> '连接mysql DBServer_MySql = "xxx"'数据库服务器地址 DBUsername_MySql = "yyy"'用户名 DBPassword_MySql = "zzz" '用户密码 DBName_MySql = "aaa"'数据库名 ConnString_MySql = "Driver={MySQL ODBC 3.51 Driver};Server=" & DBServer_MySql & ";Uid=" & DBUsername_MySql & ";Pwd=" & DBPassword_MySql & ";Database=" & DBName_MySql & ";Port=3306;Option=3;Socket=;Stmt=Set Names 'GBK';" 注意数据库连接串里面的 Stmt=Set Names 'GBK' ,一定要有这一句。 '联接DBF数据库 Function ConnectDBF() Set connDBF = Server.CreateObject("ADODB.Connection") Driver = "Driver={Microsoft Visual FoxPro Driver};" SourceType = "SourceType=DBF;" DBPath = "SourceDB=" & Server.MapPath("kq.dbc") connDBF.Open Driver & SourceType & DBPath End Function kq.dbc是dbf数据库文件所在的目录