刚刚学用vs2008,在把数据添加到临时表格mtable中后,要改变格式插入到SQL2005数据库中,以下是代码:不知道哪里出了问题,就是不能导入SQL2005数据库
Dim mtable As DataTable = myDataset.Tables(0)
Dim txt1 As String
Dim i As Integer = 0
Dim mrow As DataRow = mtable.NewRow
If TextBox12.Text = "" Then TextBox11.Text = VB6.Format(Now, "yyyymm") & "0001"
Try
For Each mrow In mtable.Rows
mrow = mtable.Rows(i)'————取得当前单元格的行
TextBox11.Text = VB6.Format(Now, "yyyymm") & VB6.Format(Microsoft.VisualBasic.Right((TextBox11.Text), 4) + 1, "0000")
txt1 = "insert into ldtcb (ID,data,text1,text2,thr1,thr2,text3,text4,thr3,text5,thr4,cj2,sj2,cj3,sj3,cj4,sj4,sd) values ('" & TextBox11.Text & "','" _
& mtable.Columns(9).ReadOnly & " ','" & Microsoft.VisualBasic.Left(mtable.Columns(0).ReadOnly, 3) & "','" & Microsoft.VisualBasic.Right(mtable.Columns(0).ReadOnly, 2) & "','" & mtable.Columns(1).ReadOnly & "','" & mtable.Columns(12).ReadOnly & "','" _
& mtable.Columns(14).ReadOnly & "','" & mtable.Columns(13).ReadOnly & "','" & mtable.Columns(11).ReadOnly & "','" & mtable.Columns(15).ReadOnly & "','" & mtable.Columns(10).ReadOnly & "','" & mtable.Columns(3).ReadOnly & "','" _
& mtable.Columns(4).ReadOnly & "','" & mtable.Columns(5).ReadOnly & "','" & mtable.Columns(6).ReadOnly & "','" & mtable.Columns(7).ReadOnly & "','" & mtable.Columns(8).ReadOnly & "','" & mtable.Columns(2).ReadOnly & "')"
InDelRecord(txt1)'执行插入
i = i + 1
Label21.Text = "正在导入……" & i / mtable.Rows.Count * 100 & "%"
Next
txt5 = "select * from ldtcb where wc like 0"
txt4 = "select * from ldtcb where wc like 0 and cj3<>'' or cj4<>'' or sj4<>'' or sj3<>''"
xbwsx()'执行刷新
xbwqk()'执行变化
MessageBox.Show("您的操作已经成功地执行!", "恭喜!", MessageBoxButtons.OK, MessageBoxIcon.Information)
Me.Cursor = Cursors.Default
PictureBox1.Visible = False
Label21.Visible = False
Me.Enabled = True
Catch
Me.Enabled = True
MessageBox.Show(Err.Description, "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning)
Exit Sub
End Try