模块中有Public g_conn As ADODB.Connection
from1中的代码
Public Sub Opendatabase()
Set g_conn = New ADODB.Connection
g_conn.ConnectionString = "DSN=sms"
g_conn.Open
If g_conn.State <> adStateOpen Then
MsgBox "数据库打开失败", vbOKOnly + vbCritical + conAppName
Unload frmMain
End If
End Sub
Private Sub Form_Load()
Opendatabase
Dim a As ADODB.Recordset
Set a = New ADODB.Recordset
a.Open "select * from student where xm='水粉画'", g_conn, adOpenStatic, adLockOptimistic, adCmdText
End Sub
出现以错误Too few parameters. expected 1
ADODB中的SQL是完全支持汉字查询的,从你贴出的贴子来看,是SQL语句的问题。在VB的SQL语句中如果条件为字符串应该用单引号,不能用双引号。如果非要双引号,应该用Chr(34)来代替。
例如:
sSQL="Select a from a='条件'"
或
sSQL="select a from a=" & chr(34) & "条件" & chr(34)