当combobox修改选择时(双击combobox控件后显示的那个事件里面),
执行下面的
dim ds as new dataset
dim ad as new sqldataadpter("select 代号 from table where 用户名='"& combobox.selectitem &"'",sqlconn)
ad.fill(ds)
textbox1.text=ds.table(0).row(0).item(0).tostring
下面的VB代码是转的
Dim conn As New SqlConnection("连接字符串")
Dim cmd As SqlCommand = conn.CreateCommand()
cmd.CommandText = "查询语句"
conn.Open()
Try
Dim reader As SqlDataReader = cmd.ExecuteReader()
If reader.Read() Then
textbox1.Text = reader.GetString(0)
End If
reader.Close()
Catch generatedExceptionName As Exception
Throw
End Try
cmd.Dispose()
conn.Close()
conn.Dispose()
[Quote=引用 4 楼 wtnu200 的回复:]
当combobox修改选择时(双击combobox控件后显示的那个事件里面),
执行下面的
dim ds as new dataset
dim ad as new sqldataadpter("select 代号 from table where 用户名='"& combobox.selectitem &"'",sqlconn)
ad.fill(ds)
textbox1.text=ds.table(0).row(0).item(0).tostring