Private Sub SaveToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SaveToolStripMenuItem.Click Dim Con As New SqlConnection Con.ConnectionString = "Data Source=12.18.1.77;Initial Catalog=ACC_FG;User ID=sa;Password=***********" Dim cmd As New SqlCommand Dim status As String Dim ra As Integer If (RadioButton1.Checked) Then status = "title" ElseIf (RadioButton2.Checked) Then status = "regular" Else status = "" End If Dim cost As String If (CheckEdit1.Checked) Then cost = "Branches" ElseIf (CheckEdit2.Checked) Then cost = "Departments" ElseIf (CheckEdit3.Checked) Then cost = "projects" ElseIf (CheckEdit4.Checked) Then cost = "cost centres" Else cost = "" End If Try Con.Open() cmd.Connection = Con cmd = New SqlCommand("insert into Accounts values ('" & TextEdit1.Text & "','" & TextEdit2.Text & "','" & TextEdit3.Text & "','" & TextEdit4.Text & "','" & TextEdit5.Text & "','" & TextEdit6.Text & "','" & TextEdit7.Text & "','" & status & "','" & LookUpEdit1.Text & "','" & LookUpEdit2.Text & "','" & cost & "')", Con) ra = cmd.ExecuteNonQuery() Con.Close() MsgBox("CATEGORY ADDED", MsgBoxStyle.Information, "RECORD ADDED=" & ra) Catch ex As Exception MsgBox("not added", MsgBoxStyle.Critical) End Try
INSERT INTO TableName (Field1, Field2, Field3) VALUES('Value1', Value2, 'Value3')
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)