protected void TextBox1_TextChanged(object sender, EventArgs e)
{
SqlConnection libCon = new SqlConnection("Data Source=.\\sqlexpress;Initial Catalog=library;Integrated Security=True");
libCon.Open();
string BorSQL;
BorSQL = "select rName from borrow where bookid = '"+TextBox1.Text+"';";
SqlCommand StuIns = new SqlCommand(BorSQL, libCon);
SqlDataReader libDa = StuIns.ExecuteReader();
libDa.Read();
Response.Write(label1.Text =
libCon.Close();
************************************************************************************************************
我想从通过TextBox1.Text输入,从borrow表里查询到rName 并输入到label1里面
{
SqlConnection libCon = new SqlConnection("Data Source=.\\sqlexpress;Initial Catalog=library;Integrated Security=True");
libCon.Open();
string BorSQL;
BorSQL = "select rName from borrow where bookid = '"+TextBox1.Text+"';";
SqlCommand StuIns = new SqlCommand(BorSQL, libCon);
SqlDataReader libDa = StuIns.ExecuteReader();
libDa.Read();
Response.Write(label1.Text =
libCon.Close();
************************************************************************************************************
我想从通过TextBox1.Text输入,从borrow表里查询到rName 并输入到label1里面
解决方案 »
- C#中的stream在C++里有相同的类型吗?
- 正则表达式
- 初学者问个弱弱的问题
- 如何在ComboBox中下拉DataGridView,并将组合后的控件再以DataGridViewColumn放置在DataGridView控件中?
- 如何将软件像Visual Assist X 那样,安装后植入到类型VC,c#编译器中使用
- 一个字符串的文题
- c#中用指针实现链表(顶有分)
- listView控件的简单问题
- 说明: HTTP 404。您正在查找的资源(或者它的一个依赖项)可能已被移除,或其名称已更改,或暂时不可用。请检查以下 URL 并确保其拼写正确。
- 多线程问题
- 一个内容中能不能同时存在两个缓存表
- 请帮忙把以下参数转换为C#的...
string sql = " select rName from borrow where bookid =@bookid";
using (SqlConnection conn = new SqlConnection("Data Source=.\\sqlexpress;Initial Catalog=library;Integrated Security=True"))
{
SqlCommand cmd = new SqlCommand(sql, conn);
cmd.Parameters.Add("@bookid", SqlDbType.VarChar);
cmd.Parameters["@name"].Value = TextBox1.Text;
try
{
conn.Open();
label1.Text= cmd.ExecuteScalar()==null?"":cmd.ExecuteScalar().ToString();
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
}
cmd.Parameters["@bookid"].Value = TextBox1.Text; //囧 更正
protected void TextBox1_TextChanged(object sender, EventArgs e)
{
using(SqlConnection libCon = new SqlConnection("Data Source=.\\sqlexpress;Initial Catalog=library;Integrated Security=True"))
libCon.Open();
string BorSQL;
BorSQL = "select rName from borrow where bookid = '"+TextBox1.Text+"'";
using(SqlCommand StuIns = new SqlCommand(BorSQL, libCon))
{
using(SqlDataReader libDa = StuIns.ExecuteReader())
{
while(libDa.Read())
{
label1.Text = libDa["rName"].ToString();
}
}
}
}