Datagridview & textbox中内容插入到数据库
各位大虾,请问怎么将DataGridView中内容与若干个textbox中内容一起插入到sql 数据库某表中呢?以下这些代码提示 "要定义为new实例" 搞不懂什么问题.....
For x = 0 To row1 - 1
Gdata1 = Trim(DataGridView1.Rows(x).Cells(0).Value.ToString)
Gdata2 = Trim(DataGridView1.Rows(x).Cells(1).Value.ToString)
Gdata3 = Trim(DataGridView1.Rows(x).Cells(2).Value.ToString)
Gdata4 = Trim(DataGridView1.Rows(x).Cells(3).Value.ToString)
Gdata5 = Trim(DataGridView1.Rows(x).Cells(4).Value.ToString)
Gdata6 = Trim(DataGridView1.Rows(x).Cells(5).Value.ToString)
Gdata7 = Trim(DataGridView1.Rows(x).Cells(6).Value.ToString)
Gdata8 = Trim(DataGridView1.Rows(x).Cells(7).Value.ToString)
str1 = "insert into xhpsve(單號,編號,名稱,品牌,顔色,規格,單位,數量,金額,申請人編號,申請人姓名,部門,公司,作成日期,批准人編號,批准人姓名,批准日期,備註,批准人編號1,批准人姓名1,批准日期1,備註1,批准人編號2,批准人姓名2,批准日期2,備註2,文件狀況)values('" & Label20.Text & "','" & Gdata1 & "','" & Gdata2 & "','" & Gdata3 & "','" & Gdata4 & "','" & Gdata5 & "','" & Gdata6 & "','" & Gdata7 & "','" & Gdata8 & "','" & buse4 & "','" & buse3 & "','" & Label3.Text & "','" & buse2 & "','" & Label7.Text & "','" & bh1 & "','" & ComboBox1.Text & "','" & Label13.Text & "','" & TextBox1.Text & "','" & bh2 & "','" & ComboBox2.Text & "','" & Label11.Text & "','" & TextBox2.Text & "','" & bh3 & "','" & ComboBox3.Text & "','" & Label18.Text & "','" & TextBox3.Text & "','" & ComboBox4.Text & "') "
comm.Connection = conn
= CommandType.Text
= str1
Dim da1 As New SqlDataAdapter(str1, conn)
da1.SelectCommand = comm
da1.Fill(ds)
Next