Private Sub btnInsert_Click(sender As System.Object, e As System.EventArgs) Handles btnInsert.Click
Dim con As New OleDbConnection
Dim cmd As New OleDbCommand
Dim dr As OleDbDataReader
Dim Pnum As Integer
Dim InDate As Date
Dim PDate As Date
Dim Amount As Integer
Dim CmpID As Integer
Dim Tax As Integer
Dim TaxAmt As Integer
Dim Innumber As Integer
Dim Totamt As Integer
Dim Qty As Integer
con = New OleDbConnection("Provider=Microsoft.ace.Oledb.12.0;Data Source= C:\Users\Lenovo\Documents\Visual Studio 2010\Soft\Database\Login.accdb")
con.Open()
If txtamt.Text = "" And txtID.Text = "" And txtqty.Text = "" And txtinvoiceno.Text = "" And txtno.Text = "" And txttax.Text = "" And txttaxamt.Text = "" And txttotamt.Text = "" Then
MessageBox.Show(" Enter All The Feilds", "Done", MessageBoxButtons.OK, MessageBoxIcon.Information)
Else
Pnum = Convert.ToInt32(txtno.Text)
InDate = DateTimePicker1.Text
PDate = DateTimePicker2.Text
Amount = Convert.ToInt32(txtamt.Text)
CmpID = Convert.ToInt32(txtID.Text)
Tax = Convert.ToInt32(txttax.Text)
TaxAmt = Convert.ToInt32(txttaxamt.Text)
Innumber = Convert.ToInt32(txtinvoiceno.Text)
Totamt = Convert.ToInt32(txtamt.Text)
Qty = txtqty.Text
cmd = New OleDbCommand("INSERT INTO Purchase1 VALUES( '" & Pnum & "', '" & InDate & "', '" & PDate & "', '" & Amount & "','" & CmpName & "','" & Tax & "'," & CmpID & ", '" & TaxAmt & "', '" & Innumber & "', '" & Totamt & "', '" & Qty & "')", con)
cmd.ExecuteNonQuery()
MessageBox.Show("Added successfully", "Done", MessageBoxButtons.OK, MessageBoxIcon.Information)
End If
cmd = New OleDbCommand("Select * from Purchase1", con)
dr = cmd.ExecuteReader()
Dim dt As New DataTable("Purchase1")
dt.Load(dr)
DataGridView1.DataSource = dt
End Sub
End Class
Can any one telll me why Am I getting the error (Operator '&' is not defined for types 'String' and 'System.Windows.Forms.Label' ) in the above code.