2 zry112233 zry112233 于 2014.04.04 13:13 提问

VB.NET中向access数据库中添加数据,,,为什么总是添加失败?

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Try

        Dim myConn As OleDbConnection = New OleDbConnection()

        myConn.ConnectionString = ConnString

        myConn.Open()

        Dim strInsert As String = "insert into Table1  (时间,温度,入射功率,反射功率 ) values('" + Label1.Text + "','" + Label2.Text + "','" + Label3.Text + "','" + Label4.Text + "')"

        Dim cmdInsert As OleDbCommand = New OleDbCommand(strInsert, myConn)

        cmdInsert.ExecuteNonQuery()

        MsgBox("添加成功!")

    Catch ex As Exception

        MsgBox("添加失败")

    End Try

End Sub

End Class

Csdn user default icon
上传中...
上传图片
插入图片
准确详细的回答,更有利于被提问者采纳,从而获得C币。复制、灌水、广告等回答会被删除,是时候展现真正的技术了!