Private Sub frmRegistration_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
cn.Open()
cmd.Connection = cn
cmd.CommandText = "Select * from Registration"
adp = New OleDb.OleDbDataAdapter(cmd)
adp.Fill(ds, "mytable")
'Binding Statements Follow
bs = New BindingSource(ds, "mytable")
'Bind the name field to first textbox, type of data as text
Me.txtCustID.DataBindings.Add("text", bs, "Customer_ID")<<<< this part gives me problem with saying "Cannot bind to the property or column Customer_ID on the DataSource.
Parameter name: dataMember" Me.txtFirstName.DataBindings.Add("text", bs, "First_Name")
Me.txtLastName.DataBindings.Add("text", bs, "Last_Name")
Me.txtDateOfBirth.DataBindings.Add("text", bs, "Date_of_Birth")
Me.txtGender.DataBindings.Add("text", bs, "Gender")
Me.txtPhoneNumber.DataBindings.Add("text", bs, "Phone_Number")
Me.txtEmail.DataBindings.Add("text", bs, "Email")
Me.txtAddress.DataBindings.Add("text", bs, "Address")
cn.Close()
End Sub


Pls pls people help me i would really appreciate this :)

Recommended Answers

All 6 Replies

Your error means that there is no column Customer_ID in the dataset. Verify that Registration has a column named like that or verify that this is the exact name of the column you want to bind to that field.

adam_k thanx for ur help but now i am seriously having trouble with something else please help here is full my code

Imports System.Data.OleDb

Public Class frmRegistration
    Dim cn As New OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Persist Security Info=False;Data Source=F:\vbedit\Vb assigment\WindowsApplication1\databaseforregistration.mdb")
    Dim cmd As New OleDb.OleDbCommand
    Dim adp As OleDb.OleDbDataAdapter
    Dim ds As New DataSet
    Dim bs As BindingSource


    Private Sub btnCancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCancel.Click
        frmMainMenu.Show()
        Me.Hide()
    End Sub

    Private Sub btnAccept_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAccept.Click


        'Sql statement. This will insert record into Registration table
        Dim sqlQRY As String = "INSERT INTO Registration (Customer_ID, First_Name, Last_Name, Date_of_Birth, Gender, Phone_Number, Email, Address) VALUES ('& txtCustomerID.Text &',' & txtFirstName.Text & ',' & txtLastName.Text & ',' & txtDateOfBirth.Text & ',' & txtGender.Text & ','& txtPhoneNumber.Text & ', ' & txtEmail.Text & ', ' & txtAddress.Text & ')"

        'Create connection
        'Dim conn As OleDbConnection = New OleDbConnection(cnString)

        Try
            ' Open connection
            cn.Open()

            'create command 
            Dim cmd As OleDbCommand = New OleDbCommand(sqlQRY, cn)

            'execute non query command
            cmd.ExecuteNonQuery()

            MsgBox("Record successfully saved...", MsgBoxStyle.Information)
        Catch ex As OleDbException
            MsgBox("Error: " & ex.ToString & vbCrLf)
        Finally
            ' Close connection
            cn.Close()
        End Try
    End Sub
    Private Sub frmRegistration_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        cn.Open()
        cmd.Connection = cn
        cmd.CommandText = "Select * from Registration"
        adp = New OleDb.OleDbDataAdapter(cmd)
        adp.Fill(ds, "mytable")
        'Binding Statements Follow 
        bs = New BindingSource(ds, "mytable")
        'Bind the name field to first textbox, type of data as text 
        Me.txtCustomerID.DataBindings.Add("text", bs, "Customer_ID")
        Me.txtLastName.DataBindings.Add("text", bs, "Last_Name")
        'Me.txtDateOfBirth.DataBindings.Add("text", bs, "Date_of_Birth")
        Me.txtGender.DataBindings.Add("text", bs, "Gender")
        Me.txtPhoneNumber.DataBindings.Add("text", bs, "Phone_Number")
        Me.txtEmail.DataBindings.Add("text", bs, "Email")
        Me.txtAddress.DataBindings.Add("text", bs, "Address")
        cn.Close()
    End Sub
End Class

basically what i am planning to do is this is the place where i can register customers, but when i key in all of them i get a system error

Where exactly do you get this error? On which line of code?

after i key in all the info in registration like customer id and stuff after i press accept which basically has to save it to database it fails

I guess your problem in in inserting new custome into database.
Your sql query is not ok, chnage it to:

"INSERT INTO Registration (Customer_ID, First_Name, Last_Name, Date_of_Birth, Gender, Phone_Number, Email, Address) VALUES ('"& txtCustomerID.Text &"','" & txtFirstName.Text & "','" & txtLastName.Text & "','" & txtDateOfBirth.Text & "','" & txtGender.Text & "','" & txtPhoneNumber.Text & "', '" & txtEmail.Text & "', '" & txtAddress.Text & "')"

As you can see you have forgot to add double quotes when you define the parameters directly into query statement.

omg thanks a lot :)

now i am facing another problem.... if i wanna attach pic is it possible? what i mean i register user can i attach his photo? if yes how i seriously dont know how

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.