Error: Data type mismatch in criteria expression.
Code:
vb Code:
With frmMainMenu Dim SLen As Integer = Len(.lblCourse.Text) SLen = SLen - 8 Dim BirthDate As String Dim GenderChk As String BirthDate = .txtMonth.Text & "/" & .txtDay.Text & "/" & .txtYear.Text If .rbMale.Checked = True Then GenderChk = "Male" ElseIf .rbFemale.Checked = True Then GenderChk = "Female" End If SQL = "INSERT INTO Course_" & .lblCourse.Text.ToCharArray(8, SLen) & " (LastName, FirstName, Gender, HomeRoom, StudentNumber, BirthDate, PhoneNumber, StudentEmail, ParentsEmail) VALUES('" & .txtLastName.Text & "','" & .txtFirstName.Text & "','" & GenderChk.ToString() & "','" & .txtHomeRoom.Text & "','" & .txtStudentNumber.Text & "','" & BirthDate.ToString() & "','" & .txtPhoneNumber.Text & "','" & .txtEmail.Text & "','" & .txtParentsEmail.Text & "')" Command = New OleDbCommand(SQL, Connection) Command.Connection.Open() Command.ExecuteReader() Command.Connection.Close() End With
Mainly This Part:
vb Code:
SQL = "INSERT INTO Course_" & .lblCourse.Text.ToCharArray(8, SLen) & " (LastName, FirstName, Gender, HomeRoom, StudentNumber, BirthDate, PhoneNumber, StudentEmail, ParentsEmail) VALUES('" & .txtLastName.Text & "','" & .txtFirstName.Text & "','" & GenderChk.ToString() & "','" & .txtHomeRoom.Text & "','" & .txtStudentNumber.Text & "','" & BirthDate.ToString() & "','" & .txtPhoneNumber.Text & "','" & .txtEmail.Text & "','" & .txtParentsEmail.Text & "')"
I usedvb Code:
.lblCourse.Text.ToCharArray(8, SLen)
Because I wanted to get the text that appeared after a certain piece of text which then defines the table I'm in.
If I can't use .ToCharArray, what can I do to split the text into 2, and use the last half?




Reply With Quote