Click here to Skip to main content
15,887,328 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi all , in my vb6 project i have a button that adds new row to ms access database from textboxes
, One of the fields is with date data type . i tried this code but it does not work
VB
Adodc1.Recordset.AddNew
Adodc1.Recordset(0).Value = val(text1.text)
Adodc1.Recordset(1).Value = text2.text
Adodc1.Recordset(2).Value = val(text3.text)
Adodc1.Recordset(3).Value = "# " & Text4.Text & "#"       ' this to send date to specified cell in a field

Adodc1.Refresh
DataGrid1.Refresh


if any body have this solution , so help me :) and thanks
Posted
Comments
j snooze 12-May-14 17:32pm    
I see a space between the first # sign and your date textbox. Are you sure its the date, what is the error?
Hamdi Choban 12-May-14 18:06pm    
the error was .the date can not be saved to database and the error msg from vb was "multiple step generated error"
[no name] 12-May-14 17:36pm    
"does not work" tells us nothing about what you see on your screen or what errors you get.
Hamdi Choban 12-May-14 18:07pm    
i see error message like that "multiple step generated error"

I assume that you know how to add reference to MS ActiveX Database Objects x.x libary[^].

To add data to MS Access database, you need to create ADODB.Connection[^]. Next, you need to create ADODB.Command[^] with this sql statement:
SQL
INSERT INTO <TableName> (NumericField, TextField, DateField)
VALUES (1, 'SomeText', #yyyy/MM/dd#)

Finally, you need to call Execute Method[^].

Note: Connection string[^] depends of MS Access database version (*.mdb or *.accdb).
 
Share this answer
 
Comments
Hamdi Choban 12-May-14 18:14pm    
thanks Maciej Los :)
i found my error , it was wrong to send date from vb6 to database with two # [in begin and end] in case if used adodc1.recordset.addnew Method .... But we should add # to begin and end of the date if we used the method of sql query .. thanks for you all for you comments and Answers :)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900