Hello
I have this to ponder over...
Private Sub btnOK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOK.Click
Dim sFN As String
Dim sLN As String
Dim sJT As String
Dim sUN As String
Dim sPW As String
sFN = txtFirstName.Text.ToString
sLN = txtLastName.Text.ToString
sJT = txtJobTitle.Text.ToString
sUN = txtUserName.Text.ToString
sPW = txtPassword.Text.ToString
Const sConnection As String = "Provider=SQLOLEDB.1;Persist Security Info=False;User ID=sa;Initial Catalog=HelpdeskApp;Data Source=MARK"
Dim objConn As New System.Data.OleDb.OleDbConnection(sConnection)
objConn.Open()
Dim sSQL As String
Dim objCmd As New System.Data.OleDb.OleDbCommand(sSQL, objConn)
sSQL = "INSERT INTO STAFF (First Name, Last Name, Job Title, Username, Password, StaffID) VALUES (sFN, sLN, sJT, sUN, sPW, 1)"
Try
objCmd.ExecuteNonQuery()
Catch myException As System.Exception
Console.WriteLine(myException.Message)
End Try
txtFirstName.Text = ""
txtLastName.Text = ""
txtJobTitle.Text = ""
txtUserName.Text = ""
txtPassword.Text = ""
txtConfirmPassword.Text = ""
End Sub
The txtXxX are the names of the text boxes on the form, the extra 1 on the INSERT is for testing (it fills the Primary Key field). It appears to work, without any errors and clears the form afterwards but no data appears in the table on the SQL server???????
I have this to ponder over...
Private Sub btnOK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOK.Click
Dim sFN As String
Dim sLN As String
Dim sJT As String
Dim sUN As String
Dim sPW As String
sFN = txtFirstName.Text.ToString
sLN = txtLastName.Text.ToString
sJT = txtJobTitle.Text.ToString
sUN = txtUserName.Text.ToString
sPW = txtPassword.Text.ToString
Const sConnection As String = "Provider=SQLOLEDB.1;Persist Security Info=False;User ID=sa;Initial Catalog=HelpdeskApp;Data Source=MARK"
Dim objConn As New System.Data.OleDb.OleDbConnection(sConnection)
objConn.Open()
Dim sSQL As String
Dim objCmd As New System.Data.OleDb.OleDbCommand(sSQL, objConn)
sSQL = "INSERT INTO STAFF (First Name, Last Name, Job Title, Username, Password, StaffID) VALUES (sFN, sLN, sJT, sUN, sPW, 1)"
Try
objCmd.ExecuteNonQuery()
Catch myException As System.Exception
Console.WriteLine(myException.Message)
End Try
txtFirstName.Text = ""
txtLastName.Text = ""
txtJobTitle.Text = ""
txtUserName.Text = ""
txtPassword.Text = ""
txtConfirmPassword.Text = ""
End Sub
The txtXxX are the names of the text boxes on the form, the extra 1 on the INSERT is for testing (it fills the Primary Key field). It appears to work, without any errors and clears the form afterwards but no data appears in the table on the SQL server???????