最简单的问题求助
我刚接触到VB.NET,好多语法都不熟,现在我要在 数据库 "JML " 的 "人员_门市_Ref "表里面查询 "密码 "字段的值并保存到变量mima里面,请问该怎么弄?
下面是我写的,请大家帮我写出正确的 ,谢谢
Dim ry As String = Me.ComboBox人员.Text.Trim
Dim mima As String
Select 人员_门市_Ref.密码 From 人员_门市_Ref into mima where 人员_门市_Ref.人员名称=人员_门市_Ref.ry
[解决办法]
dim conn as new sqlcilent.sqlconntion( " ") '里面填上连接字符串,不会的可以去查一下手册
dim comm as new sqlcilent.sqlcommand( "Select 人员_门市_Ref.密码 From 人员_门市_Ref into mima where 人员_门市_Ref.人员名称=人员_门市_Ref.ry ",conn)
dim adp as new sqlcilent.dataadapter(comm)
dim ds as new dataset
conn.open '打开数据库连接
adp.fill(ds, "Table1 ") '将数据适配器的取值放到ds的 "Table1 "表中去
conn.close '关闭数据连接
mima=ds.tables( "Table1 ").rows(0).item( "密码 ").tostring
可能有些不是很准确,不过大致就是以上的语句了