hie if you could help me out i'll be forever grateful!!
okay i am creating an ordering system but when i try to add a new customer it allos me to add but it doesnt save to the database and i can not also call it up the code i have is:
Private Sub frmAddCustomer_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
' Purpose: Add new Customer record and assign its default values
' Clear the tables in the DataSet ready for a new record to be added
'dtasetAmway.Tables("OrderDeatils").Clear()
dtasetAmway.Tables("Customer").Clear()
' Add a new record to Customer table
dtasetAmway.Tables("Customer").Rows.Add(Nothing, Nothing, Nothing, Nothing, Nothing, Nothing)
' Make this the current row
currentrowno = 0
' Update the Customer table in the database so the CustomerNo gets allocated by SQL Server
dtaadpCustomer.Update(dtasetAmway, "Customer")
' Retrieve the record just added to the Customer table in the database so user can see CustomerNo
' Create query to retrieve required record: the record with highest CustomerNo
dtaadpCustomer.SelectCommand.CommandText = "SELECT TOP 1 * FROM Customer ORDER BY CustomerNo DESC"
' Empty the Customer table in the DataSet so that the Customer record can be retrieved from the database
dtasetAmway.Tables("Customer").Clear()
' Execute the SqlCommand to fill a table called Customer in the DataSet
dtaadpCustomer.Fill(dtasetAmway, "Customer")
' Make a note that user is adding a record
AddRecord = True
'View CustomerNo in textbox
txtCustomerNo.Text = dtasetAmway.Tables("Customer").Rows(currentrowno).Item("CustomerNo")
'Make txtCustomer Read Only so that it can not be changed
txtCustomerNo.ReadOnly = True
End Sub
Save:
Private Sub btnSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSave.Click
' Purpose: Save the changes made to the Customer record on the screen
' Check if compulsory fields don't contain data, show error message and place cursor back in field
If txtFirstName.Text = "" Then
MessageBox.Show("First Name must be filled in.", "Save Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
txtFirstName.Focus()
ElseIf txtSurname.Text = "" Then
MessageBox.Show("Surname must be filled in.", "Save Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
txtSurname.Focus()
ElseIf txtDOB.Text = "" Then
MessageBox.Show("D.O.B. must be filled in.", "Save Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
txtDOB.Focus()
ElseIf txtAddress.Text = "" Then
MessageBox.Show("Address must be filled in.", "Save Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
txtAddress.Focus()
ElseIf txtTelephone.Text = "" Then
MessageBox.Show("Telephone must be filled in.", "Save Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
txtTelephone.Focus()
Else
' Purpose: Save the changes made to the Customer record on the screen
' Copy the data from the screen into the DataSet
dtasetAmway.Tables("Customer").Rows(currentrowno)("FirstName") = txtFirstName.Text
dtasetAmway.Tables("Customer").Rows(currentrowno)("Surname") = txtSurname.Text
dtasetAmway.Tables("Customer").Rows(currentrowno)("DOB") = txtDOB.Text
dtasetAmway.Tables("Customer").Rows(currentrowno)("Address") = txtAddress.Text
dtasetAmway.Tables("Customer").Rows(currentrowno)("TelephoneNo") = txtTelephone.Text
' Update the Account table in the database
dtaadpCustomer.Update(dtasetAmway, "Customer")
MessageBox.Show("The updates have been saved to disk.", "Save Updates", MessageBoxButtons.OK, MessageBoxIcon.Information)
'close form and open Menu
Me.Hide()
frmMenu.Show()
End If
End Sub
thanks in advance