按名称查找记录 [英] find records by name

查看:76
本文介绍了按名称查找记录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨.有人告诉我如何在数据库中按名称查找记录吗?即时通讯使用vb.net和sql searver.感谢

解决方案

示例代码布局:

  Dim  con  As   SqlConnection
 Dim  cmd  As  新建 SqlCommand
尝试
con.ConnectionString = " 
con.Open()
cmd.Connection = con
cmd.CommandText = " 
 Dim  lrd  As  SqlDataReader = cmd.ExecuteReader()

同时 lrd.Read()
' 在这里做些事情
结束 同时

捕获,例如 As 异常
MessageBox.Show(" & ex.Message," )
最后
con.Close()
结束 尝试 


hi. any one tell me how find records by name in database? im using vb.net and sql searver. thanks

解决方案

Sample code layout:

Dim con As New SqlConnection
Dim cmd As New SqlCommand
Try
con.ConnectionString = "Data Source=atisource;Initial Catalog=BillingSys;Persist Security Info=True;User ID=sa;Password=12345678"
con.Open()
cmd.Connection = con
cmd.CommandText = "SELECT [field1], [field2] FROM [tablename] WHERE [condition] ORDER BY [sortfield]"
Dim lrd As SqlDataReader = cmd.ExecuteReader()

While lrd.Read()
'Do something here
End While

Catch ex As Exception
MessageBox.Show("Error while retrieving records on table..." & ex.Message, "Load Records")
Finally
con.Close()
End Try


这篇关于按名称查找记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆