I am new to Vb.net and I'me trying to store data to the sql databse using text fields. Everything seems ok but i've tried several connection strings but they wont work.Could somebody give a hand, please?
Private Sub btnSubmit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSubmit.Click
Dim conn As New SqlClient.SqlConnection()
Dim cmd As New SqlClient.SqlCommand()
conn.ConnectionString = "Data Source=(local);Initial Catalog=myDatabase;Integrated Security=SSPI"
conn.Open()
cmd.Connection = conn
With cmd.Parameters
.Add(New SqlClient.SqlParameter("@Student_id", TextBox1.Text))
.Add(New SqlClient.SqlParameter("@FirstName", TextBox1.Text))
.Add(New SqlClient.SqlParameter("@LastName", TextBox2.Text))
.Add(New SqlClient.SqlParameter("@Email", TextBox3.Text))
.Add(New SqlClient.SqlParameter("@Module", TextBox1.Text))
End With
cmd.CommandText = "INSERT INTO <Students> (<field1>,<field2>,<field3>,<field4>,<field5>) VALUES (@Student_id, @FirstName, @LastName, @Email, @Module)"
Progress.Show()
End Sub