Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: VB Oracle
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 29-Dec-12 0:40am
surkhi623
Edited 29-Dec-12 0:51am
v3

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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 at 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 at 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 at 29-Dec-12 7:26am
   
I am using microsoft activex data objects2.7 library from referenses.
Mika Wendelius at 29-Dec-12 7:30am
   
Have a try with the ADO date syntax if that helps...
Member 9687206 at 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 at 29-Dec-12 7:38am
   
5'ed!
Mika Wendelius at 29-Dec-12 7:54am
   
Thank you :D
Member 9687206 at 31-Dec-12 6:35am
   
That is also not working......
What should I do?
Mika Wendelius at 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
0 Marcin Kozub 330
1 OriginalGriff 256
2 Sergey Alexandrovich Kryukov 215
3 Praneet Nadkar 197
4 Richard MacCutchan 182
0 OriginalGriff 8,048
1 Sergey Alexandrovich Kryukov 7,287
2 DamithSL 5,614
3 Manas Bhardwaj 4,986
4 Maciej Los 4,910


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

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100