M
muhammadanzar
Guest
HI
METHOD 1
Private Sub addData()
Dim connection As New SqlConnection("Data Source=.\SQLExpress;Initial Catalog=k1;Integrated Security=True")
Try
Dim command As New SqlCommand("insert into area (AreaName) values('" & area_name_textbox.Text & "')", connection)
connection.Open()
command.ExecuteNonQuery()
Catch ex As Exception
MsgBox(ex.Message)
Finally
connection.Close()
End Try
End Sub
METHOD 2
PRIVATE SUB ADDDATA
Try
Dim connection As New SqlConnection("Data Source=.\SQLExpress;Initial Catalog=k1;Integrated Security=True")
Dim command As New SqlCommand("insert into (AreaName) values(@AreaName)", connection)
Command.Parameters.Add("@AreaName", SqlDbType.VARCHAR).Value = area_name_textbox.Text
connection.Open()
command.ExecuteNonQuery()
Catch ex As Exception
MsgBox(ex.Message)
Finally
connection.Close()
End Try
END SUB
MUHAMMAD ANZAR E-mail : muhammadanzar@hotmail.com Mobile # :0092-3215096959
Continue reading...
METHOD 1
Private Sub addData()
Dim connection As New SqlConnection("Data Source=.\SQLExpress;Initial Catalog=k1;Integrated Security=True")
Try
Dim command As New SqlCommand("insert into area (AreaName) values('" & area_name_textbox.Text & "')", connection)
connection.Open()
command.ExecuteNonQuery()
Catch ex As Exception
MsgBox(ex.Message)
Finally
connection.Close()
End Try
End Sub
METHOD 2
PRIVATE SUB ADDDATA
Try
Dim connection As New SqlConnection("Data Source=.\SQLExpress;Initial Catalog=k1;Integrated Security=True")
Dim command As New SqlCommand("insert into (AreaName) values(@AreaName)", connection)
Command.Parameters.Add("@AreaName", SqlDbType.VARCHAR).Value = area_name_textbox.Text
connection.Open()
command.ExecuteNonQuery()
Catch ex As Exception
MsgBox(ex.Message)
Finally
connection.Close()
End Try
END SUB
MUHAMMAD ANZAR E-mail : muhammadanzar@hotmail.com Mobile # :0092-3215096959
Continue reading...