一个VB连接SQL Server的小问题,请各位大虾帮忙

来源:百度知道 编辑:UC知道 时间:2024/06/25 17:25:07
点击单选按钮option1,查询 “故障诊断”数据库中 ,“试验表”中“序号”为2的“排除方法” 并显示在text3中,如何用VB实现?

Public cn As New ADODB.Connection
Public rs As New ADODB.Recordset

if option1.Value=True then
cn.CursorLocation = adUseClient
cn.Open "Provider=sqloledb;Data Source=数据;Initial Catalog=故障诊断;User Id=用户名;Password=密码;"

SQL="Select '排除方法' from '试验表' Where '序号'=2 "
rs.Open SQL, cn, 1, 1
text3.text=rs.Fields("排除方法")
rs.close
cn.Close
end if