Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Re: Validate date from VB to insert into Oracle table

Re: Validate date from VB to insert into Oracle table

From: harris <harris_m_at_yahoo.com>
Date: 14 Jun 2003 19:18:48 -0700
Message-ID: <af968c64.0306141818.23bf1686@posting.google.com>


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

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US