当我尝试在VB 6.0中运行此项目时,出现的错误是:找不到方法或数据成员
当我将文本方法定义到文本框时,文本方法出现错误,文本框可用的方法是计数项lbound ubound。
请帮我解决。
Private Sub btnSubmit_Click(Index As Integer)
Dim db_file As String
Dim statement As String
Dim conn As ADODB.Connection
Dim ctl As Control
db_file = App.path
If Right$(db_file, 1) <> "\" Then db_file = db_file & "\"
db_file = db_file & "MyDB.mdb"
Set conn = New ADODB.Connection
conn.ConnectionString = _
"Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & db_file & ";" & _
"Persist Security Info=False"
conn.Open
statement = "INSERT INTO MyTable " & "(Job_Date, Client, Final_Product, Description) " & _
'" VALUES (" & "'" & Date & "', " & "'" & txtClient.Text & "', " & "'" & txtFinalProduct.Text & "', " & "'" & txtDescription.Text & "'" & ")"
conn.Execute statement, , adCmdText
conn.Close
msgbox "Done"
End Sub
最佳答案
代替这个
statement = "INSERT INTO MyTable " & "(Job_Date, Client, Final_Product, Description) " & _
'" VALUES (" & "'" & Date & "', " & "'" & txtClient.Text & "', " & "'" & txtFinalProduct.Text & "', " & "'" & txtDescription.Text & "'" & ")"
。 。 。将注释开始'
移到上一行的串联运算符&
之前,像这样statement = "INSERT INTO MyTable " & "(Job_Date, Client, Final_Product, Description) " ' & _
" VALUES (" & "'" & Date & "', " & "'" & txtClient.Text & "', " & "'" & txtFinalProduct.Text & "', " & "'" & txtDescription.Text & "'" & ")"
。 。 。否则,它仍然希望连接一个未提供的字符串。
关于compiler-errors - VB6-找不到方法或数据成员,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63031507/