Member 13341316 Ответов: 2

Argumentexception был необработан


Imports System.Data.OleDb
Public Class Form1
    Dim provider As String
    Dim dataFile As String
    Dim connstring As String
    Dim myconnection As OleDbConnection = New OleDbConnection

    Private Sub StatisticBindingNavigatorSaveItem_Click(sender As Object, e As EventArgs)
        Me.Validate()
        Me.StatisticBindingSource.EndEdit()
        Me.TableAdapterManager.UpdateAll(Me.TeejayDataSet)

    End Sub

    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        'TODO: This line of code loads data into the 'TeejayDataSet.Statistic' table. You can move, or remove it, as needed.
        Me.StatisticTableAdapter.Fill(Me.TeejayDataSet.Statistic)

    End Sub

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        StatisticBindingSource.AddNew()
    End Sub

    Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
        provider = "provide=Microsoft.ACE.OLEDB.12.0;" & _
        dataFile = "Data Source=teejay.accdb;"
        connstring = provider & dataFile
        myconnection.ConnectionString = connstring
        myconnection.Open()
        Dim str As String
        str = ("INSERT INTO members (Date,Bowen,Nursing,Bowen1,Nursing1,Total Bowen,Total Nursing) " & _
                         "VALUES (@Date,@Bowen,@Nursing,@Bowen1,@Nursing1,@Total Bowen,@Total Nursing); ")
        Dim cmd As OleDbCommand = New OleDbCommand(str, myconnection)
        cmd.Parameters.Add(New OleDbParameter("Date", CType(DateDateTimePicker.Text, String)))
        cmd.Parameters.Add(New OleDbParameter("Date", CType(BowenTextBox.Text, String)))
        cmd.Parameters.Add(New OleDbParameter("Date", CType(NursingTextBox.Text, String)))
        cmd.Parameters.Add(New OleDbParameter("Date", CType(Bowen1TextBox.Text, String)))
        cmd.Parameters.Add(New OleDbParameter("Date", CType(Nursing1TextBox.Text, String)))
        cmd.Parameters.Add(New OleDbParameter("Date", CType(Total_BowenTextBox.Text, String)))
        cmd.Parameters.Add(New OleDbParameter("Date", CType(Total_NursingTextBox.Text, String)))
        Try
            cmd.ExecuteNonQuery()
            cmd.Dispose()
            myconnection.Close()
            BowenTextBox.Clear()
            NursingTextBox.Clear()
            Bowen1TextBox.Clear()
            Nursing1TextBox.Clear()
            Total_BowenTextBox.Clear()
            Total_NursingTextBox.Clear()
        Catch ex As Exception
            MsgBox(ex.Message)

        End Try


    End Sub

    Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
        StatisticBindingSource.RemoveCurrent()

    End Sub
End Class


Что я уже пробовал:

помогите мне решить эту проблему. я выделяю жирным шрифтом то место, где он дает мне ошибку

2 Ответов

Рейтинг:
2

Jochen Arndt

В дополнение к решению 1 есть еще одна ошибка в той же строке. Это должно быть обеспеченоР (обратите внимание на отсутствующие Р в вашем коде):

provider = "provider=Microsoft.ACE.OLEDB.12.0;"


Рейтинг:
0

OriginalGriff

Вероятно, вы хотите удалить "& _ " из конца этого:

provider = "provide=Microsoft.ACE.OLEDB.12.0;" & _