发生错误类型'System.Data.OleDb.OleDbException'的未处理异常?

时间:2015-05-30 07:03:21

标签: sql wpf vb.net

发生错误System.Data.dll中出现类型为“System.Data.OleDb.OleDbException”的未处理异常附加信息:找不到可安装的ISAM。 和debuuger指向conn.Open()黄色背景这里是我的所有代码请指导我做错了什么?

Imports System.Data.OleDb
Imports System.Data.SqlClient

Public Class insert

    Private Sub btn_Click(sender As Object, e As RoutedEventArgs) Handles btn.Click

        Dim strConn As String = "Provider=Microsoft.Jet.OLEDB.4.0;Server=(localdb)\Projects;Database=test;Uid=sa;Pwd=12345;"
        'Provider=SQLOLEDB;("Server=(localdb)\Projects;Database=master;Uid=sa;Pwd=12345;"));Server=vu-it-wqs-pc\sqlexpress;Database=Test;Uid=sa;Pwd=123;"))
        'Dim conn As OleDbConnection

        Try
            Dim sname As String = txt1.Text
            Dim sfname As String = txt2.Text
            Dim scnic As String = txt3.Text
            Dim slimit As String = txt4.Text
            Dim semail As String = txt5.Text
            Dim stel As String = txt6.Text
            Dim stel1 As String = txt7.Text
            Dim qu As String = txt8.Text
            'Dim que As Date = Date.Parse(txt9.Text)
            Dim que As String = txt9.Text
            Dim query As String = String.Empty

            query &= "INSERT INTO tencmp (qnumber, topic, Umcq , Usq , Ulq , Emcq , Esq , Elq, pdate)"
            query &= "VALUES (?,?,?,?,?,?,?,?,?)"

            Using conn As New OleDbConnection(strConn)
                Using comm As New OleDbCommand()
                    With comm
                        .Connection = conn
                        '.CommandType = CommandType.Text
                        .CommandText = query
                        .Parameters.AddWithValue("@qnumber", sname)
                        .Parameters.AddWithValue("@topic", sfname)
                        .Parameters.AddWithValue("@colPhone", scnic)
                        .Parameters.AddWithValue("@colBranch", slimit)
                        .Parameters.AddWithValue("@colCourse", semail)
                        .Parameters.AddWithValue("@coldblFee", stel)
                        .Parameters.AddWithValue("@dobv", stel1)
                        .Parameters.AddWithValue("@coldblFee1", qu)
                        .Parameters.AddWithValue("@dobv1", que)

                        conn.Open()'error occur here on this id
                        comm.ExecuteNonQuery()
                    End With
                End Using
            End Using
        Catch ex As SqlException
            txt10.Text = ex.Message
        End Try
    End Sub
End Class

0 个答案:

没有答案