Hi this is my first time using this site, so please bare with me. I'm also pretty new at coding and got thrown into connecting to a database in one of my classes. But anywho, I keep receiving a syntax error and I was wondering if anyone could help me figure out why. Thank you!
Imports System.Data
Imports System.Data.SqlClient
Public Class PatientForm1
Dim con As New SqlClient.SqlConnection("deleted for privacy")
Private Sub TextBox1_TextChanged(sender As Object, e As EventArgs) Handles lname.TextChanged
End Sub
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
End Sub
Private Sub Label14_Click(sender As Object, e As EventArgs) Handles Label14.Click
End Sub
Private Sub Label10_Click(sender As Object, e As EventArgs) Handles Label10.Click
End Sub
Private Sub TextBox12_TextChanged(sender As Object, e As EventArgs) Handles TextBox12.TextChanged
End Sub
Private Sub TextBox20_TextChanged(sender As Object, e As EventArgs) Handles TextBox20.TextChanged
End Sub
Private Sub Label1_Click(sender As Object, e As EventArgs) Handles Label1.Click
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles bn1.Click
con.Open()
Dim query As New SqlCommand(("INSERT INTO Table VALUES ('" & PatientID.Text & "', '" & fname.Text & "'," & lname.Text & "')"), con)
'Dim mycommand As New SqlCommand(query, con)
If query.ExecuteNonQuery() Then
MessageBox.Show("Patient Added")
Else
MessageBox.Show("Error patient wasn't added.")
End If
con.Close()
'EditAdd.Show()
'Me.Close()
End Sub
Private Sub Label21_Click(sender As Object, e As EventArgs) Handles Label21.Click
End Sub
Private Sub TextBox3_TextChanged(sender As Object, e As EventArgs) Handles fname.TextChanged
End Sub
Private Sub bn2_Click(sender As Object, e As EventArgs) Handles bn2.Click
Me.Close()
EditAdd.Show()
End Sub
Private Sub Label3_Click(sender As Object, e As EventArgs) Handles Label3.Click
End Sub
End Class