VB读取SQL数据并在文本框中显示时,数据为空会报错,我希望为空也不报错,该怎么处理?代码如下:
Private Sub Command1_Click()Dim conn1 As New ADODB.Connection
Dim rst1 As ADODB.Recordsetconn1.ConnectionString = "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=室分;Data Source=PC-201009081452"
conn1.Open
SQL1 = "select * from 问题处理记录 where TD编号= "
SQL1 = SQL1 & " '" & Text1.Text & " ' "Set rst1 = conn1.Execute(SQL1)Do Until rst1.EOFText2.Text = rst1("高度")rst1.MoveNext
LoopEnd Sub
如果高度为空的话VB会提示:无效使用NULL,该怎么处理呢?
Private Sub Command1_Click()Dim conn1 As New ADODB.Connection
Dim rst1 As ADODB.Recordsetconn1.ConnectionString = "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=室分;Data Source=PC-201009081452"
conn1.Open
SQL1 = "select * from 问题处理记录 where TD编号= "
SQL1 = SQL1 & " '" & Text1.Text & " ' "Set rst1 = conn1.Execute(SQL1)Do Until rst1.EOFText2.Text = rst1("高度")rst1.MoveNext
LoopEnd Sub
如果高度为空的话VB会提示:无效使用NULL,该怎么处理呢?
NewSql = "update 问题处理记录 set 高度="+ trim(text2.Text)
NewCommand.ActiveConnection = Conn
NewCommand.CommandType = adCmdText
NewCommand.CommandText = NewSql
NewCommand.Execute