VB错误 先提示至少一个参数没有指定值, 然后 弹出对象'refresh的'方法'IAdodc'失败 请问什么原因?
OptionExplicitPublicconnAsNewADODB.ConnectionPublicrsAsNewADODB.RecordsetPrivateSubcm...
Option Explicit
Public conn As New ADODB.Connection
Public rs As New ADODB.Recordset
Private Sub cmdCheck_Click()
If txtCheck.Text = "" Then
MsgBox "查询内容不能为空", vbOKOnly + vbInformation, "提示"
Exit Sub
End If
Adodc1.CommandType = adCmdText
Adodc1.RecordSource = "select carNo as 车牌号码,driver_name as 司机,PC_No as 交警编号,ticket_time as 开单日期 from TrafficTicket where 车牌号码 ='" & txtCheck & "'or 司机='" & txtCheck & "'or 交警编号='" & txtCheck & "' or 开单日期='" & txtCheck & "'"
Adodc1.Refresh
Set rs = conn.Execute("select carNo as 车牌号码,driver_name as 司机,PC_No as 交警编号,ticket_time as 开单日期 from TrafficTicket where 车牌号码 ='" & txtCheck & "'or 司机='" & txtCheck & "'or 交警编号='" & txtCheck & "' or 开单日期='" & txtCheck & "'")
If rs.EOF = True Then
MsgBox "未查找到该罚单信息", vbOKOnly + vbInformation, "提示"
End If
End Sub 展开
Public conn As New ADODB.Connection
Public rs As New ADODB.Recordset
Private Sub cmdCheck_Click()
If txtCheck.Text = "" Then
MsgBox "查询内容不能为空", vbOKOnly + vbInformation, "提示"
Exit Sub
End If
Adodc1.CommandType = adCmdText
Adodc1.RecordSource = "select carNo as 车牌号码,driver_name as 司机,PC_No as 交警编号,ticket_time as 开单日期 from TrafficTicket where 车牌号码 ='" & txtCheck & "'or 司机='" & txtCheck & "'or 交警编号='" & txtCheck & "' or 开单日期='" & txtCheck & "'"
Adodc1.Refresh
Set rs = conn.Execute("select carNo as 车牌号码,driver_name as 司机,PC_No as 交警编号,ticket_time as 开单日期 from TrafficTicket where 车牌号码 ='" & txtCheck & "'or 司机='" & txtCheck & "'or 交警编号='" & txtCheck & "' or 开单日期='" & txtCheck & "'")
If rs.EOF = True Then
MsgBox "未查找到该罚单信息", vbOKOnly + vbInformation, "提示"
End If
End Sub 展开
3个回答
2011-10-04
展开全部
Adodc1控件估计也没连接数据库(连接串没设置)
Public conn As New ADODB.Connection
Public rs As New ADODB.Recordset
Set rs = conn.Execute("select carNo as 车牌号码,driver_name as 司机,PC_No as 交警编号,ticket_time as 开单日期 from TrafficTicket where 车牌号码 ='" & txtCheck & "'or 司机='" & txtCheck & "'or 交警编号='" & txtCheck & "' or 开单日期='" & txtCheck & "'")
//conn没有打开就直接用当然出错
//conn.open "对应数据库连接串"
Public conn As New ADODB.Connection
Public rs As New ADODB.Recordset
Set rs = conn.Execute("select carNo as 车牌号码,driver_name as 司机,PC_No as 交警编号,ticket_time as 开单日期 from TrafficTicket where 车牌号码 ='" & txtCheck & "'or 司机='" & txtCheck & "'or 交警编号='" & txtCheck & "' or 开单日期='" & txtCheck & "'")
//conn没有打开就直接用当然出错
//conn.open "对应数据库连接串"
追问
对应数据库连接串是啥? 新手
追答
标准连接(Standard Security):
"Provider=sqloledb;Data Source=Aron1;Initial Catalog=pubs;User Id=sa;Password=asdasd; "
信任连接(Trusted connection):
"Provider=sqloledb;Data Source=Aron1;Initial Catalog=pubs;Integrated Security=SSPI; "
(如果连接一个具体的已命名SQLServer实例,使用Data Source=Servere Name\Instance Name;但仅适用于 SQLServer2000)例 如: "Provider=sqloledb;Data Source=MyServerName\MyInstanceName;Initial Catalog=MyDatabaseName;User Id=MyUsername;Password=MyPassword; "
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询