3个回答
展开全部
Dim cnnUser As New ADODB.Connection
Dim rstUser As New ADODB.Recordset
Private Sub Form_Load()
With cnnUser
If .State = adStateOpen Then .Close
.ConnectionString = "Provider=SQLOLEDB.1;Password=" & password & ";Persist Security Info=True;User ID=" & uId & ";Initial Catalog= " & DB & " ;Data Source=" & ds
.Open
End With
End Sub
Private Sub commSid_Click()
On Error GoTo p
With rstUser
If .State = adStateOpen Then .Close
.Open "Select * from wf_data where sid ='" & Trim(txtSid.Text) & "'", cnnUser, adOpenKeyset, adLockOptimistic
If Not .EOF Then
Me.coShangpin.Text = rstUser.Fields("shangpin").Value
Me.coChepai.Text = rstUser.Fields("chepai").Value
Me.coFahuo.Text = rstUser.Fields("fahuo").Value
Me.coShouhuo.Text = rstUser.Fields("shouhuo").Value
Me.txtDanjia.Text = rstUser.Fields("danjia").Value
Me.txtFeilv.Text = Format(rstUser.Fields("feilv").Value, "0.00")
Me.txtMaoz.Text = rstUser.Fields("maoz").Value
Me.txtPiz.Text = rstUser.Fields("piz").Value
End If
End With
Exit Sub
p:
MsgBox "数据库读取错误!", vbOKOnly, "错误"
End
End Sub
Dim rstUser As New ADODB.Recordset
Private Sub Form_Load()
With cnnUser
If .State = adStateOpen Then .Close
.ConnectionString = "Provider=SQLOLEDB.1;Password=" & password & ";Persist Security Info=True;User ID=" & uId & ";Initial Catalog= " & DB & " ;Data Source=" & ds
.Open
End With
End Sub
Private Sub commSid_Click()
On Error GoTo p
With rstUser
If .State = adStateOpen Then .Close
.Open "Select * from wf_data where sid ='" & Trim(txtSid.Text) & "'", cnnUser, adOpenKeyset, adLockOptimistic
If Not .EOF Then
Me.coShangpin.Text = rstUser.Fields("shangpin").Value
Me.coChepai.Text = rstUser.Fields("chepai").Value
Me.coFahuo.Text = rstUser.Fields("fahuo").Value
Me.coShouhuo.Text = rstUser.Fields("shouhuo").Value
Me.txtDanjia.Text = rstUser.Fields("danjia").Value
Me.txtFeilv.Text = Format(rstUser.Fields("feilv").Value, "0.00")
Me.txtMaoz.Text = rstUser.Fields("maoz").Value
Me.txtPiz.Text = rstUser.Fields("piz").Value
End If
End With
Exit Sub
p:
MsgBox "数据库读取错误!", vbOKOnly, "错误"
End
End Sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询