我的sql异常未处理,列名无效? 这里是代码,请告诉我我在哪里做错了? 我尝试了很多次,我无法找到错误? 那怎么能改变错误呢 你能帮帮我..
我是初学者。 提前谢谢你Private Sub ProductBindingNavigatorSaveItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ProductBindingNavigatorSaveItem.Click
Me.Validate()
Me.ProductBindingSource.EndEdit()
Me.TableAdapterManager.UpdateAll(Me.InvoiceDataSet)
End Sub
Private Sub Product_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'TODO: This line of code loads data into the 'InvoiceDataSet1.Product' table. You can move, or remove it, as needed.
Me.ProductTableAdapter1.Fill(Me.InvoiceDataSet1.Product)
'TODO: This line of code loads data into the 'InvoiceDataSet.Product' table. You can move, or remove it, as needed.
Me.ProductTableAdapter.Fill(Me.InvoiceDataSet.Product)
cmd.Connection = cs
End Sub
Private Sub FillByCodeToolStripButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles FillByCodeToolStripButton.Click
Try
Me.ProductTableAdapter.FillByCode(Me.InvoiceDataSet.Product, Code_SKUToolStripTextBox.Text)
Catch ex As System.Exception
System.Windows.Forms.MessageBox.Show(ex.Message)
End Try
End Sub
Private Sub btnNew_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnNew.Click
ProductBindingSource.AddNew()
Code___SKUTextBox.Focus()
End Sub
Private Sub btnModify_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnModify.Click
ProductBindingSource.ResetCurrentItem()
End Sub
Private Sub btnDelete_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDelete.Click
ProductBindingSource.RemoveCurrent()
End Sub
Private Sub btnSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSave.Click
Try
Me.Validate()
Me.ProductBindingSource.EndEdit()
Me.TableAdapterManager.UpdateAll(Me.InvoiceDataSet)
MsgBox("One Record is added to PRODUCT as " & Code___SKUTextBox.Text)
Catch ex As Exception
System.Windows.Forms.MessageBox.Show(ex.Message)
End Try
End Sub
Private Sub btnSearch_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSearch.Click
Try
Me.ProductTableAdapter.FillByCode(Me.InvoiceDataSet.Product, txtSearch.Text)
Catch ex As System.Exception
System.Windows.Forms.MessageBox.Show(ex.Message)
End Try
End Sub
Private Sub btnSelect_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSelect.Click
OpenFileDialog1.ShowDialog()
txtSelect.Text = OpenFileDialog1.FileName
Product_PicturePictureBox.Image = Image.FromFile(txtSelect.Text)
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If Code___SKUTextBox.Text <> "" And Product_Name___DescTextBox.Text <> "" And Product_priceTextBox.Text <> "" And Price_Disc___TextBox.Text <> "" And Product_Tax___TextBox.Text <> "" Then
cs.Open()
Dim sql = "INSERT INTO Product(Code___SKU, Product_Name___Desc, Product_price, Price_Disc___, Product_Tax___)VALUES(@Code___SKU, @Product_Name___Desc, @Product_price, @Price_Disc___, @Product_Tax___)"
Using cs = New SqlConnection("Data Source=.\SQLEXPRESS;AttachDbFilename=C:\Invoice\Invoice.mdf;Integrated Security=True;User Instance=True")
Using cmd = New SqlCommand(sql, cs)
cmd.Parameters.AddWithValue("@Code___SKU", Code___SKUTextBox.Text)
cmd.Parameters.AddWithValue("@Product_Name___Desc", Product_Name___DescTextBox.Text)
cmd.Parameters.AddWithValue("@Product_price", Int32.Parse(Product_priceTextBox.Text))
cmd.Parameters.AddWithValue("@Price_Disc___", Int32.Parse(Price_Disc___TextBox.Text))
cmd.Parameters.AddWithValue("@Product_Tax___", Int32.Parse(Product_Tax___TextBox.Text))
cs.Open()
cmd.ExecuteNonQuery()
End Using
End Using
End If
End Sub
End Class