数据库操作的问题
在做vb.net到sql server2000 (个人版)的连接测试,碰到异常。代码如下:
Dim objConnection As OleDbConnection = New OleDbConnection("Integrated Security=SSPI;Packet Size=4096;Tag with column collation when possible" & _
"=False;Initial Catalog=Student;Use Procedure for Prepare=1;Auto Translate=True;P" & _
"ersist Security Info=False;Provider=""SQLOLEDB.1"";Workstation ID=""JATI-RQ708"";Use" & _
" Encryption for Data=False")
...
Dim objDataAdapter As New OleDbDataAdapter
Dim objDataSet As DataSet = New DataSet
objConnection.Open()
objDataAdapter.SelectCommand = New OleDbCommand
objDataAdapter.SelectCommand.Connection = objConnection
objDataAdapter.SelectCommand.CommandText = "SELECT user, password" & _
"FROM loglist " & _
"ORDER BY user"
objDataAdapter.SelectCommand.CommandType = CommandType.Text
objDataAdapter.SelectCommand.ExecuteNonQuery()
objDataAdapter.Fill(objDataSet, "loglist")
objConnection.Close()
测试运行到objDataAdapter.SelectCommand.ExecuteNonQuery(),也就是倒数第三行这就产生异常,返回的消息是一个未处理的异常
'System.Data.OleDb.OleDbException' occurred in system.data.dll。
谁碰到过这种事情啊?
[解决办法]
用try
[解决办法]
如果想要别人帮忙解决问题,就应该把错误的详细内容贴出来。
比如你这里的OleDbException 是无法打开连接还是什么别的错误.