當前位置:首頁 » 編程語言 » 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-03-10 20:24:34 瀏覽:762
光遇安卓服為什麼注銷不了賬號 發布:2025-03-10 20:24:28 瀏覽:585
shell腳本教程視頻 發布:2025-03-10 20:05:45 瀏覽:61
吶喊解壓歌曲 發布:2025-03-10 19:30:22 瀏覽:669
怎樣用電腦做家庭雲伺服器 發布:2025-03-10 19:28:07 瀏覽:244
編程分享家 發布:2025-03-10 19:24:19 瀏覽:731
python切換路徑 發布:2025-03-10 19:21:58 瀏覽:922
數值最優化演算法與理論 發布:2025-03-10 19:09:45 瀏覽:315
p30伺服器怎麼樣 發布:2025-03-10 19:01:36 瀏覽:5
四州志是由誰編譯的 發布:2025-03-10 19:01:33 瀏覽:214