elianeasmar
Well-known member
- Joined
- Oct 3, 2013
- Messages
- 76
- Programming Experience
- Beginner
Hello everyone. I have been trying for a while to save records to sql.
i have created a database called SchoolDB. i hv the feild listed below in the table StudentInfo.
unfortunately i haven't succeeded. I tried many ways.
Here is one of them.
i have created a database called SchoolDB. i hv the feild listed below in the table StudentInfo.
unfortunately i haven't succeeded. I tried many ways.
Here is one of them.
Dim _cn As New SqlConnection
Dim _cnstring As String = "Data Source=ELIANE-VAIO\SQLEXPRESS;Initial Catalog=SchoolDB;Integrated Security=True;"
Dim _cn As New SqlConnection(_cnstring)
Dim cmd As New SqlCommand
'Try
_cn.Open()
cmd.Connection = _cn
cmd.CommandText = "INSERT INTO StudentInfo(VB.NET:, [Full-Name], [Position], [Title], [Phone-Number], [Address], [Date-Time]) VALUES('" & Form1.txtCode.Text & "', '" & Form1.txtName.Text & "', '" & Form1.cmbPosition.Text & "', '" & Form1.cmbTitle.Text & "','" & Form1.txtPhoneNumber.Text & "',' " & Form1.txtAddress.Text & "', '" & Form1.DateTimePicker1.Value & "');" cmd.ExecuteNonQuery() 'Catch ex As Exception ' MessageBox.Show("Error while inserting record on table...") 'Finally _cn.Close() 'End Try [/QUOTE] Can you help me please :/ Any help would be appreciated :)