【发布时间】:2014-05-07 16:36:07
【问题描述】:
您好,我正在使用 SQL Server 和 VB 6 做一个项目
我的项目在图书馆,最准确地说是在我的租赁表格上。 RENT AND DUE DATE 的日期没有保存在我的数据库中
它显示在列表视图中,但在我的表格中保存为 1/1/1900。
我已经多次更改数据类型,但仍然没有保存在我的数据库中。
代码:
Private Sub Form_Load()
txtRent_Date.Text = Format(Now, "MM/ dd/ yyyy")
txtDue_Date.Text = Format(Now, "MM/ dd/ yyyy")
End Sub
Private Sub Command1_Click()
If Len(dcbBook.Text) = 0 Then
MsgBox "Select a book First", vbOKOnly + vbInformation, "Alert"
Else
' Save to Rental
With Adodc1.Recordset
.AddNew
.Fields("Customer_id") = dcbCustomer.BoundText
.Update
End With
' End Saving
txtID.Text = Adodc1.Recordset.Fields("Rental_id").Value
' Save to Rental Copies
For X = 0 To ListView1.ListItems.Count - 1
Set CN = New ADODB.Connection
CN.CursorLocation = adUseClient
CN.ConnectionString = "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=Library;Data Source=SOUMEIYA-MSI\SQLEXPRESS"
CN.Open
strsql = "INSERT INTO Rental_Copies(Rental_id,Copies_id,Rent_Date,Due_Date)Values(" & txtID.Text & "," & ListView1.ListItems(X + 1) & "," & txtRent_Date.Text & "," & txtDue_Date.Text & ")"
Set rs = CN.Execute(strsql)
Next
MsgBox "Book Rented successfully !", vbOKOnly + vbInformation, "Save"
End If
End Sub
【问题讨论】:
-
Rent_Date是日期列还是文本? -
stackoverflow.com/questions/23482709/… 几天前我为另一个用户回答了这个问题。这是学校作业吗?
标签: sql-server tsql vb6