Click here to Skip to main content
Sign Up to vote bad
good
See more: VBOracle
Private Sub AddRecord_Click()
RSSQL = "SELECT * FROM D"
ASSIGNRS.Open RSSQL, DB, adOpenDynamic, adLockOptimistic
ASSIGNRS.AddNew "DOB", "'" & Text1.Text & "'"
ASSIGNRS.Close
End Sub
 
This is the simple code for adding date fields into table D having only column DOB.
In table D,SQL accepts date as '01-JAN-99' format.So I set data_format property of combo1 as date:dd-MMM-yy
But still While running this code error occurred- Multiple-step operation generated error, check each status value.
Though both sided date formats are same then why it is not accepting addnew record?
Please help
Posted 28-Dec-12 23:40pm
surkhi619
Edited 28-Dec-12 23:51pm


1 solution

Try using TO_DATE function. So something like
ASSIGNRS.AddNew "DOB", "TO_DATE('" & Text1.Text & "', 'DDMMYYYY')"
In that example the text should be formatted like
26032011
  Permalink  
Comments
Member 9687206 - 29-Dec-12 6:39am
This code is also not working,same error occurred. SQL not taking any date field input,rather in SQL window records get added by writing query Insert into D values('12-dec-2012'); But it is not added through vb code. What should I do?
Mika Wendelius - 29-Dec-12 7:22am
What interface are you using ADO with VB6? if that's true I think both field list and the values should be arrays. Have a look at http://msdn.microsoft.com/en-us/library/windows/desktop/ms677536(v=vs.85).aspx[^] You could also try a different, ADO syntax for the date: #01/01/2011#
Member 9687206 - 29-Dec-12 7:26am
I am using microsoft activex data objects2.7 library from referenses.
Mika Wendelius - 29-Dec-12 7:30am
Have a try with the ADO date syntax if that helps...
Member 9687206 - 29-Dec-12 7:30am
Dim DB As New ADODB.Connection Dim ASSIGNRS As New ADODB.Recordset Private Sub OPENDB() DB.CursorLocation = adUseClient DB.Mode = adModeReadWrite If ASSIGNRS.State = 1 Then ASSIGNRS.Close DB.Open "Provider=OraOLEDB.Oracle.1;Password=aus123 ;Persist Security Info=True;User ID=aus ;Data Source=soft" End Sub Private Sub Combo1_Click() Dim ASSIGNRS As New ADODB.Recordset Dim RSSQL As String RSSQL = "SELECT *FROM D WHERE DOB='" & Combo1.Text & "'" Set ASSIGNRS = DB.Execute(RSSQL) End Sub Private Sub Command1_Click() RSSQL = "SELECT * FROM D where DOB='" & Combo1.Text & "'" ASSIGNRS.Open RSSQL, DB, adOpenDynamic, adLockOptimistic If Combo1.Text = Empty Then ASSIGNRS.AddNew "DOB", "TO_DATE('" & Text1.Text & "', 'DDMMMYYYY')" MsgBox ("RECORD ADDED") Else If Combo1.Text <> Empty Then ASSIGNRS.Update "DOB", "'" & Combo1.Text & "'" MsgBox ("RECORD INSERTED") End If End If ASSIGNRS.Close End Sub Private Sub Form_Load() OPENDB Dim ASSIGNRS As New ADODB.Recordset Dim RSSQL As String RSSQL = "SELECT * FROM D" ASSIGNRS.Open RSSQL, DB, adOpenDynamic, adLockOptimistic Set ASSIGNRS = DB.Execute(RSSQL) If ASSIGNRS.RecordCount > 0 Then ASSIGNRS.MoveFirst For I = 0 To ASSIGNRS.RecordCount - 1 Combo1.AddItem ASSIGNRS.Fields("DOB").Value ASSIGNRS.MoveNext Next End If End Sub This is my full code
Espen Harlinn - 29-Dec-12 7:38am
5'ed!
Mika Wendelius - 29-Dec-12 7:54am
Thank you :D
Member 9687206 - 31-Dec-12 6:35am
That is also not working...... What should I do?
Mika Wendelius - 6-Jan-13 11:13am
What is the error message you now get?

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

  Print Answers RSS
Your Filters
Interested
Ignored
     
0 Christian Graus 393
1 Michael Haephrati 390
2 Prasad_Kulkarni 390
3 OriginalGriff 320
4 CPallini 259
0 Sergey Alexandrovich Kryukov 6,824
1 Prasad_Kulkarni 3,671
2 _Amy 3,312
3 OriginalGriff 3,309
4 CPallini 2,925


Advertise | Privacy | Mobile
Web03 | 2.6.130617.1 | Last Updated 29 Dec 2012
Copyright © CodeProject, 1999-2013
All Rights Reserved. Terms of Use
Layout: fixed | fluid