Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Re: Validate date from VB to insert into Oracle table
Try somthing like this-
Dim sql as String
Oracon.Open ' assumed you have declaired and initiated Oracon with sid
etc
Set cmd = New ADODB.Command
Set cmd.ActiveConnection = Oracon
sql = "INSERT into mytable (mydate)" & "values ( to_date(" & "'" & Text1 & "'" & "," & "'" & "DD-MON-YYYY HH:MI:SS" & "') )"
Set rs = cmd.Execute
Auuming Text1 is your Date entered in VB application. Make sure VB date format matches with DD-MON-YYYY HH:MI:SS and you get your desired outcome.
Above source lines are just guide lines. Hope they give you idea what needs to be done.
Harris M.
>
> For example:
> Private Sub Command1_Click()
> ' Check user input
> If Not IsDate(Text1) Then
> MsgBox "Sorry! That is not a valid date or Date/Time.", vbCritical
> & vbOK, "Error"
> Exit Sub
> End If
>
> Validates a date for VB but the same date format is not compatible
> with Oracle and I get an error when I try to insert values.
> How can this be solved?
Received on Sat Jun 14 2003 - 21:18:48 CDT
![]() |
![]() |