vb代码获取当前行的某个字段

Private Sub LoadData(ByVal jm As StringByVal)
Dim conn As New Connection
Dim temprs As New ADODB.Recordset
Dim strsql As String
Dim mocode As String
Dim cinvcode As String
Dim x As Integer
conn.Open Obj
填写代码处
strsql = "SELECT * from QWSK_SP_GongHao where cinvcode='" + cinvcode + "' "
With Adodc1
.ConnectionString = Obj
.RecordSource = strsql
End With
Adodc1.Refresh
Set temprs = Adodc1.Recordset
MSFlexGrid1.Cols = temprs.Fields.Count + 1
MSFlexGrid1.Rows = temprs.RecordCount + 1

'绑定数据
Dim j As Integer
For j = 0 To temprs.Fields.Count - 1
MSFlexGrid1.TextMatrix(0, j + 1) = temprs.Fields(j).Name '绑定表头列名称
Next j
If (temprs.EOF <> True And temprs.BOF <> True) Then
temprs.MoveFirst
End If

Dim i As Integer
i = 1
Do While True <> temprs.EOF
For j = 0 To temprs.Fields.Count - 1
MSFlexGrid1.TextMatrix(i, j + 1) = temprs.Fields(j).Value '绑定表体数据
Next j
i = i + 1
temprs.MoveNext
Loop
在填写代码处写上一句查询语句 使得strsql = "SELECT * from QWSK_SP_GongHao where cinvcode='" + cinvcode + "' "这句话cinvcode能用 cinvcode是当前行的字段

第1个回答  2014-09-10
target.value

或cells(target.row,"a")
第2个回答  2014-09-11
SQL语句的Where子句:
假设数据表有[姓名]字段,要查询某姓名的记录。
1,要查询的姓名为字符串常量
"Select * From 数据表名 Where 姓名='王老五'"
2,要查询的姓名为字符串变量
dim xm as string
xm = ='王老五'
"Select * From 数据表名 Where 姓名='" & xm & "'"本回答被网友采纳
第3个回答  2014-09-10
cinvcode=jm
相似回答