两段一模一样的代码, 为什么一个能运行,一个却运行不了!
不能运行
Dim strConStr As String = "Provider=Microsoft.Jet.OLEDB.4.0; " & _
"Data Source=D:\IIS\Banking.mdb "
Dim strComStr As String = "Select * From tblUsers "
Dim dscA As OleDbDataAdapter = New OleDbDataAdapter(strConStr, strComStr)
可运行
Dim strConStr As String = "Provider=Microsoft.Jet.OLEDB.4.0; " & _
"Data Source=D:\IIS\Banking.mdb "
Dim strComStr As String = "Select * From tblUsers "
Dim dscA As OleDbDataAdapter = New OleDbDataAdapter(strComStr, strConStr)
一模一样啊,我试了无数次了, 前一个复制粘贴后就是不能运行,提示:
从索引 0 处开始,初始化字符串的格式不符合规范。
后一个就是能,有如此奇怪的事???
------解决方案--------------------最后一句明显不一样啊.
初始化数据适配器时传入的参数搞反了.
第一句:Dim dscA As OleDbDataAdapter = New OleDbDataAdapter(strConStr, strComStr)
第二句:Dim dscA As OleDbDataAdapter = New OleDbDataAdapter(strComStr, strConStr)
看一下后面的参数先后位置;
------解决方案--------------------(strComStr, strConStr)
(strConStr, strComStr)
不一样吧
------解决方案--------------------第一句:Dim dscA As OleDbDataAdapter = New OleDbDataAdapter(strConStr, strComStr)
第二句:Dim dscA As OleDbDataAdapter = New OleDbDataAdapter(strComStr, strConStr)
这也能复制出来??
你啥机器,厉害啊
------解决方案--------------------参数传递错误!
建议不要使用这种相近的字母区别参数的名称,以避免不必要的错误!