Visual Studio 2008搜索记录代码 [英] visual studio 2008 search record code
本文介绍了Visual Studio 2008搜索记录代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在asp.net中使用vb代码从SQL Server数据库2005的表中搜索数据?
How to search data from a table of a SQL Server database 2005 using vb code in asp.net?
推荐答案
尝试:
Using con As New SqlConnection(strConnect)
con.Open()
Using com As New SqlCommand("SELECT iD, description FROM myTable WHERE Name='John Smith'", con)
Using reader As SqlDataReader = com.ExecuteReader()
While reader.Read()
Dim id__1 As Integer = CInt(reader("iD"))
Dim desc As String = DirectCast(reader("description"), String)
Console.WriteLine("ID: {0}" & vbLf & " {1}", iD, desc)
End While
End Using
End Using
End Using
使用此代码.. ..
SqlConnection connew = null;
SqlDataReader sdrDatanew = null;
字符串strnew;
connew =新的SqlConnection(ConfigurationManager.AppSettings ["con"].ToString());
connew.Open();
strnew =从员工中选择*,其中emp_Int_Id =" + txtEmp.Text +";
SqlCommand sqlCommnew =新的SqlCommand(strnew,connew);
sdrDatanew = sqlCommnew.ExecuteReader();
如果(sdrDatanew.HasRows)
{
如果(sdrDatanew.Read())
{
记录可用,按照requiremant
编写代码 }
}
lblnorecords.Visible = true
connew.Close();
Use this code ....
SqlConnection connew = null;
SqlDataReader sdrDatanew = null;
string strnew;
connew = new SqlConnection(ConfigurationManager.AppSettings["con"].ToString());
connew.Open();
strnew = "select * from employee where emp_Int_Id=" + txtEmp.Text + "";
SqlCommand sqlCommnew = new SqlCommand(strnew, connew);
sdrDatanew = sqlCommnew.ExecuteReader();
if (sdrDatanew.HasRows)
{
if (sdrDatanew.Read())
{
records are available write your code as per requiremant
}
}
lblnorecords.Visible = true
connew.Close();
这篇关于Visual Studio 2008搜索记录代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文