I am a very beginner in coding, changing career and doing self learning+enrolled to a self funded course to get into programming. I posted some similar question earlier but now I have more bigger issue in my code! It was partially working until I mess it up :(.. I have a form which the user will fill then store it into Microsoft Access database, when it was working the first detailed user entered was perfectly stored into my table but second deatiled it skipped the first field (firstname in my case) and stored the firstname to Surname(my second field) basically every time it was skiping one field and starting from the following field ( Hope I am clear!) .. Now that I changed my code, It keeps giving me Syntax error and I checked different tutorials and different syntax ( they all use different syntax) but this error is VERY persistant!

Please, help me.. below is mycode

Imports System.Data.OleDb

Public Class FirstCode
    Inherits System.Web.UI.Page
    Dim provider As String
    Dim dataFile As String
    Dim connString As String
    Dim myConnection As OleDbConnection = New OleDbConnection

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

    End Sub

    Protected Sub Button1_Click(sender As Object, e As EventArgs) Handles save.Click
        provider = "Provider= Microsoft.ACE.OLEDB.15.0;Data Source = "
        dataFile = "C:\Users\Data.accdb"
        connString = provider & dataFile
        myConnection.ConnectionString = connString
        myConnection.Open()
        Dim str As String

        str = "INSERT INTO RegisterList (FirstName,Surname,Email,Location,ZipCode,Num,[Password]) + VALUES (@FirstName,@Surname,@Email,@Location,@ZipCode,@Num,@Pass)"

        str = " Insert into RegisterList (FirstName) Values(@FirstName)"
        str = " Insert into RegisterList (Surname) Values(@Surname)"
        str = " Insert into RegisterList (Email) Values(@Email)"
        str = " Insert into RegisterList (Location) Values(@Location)"
        str = " Insert into RegisterList (ZipCode) Values(@ZipCode)"
        str = " Insert into RegisterList (Num) Values(@Num)"
        str = " Insert into RegisterList (Password) Values(@Pass)"

        Dim cmd As OleDbCommand = New OleDbCommand(str, myConnection)
        cmd.Parameters.AddWithValue("@FirstName", TextBox2.Text)
        cmd.Parameters.AddWithValue("@Surname", TextBox3.Text)
        cmd.Parameters.AddWithValue("@Email", TextBox3.Text)
        cmd.Parameters.AddWithValue("@Location", DropDownList1.Text)
        cmd.Parameters.AddWithValue("@CourtName", TextBox4.Text)
        cmd.Parameters.AddWithValue("@Homecare", TextBox5.Text)
        cmd.Parameters.AddWithValue("@Pass", TextBox6.Text)

        cmd.ExecuteNonQuery()
        myConnection.Close()

    End Sub

    Protected Sub Button1_Click1(sender As Object, e As EventArgs) Handles Button1.Click

    End Sub
End Class

Related posts

Recent Viewed