【发布时间】:2011-05-17 12:31:50
【问题描述】:
我正在尝试在 msaccess2003 mdb 文件中插入一条新记录,我的版本是 VB.net 2005,它没有显示任何错误,而且当我打开我的 access db 文件时,没有插入记录,以及我该如何格式化它给我的日期字段错误,我如何将 txtdate.text 转换为与 ms 访问兼容的日期
这里是代码
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
Dim ds As New DataSet
Dim db As New ClassDB
ds = db.FetchData("ricemill.mdb", "sales")
Dim anyRow As DataRow = ds.Tables(0).NewRow
Dim mydate As DateTime
Dim cmydate As String
cmydate = txtdate.Text
mydate = DateTime.Parse(mydate)
anyRow("description") = txtdesc.Text
anyRow("date") = DateTime.Parse(txtdate.Text)
anyRow("amount") = txtamount.Text
ds.Tables(0).Rows.Add(anyRow)
ds.Tables(0).AcceptChanges()
ds.AcceptChanges()
MsgBox("Record Added ! ")
End Sub
【问题讨论】: