ASP與SQL數據庫連接語句具體如下:
Set conn = Server.CreateObject("ADODB.Connection")
connstr = "provider=Sqloledb;server=服務器名;uid=用戶名;pwd=密碼;database=數據庫名"
conn.Open connstr
If Err Then
err.Clear
Set conn = Nothing
Response.Write "數據庫連接出錯,請檢查連接字串"
Response.End
擴展資料:
SQL常用命令使用方法:
(1) 數據記錄篩選:
sql="select * from 數據表 where 字段名=字段值 order by 字段名 "
sql="select * from 數據表 where 字段名 like ‘%字段值%‘ order by 字段名 "
sql="select top 10 * from 數據表 where 字段名 order by 字段名 "
sql="select * from 數據表 where 字段名 in (‘值1‘,‘值2‘,‘值3‘)"
sql="select * from 數據表 where 字段名 between 值1 and 值2"
(2) 更新數據記錄:
sql="update 數據表 set 字段名=字段值 where 條件表達式"
sql="update 數據表 set 字段1=值1,字段2=值2 …… 字段n=值n where 條件表達式"
(3) 刪除數據記錄:
sql="delete from 數據表 where 條件表達式"
sql="delete from 數據表" (將數據表所有記錄刪除)