我正在尝试从列表框中插入选定的值,并且该值是sql server中的System.Data.DataRowView,我对此vb有点陌生。你能帮我吗... 为什么呢?
Imports System.Data
Imports System.Data.SqlClient
Public Class Form1
Dim con As New SqlConnection
Dim cmd As New SqlCommand
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
'TODO: This line of code loads data into the 'AccountsC20DataSet.ProductMast' table. You can move, or remove it, as needed.
Me.ProductMastTableAdapter.Fill(Me.AccountsC20DataSet.ProductMast)
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles SAVE.Click
Try
con.ConnectionString = "Data Source = OMAR;Initial Catalog=AccountsC20;Persist Security Info=True;User ID=ofamo;Password="
con.Open()
cmd.Connection = con
Dim Selected = ListBox1.SelectedValue.ToString()
cmd.CommandText = "Insert into SInvoice Values('" + Selected + "',0,1,1,1.000000,0.000000,'04/04/2019 08:45:08',0.000000,0.000000,'',0,1,1,1,1,'04/04/2019 08:45:08','',1.000000,1,0,'','b',0.000000,5,0.000000,0.000000,'Nos',1.000000,'','','','','','','','','','','','','','','','','','','','','',0,3,'SIV-',1,1,1,1,1,1,0.000000)"
cmd.ExecuteNonQuery()
Catch ex As Exception
MessageBox.Show("Error while inserting record on table..." & ex.Message, "Insert Records")
Finally
con.Close()
End Try
End Sub
Private Sub ListBox1_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ListBox1.SelectedIndexChanged
End Sub
End Class
我在这里做错了.....