當前位置:編程學習大全網 - 源碼下載 - ASP 怎麽連接SQL數據庫

ASP 怎麽連接SQL數據庫

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 數據表" (將數據表所有記錄刪除)

  • 上一篇:ASP檢測圖片尺寸
  • 下一篇:帶EB的可轉債有什麽特點?
  • copyright 2024編程學習大全網