Hi, Im using Visual Basic 2008 to make my program.

I want to be able to input data from textboxes to my database tables using a buton, I created the database with the SQL server compact built into VB.

I am really usnsure and getting really frustrated with how to do this, Please help urgently :S

This is the code that I have completed so far:


Public Class New_Customers
'Dim connectionstring As String = CustomersBindingSource
Dim Customers As New DataTable()
'Dim _APDatabase_2_DataSet1 As DataSet

Private Sub lblDate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lblDate.Click
lblDate.Text = Today
End Sub

Private Sub lblTime_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lblTime.Click

lblTime.Text = TimeString
lblDate.Text = Today

End Sub

Private Sub tmrNewCustomers_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tmrNewCustomers.Tick

lblTime.Text = TimeString
lblDate.Text = Today

End Sub

Private Sub Label1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lblPostcode.Click

End Sub

Private Sub Cutomers_Closebtn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Cutomers_Closebtn.Click

Me.Hide()


End Sub

Private Sub New_Customers_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'TODO: This line of code loads data into the '_APDatabase_2_Cutomers.Customer' table. You can move, or remove it, as needed.
'Me.CustomerTableAdapter.Fill(Me._APDatabase_2_Cutomers.Customer)
'TODO: This line of code loads data into the 'Db1DataSet.Customers' table. You can move, or remove it, as needed.
'Me.CustomersTableAdapter.Fill(Me.Db1DataSet.Customers)

Me.forenametxt.DataBindings.Add(New Binding("Text", _APDatabase_2_DataSet1, "Customers.Forename"))
Me.txtSurname.DataBindings.Add(New Binding("Text", _APDatabase_2_DataSet1, "Customers.Surname"))
Me.txtAL1.DataBindings.Add(New Binding("Text", _APDatabase_2_DataSet1, "Customers.Address Line 1"))
Me.txtAL2.DataBindings.Add(New Binding("Text", _APDatabase_2_DataSet1, "Customers.Address Line 2"))
Me.txtTown.DataBindings.Add(New Binding("Text", _APDatabase_2_DataSet1, "Customers.Town"))
Me.txtCity.DataBindings.Add(New Binding("Text", _APDatabase_2_DataSet1, "Customers.City"))
Me.txtCounty.DataBindings.Add(New Binding("Text", _APDatabase_2_DataSet1, "Customers.County"))
Me.txtPostcode.DataBindings.Add(New Binding("Text", _APDatabase_2_DataSet1, "Customers.PostCode"))
Me.txt_Email.DataBindings.Add(New Binding("Text", _APDatabase_2_DataSet1, "Customers.E-Mail"))
Me.txt_HomeTel.DataBindings.Add(New Binding("Text", _APDatabase_2_DataSet1, "Customers.Home Telephone"))
'Me.txt_Mobile.DataBindings.Add(New Binding("Text", _APDatabase_2_DataSet1, "Customers.Mobile Telephone"))
'Me.Rd_Home_Tel.DataBindings.Add(New Binding("Boolean", _APDatabase_2_DataSet1, "Customers.Prefer Telephone"))
'Me.Rd_Mobile.DataBindings.Add(New Binding("Boolean", _APDatabase_2_DataSet1, "Customers.Prefer Mobile "))
'Me.Rd_Email.DataBindings.Add(New Binding("Boolean", _APDatabase_2_DataSet1, "Customers.Prefer Email"))

End Sub

Private Sub forenametxt_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles forenametxt.TextChanged
Dim query As String = "Insert into Forename"

End Sub

Private Sub txtCustomerID_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtCustomerID.TextChanged

End Sub

Private Sub btn_InsertDetails_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_InsertDetails.Click

'Makes sure the user has entered a value for the Forename
If forenametxt.Text = "" And txtAL1.Text = "" Then
MsgBox("Forename Must be entered", vbCritical, "Error")
End If

'Makes Sure the user enters a value for the Surname
If txtSurname.Text = "" Then
MsgBox("Surname Must Be Entered", vbCritical, "Error")
End If

'Makes Sure the user enters a value for the First Address Line
If txtAL1.Text = "" Then
MsgBox("Address Line 1 Must Be enetered", vbCritical, "Error")
End If

'Because there is no need for a Second Address Line No error message needed, but a dash is inputted
'If txtAL2.Text = "" Then

'End If

'Makes Sure the user enters a value for the Town
If txtTown.Text = "" Then
MsgBox("Town Name Must Be Entered", vbCritical, "Error")
End If

'Makes Sure the user enters a value for the City
If txtCity.Text = "" Then
MsgBox("City Name Must Be Entered", vbCritical, "Error")
End If

'Makes Sure the user enters a value for the County
If txtCounty.Text = "" Then
MsgBox("County Name Must Be Entered", vbCritical, "Error")
End If

'Makes Sure the user enters a value for the PostCode
If txtPostcode.Text = "" Then
MsgBox("Post Code Must Be Entered", vbCritical, "Error")
End If

'Makes Sure the user enters a value for Email
If txt_Email.Text = "" Then
MsgBox("Email Address Must Be Entered", vbCritical, "Error")
End If

'Makes Sure the user enters a value for a Home Telephone Number
If txt_HomeTel.Text = "" Then
MsgBox("Home telephone Number Must Be Entered", vbCritical, "Error")
End If

'Makes Sure the user enters a value for a Mobile Number
If txtTown.Text = "" Then
MsgBox("Mobile Number Must Be Entered", vbCritical, "Error")
End If


BindingContext(_APDatabase_2_DataSet1, "Customers").EndCurrentEdit()
Customers.DataSet.SaveCustomers(_APDatabase_2_DataSet1)

This article has been dead for over six months. Start a new discussion instead.