I have tried using the following it saves the data but the data is not visible in database i have attached the Screen SHot of the database below. i am pasting my code below. Kindly help me out as m not getting what to do further.
Private Sub cmdSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdSave.Click
Dim comd As SqlCommand = con.CreateCommand()
If txtPONumber.Text <> " " Then
Try
con.ConnectionString = obj.getconnectionstring
con.Open()
comd.Connection = con
comd.CommandText = "Insert into PurchaseOrder(PoNumber,PoDate,PoCompanyName,PoSiteName,PoContactNumber,ItemNumber,itemName,Quantity,Rate,TotalAmount,GrossAmount,Discount,tax,FinalAmount) values('" & txtPONumber.Text & "','" & lblDatetime.Text & "','" & cbxCompanyName.Text & "','" & txtSiteName.Text & "','" & txtContact.Text & "',@ItemNum,@ItemNam,@Qty,@Rte,@TotalAmt,'" & txtGrossAmount.Text & "','" & txtDiscount.Text & "','" & txtTax.Text & "','" & txtFinalAmount.Text & "')"
'Adding Parameters
comd.Parameters.Add("@ItemNum", SqlDbType.VarChar, 50)
comd.Parameters.Add("@ItemNam", SqlDbType.VarChar, 50)
comd.Parameters.Add("@Qty", SqlDbType.VarChar, 50)
comd.Parameters.Add("@Rte", SqlDbType.VarChar, 50)
comd.Parameters.Add("@TotalAmt", SqlDbType.VarChar, 50)
comd.Prepare()
'Data Inserted
For Each row As DataGridViewRow In DGVPO.Rows
If Not row.IsNewRow Then
comd.Parameters("@ItemNum").Value = row.Cells(0).Value.ToString
comd.Parameters("@ItemNam").Value = row.Cells(1).ToString
comd.Parameters("@Qty").Value = row.Cells(2).ToString
comd.Parameters("@Rte").Value = row.Cells(3).ToString
comd.Parameters("@TotalAmt").Value = row.Cells(4).ToString
End If
Next
comd.ExecuteNonQuery()
MessageBox.Show("Data Inserted")
Catch ex As Exception
MessageBox.Show("Error :" & ex.ToString())
Finally
con.Close()
End Try
Else
MessageBox.Show("Enter PoNumber")
End If
End Sub