vb 里data控件与MsflexGrid怎么实现查询,在保存,
发布网友
发布时间:2023-09-01 04:03
我来回答
共1个回答
热心网友
时间:2024-12-11 20:14
这个查询与datagrid是一样的。保存吗。也就是平常的保存数据到数据库就可以的。
Private Sub Command1_Click()
If Text7 = "" Then
MsgBox (" 查询条件有误!请确认")
Exit Sub
End If
If rec.State = adStateOpen Then rec.Close
If flag = 0 Then
SQL = "select * from gdkh where 股东账号=" & Text7.Text & ""
rec.Open SQL, con, adOpenStatic, adLockOptimistic
If rec.RecordCount < 1 Then
MsgBox ("无此账号!请确认!")
Exit Sub
Else
If IsNull(rec("股东账号")) Then
Text4 = ""
Else
Text4 = rec("股东账号")
If IsNull(rec("股东姓名")) Then
Text2 = ""
Else
Text2 = rec("股东姓名")
If IsNull(rec("股东类别")) Then
Text3 = ""
Else
Text3 = rec("股东类别")
If IsNull(rec("证照编码")) Then
Text5 = ""
Else
Text5 = rec("证照编码")
End If
End If
End If
End If
End If
End If
If rec.State = adStateOpen Then rec.Close
SQL = "select * from gdkh where 股东账号=" & Text7.Text & ""
rec.Open SQL, con, adOpenStatic, adLockOptimistic
Set DataGrid1.DataSource = rec
DataGrid1.Enabled = False
End Sub
这是条件查询。如果查询到数据是空值则判断为空。