Imports
System.Data.SqlClient
Imports
System.Data
Public
Class income
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim con As New SqlConnection
Dim cmd As New SqlCommand
Try
con.ConnectionString =
"Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\Blue_Water.mdf;Integrated Security=True;Persist Security Info=True;User Instance=True"
con.Open()
'MessageBox.Show("Connection Success")
cmd.Connection = con
cmd.CommandText =
"INSERT INTO Owner_income(Shop_no, Jomidhari_vhara,Dukan_kisti, Dukan_vhara, Jamanot, Phone_sunjug_bill, Nam_transfer_fee) VALUES(@Shop_no, @Jomidhari_vhara,@Dukan_kisti,@Dukan_vhara,@Jamanot,@Phone_sunjug_bill,@Nam_transfer_fee)"
cmd.CommandType = CommandType.Text
cmd.Parameters.AddWithValue(
"@Shop_no", txtShop.Text)
cmd.Parameters.AddWithValue(
"@Jomidhari_vhara", txtJomidhari.Text)
cmd.Parameters.AddWithValue(
"@Dukan_kisti", txtDukankisti.Text)
cmd.Parameters.AddWithValue(
"@Dukan_vhara", txtDukanvhara.Text)
cmd.Parameters.AddWithValue(
"@Jamanot", txtJamanot.Text)
cmd.Parameters.AddWithValue(
"@Phone_sunjug_bill", txtPhone.Text)
cmd.Parameters.AddWithValue(
"@Nam_transfer_fee", txtNamtransfer.Text)
'cmd.Parameters.AddWithValue("@Date", ComboBox.
cmd.ExecuteNonQuery()
MessageBox.Show(
"Data Inserted Successfully")
Catch ex As Exception
MessageBox.Show(
"Error while connecting to SQL Server." & ex.Message)
Finally
con.Close()
'Whether there is error or not. Close the connection.
End Try
End Sub
End
Class