當前位置:首頁 » 編程語言 » asp查詢sql資料庫

asp查詢sql資料庫

發布時間: 2022-07-12 17:39:30

㈠ asp查詢調用sql資料庫代碼

記得在最上面加上這句指令集using System.Data.SqlClient;
在後台代碼中加入:
String constr = "server=.\\sqlexpress;database=test;uid=sa;pwd=123";這一種是sa用戶連接的代碼
//String constr = "server=.\\sqlexpress;database=test;Integrated security=true";這個是Windows身份驗證連接的代碼
SqlConnection con = new SqlConnection(constr);
con.Open();
// response.Write(con.State);
String sql = "select * from Student";
SqlCommand cmd = new SqlCommand(sql,con);
SqlDataReader dr = cmd.ExecuteReader();
while (dr.Read())
{
Response.Write(dr[1].ToString()+""+dr["name"].ToString()+"<br>");//dr[2]=dr["name"] response.write(dr.getInt32(3)+"<br>")
}
dr.Close();
con.Close();

㈡ ASP查詢SQL資料庫的問題

rs=Server.CreateObject("ADODB.Recordset")
set rs=conn.execute("select * from 表名")
while not rs.eof
rs("name")
rs.movenext
wend

㈢ ASP中SQL資料庫查詢功能如何實現

首先建立資料庫
資料庫里至少要有
編號、歌名、歌曲介紹
搜索時可建立記錄集recordset 使用模糊查詢
select * from [table] where 歌名 like %關鍵字% order by 編號 asc
顯示時可在對應的歌曲後加對應編號的播放按鈕

㈣ ASP通過一個條件查詢SQL資料庫

如果你的單選按鈕的名稱為sex (兩個都是一樣的名稱)那麼sql語句這樣寫
select * from table where sex='"&request.form("sex")&"'"
其中table是表名,sex是table中的欄位名

㈤ ASP通過一個條件查詢SQL資料庫方法

index.asp中的表單中,要含有 cname的文本框用來輸入姓名。

info.asp
sql="select * from 學生信息表名 where 姓名='"&request("cname")&"'"
'這樣是精確查詢,
'模糊查詢可以這樣寫
sql="select * from 學生信息表名 where 姓名 like '%"&request("cname")&"%'"

Set rs = Server.CreateObject("ADODB.Recordset")
rs.Open Sql, cnn, 1, 1 'cnn是你問題中說的已正確連接的對象名

經過上面以後,在你的顯示表格中,使用<%=rs("欄位名")%>來輸出相對應的信息

㈥ asp中 怎麼查詢sql資料庫呢

sql="select zb_value from zbstat" 缺少查詢條件 where id=?

㈦ asp查詢sql資料庫的查詢語句

資料庫的語句跟你用什麼資料庫有關,跟web編程語言無關。但是各個語言鏈接資料庫的代碼是不同的 sql中對表的查詢操作是這樣的 select * from 456 其中星號表示選擇這個表中的所有欄位。456就是表名了。

㈧ 關於ASP查詢SQL資料庫

set rs=conn.execute(sql) 是錯在這句么?如果是的話檢查y_user的屬性,如果是字元型的,把SQL改成sql="Select * from y_yp where y_user='"& user &"'"
如果是數值型的,那你在查詢前要加個isnumeric約束,防止程序出錯也好防止SQL惡意注入

㈨ 能用ASP在一個頁面裡面查詢SQL資料庫中的兩個庫中的表嗎

set
rs1=....
打開
表1
設置表1查找條件....
rs1("班代碼")=123
set
rs2=....
打開表2
根據表1結果
rs1("班代碼")=123
設置表2查找條件....
循環輸出,,,
差不多就是這樣吧

熱點內容
滑板鞋腳本視頻 發布:2025-02-02 09:48:54 瀏覽:431
群暉怎麼玩安卓模擬器 發布:2025-02-02 09:45:23 瀏覽:557
三星安卓12彩蛋怎麼玩 發布:2025-02-02 09:44:39 瀏覽:743
電腦顯示連接伺服器錯誤 發布:2025-02-02 09:24:10 瀏覽:536
瑞芯微開發板編譯 發布:2025-02-02 09:22:54 瀏覽:146
linux虛擬機用gcc編譯時顯示錯誤 發布:2025-02-02 09:14:01 瀏覽:232
java駝峰 發布:2025-02-02 09:13:26 瀏覽:651
魔獸腳本怎麼用 發布:2025-02-02 09:10:28 瀏覽:532
linuxadobe 發布:2025-02-02 09:09:43 瀏覽:212
sql2000資料庫連接 發布:2025-02-02 09:09:43 瀏覽:726