Welcome to dbFreaks.com!
FAQFAQ      ProfileProfile    Private MessagesPrivate Messages   Log inLog in

connect to database using calender value in query

 
   Database Help (Home) -> Visual Basic -> ODBC RSS
Next:  DB Speed slows down  
Author Message
aneurin

External


Since: Jan 06, 2004
Posts: 2



(Msg. 1) Posted: Mon Jan 05, 2004 1:44 pm
Post subject: connect to database using calender value in query
Archived from groups: microsoft>public>vb>database>odbc (more info?)

hi i have the below code that connects to an oracle database
what i want it to do is the user selects the date required on a
calender object types in a number in the a text box and press a
button it then should the carry out the query
it works fine if i have sysdate- 1 in the code
but when i use the caleder it does not work
does any one have any ideas


Private Sub Command2_Click()

Dim db As Connection
Dim txtsql As String

Set db = New Connection
db.CursorLocation = adUseClient
db.Open "Provider=OraOLEDB.Oracle.1;Persist Security Info=False;User
ID=rep;password=rep;Data Source=live;"

Set adoPrimaryRS = New Recordset
txtsql = "select MOMENT,CAMPAIGN,STARTED from CAMPAIGN_SUMMARY WHERE
TRUNC(CAMPAIGN_SUMMARY.MOMENT)= " & "'" & cale1 & "'" & " and
GAS_CAMPAIGN_SUMMARY.WEEK = " & "'" & txtbox & "'" & ""
adoPrimaryRS.Open txtsql, db, adOpenStatic, adLockOptimistic


Set grdDataGrid.DataSource = adoPrimaryRS
lblStartedval(0).Caption = "" & adoPrimaryRS.Fields("started").Value
mbDataChanged = False
End Sub

 >> Stay informed about: connect to database using calender value in query 
Back to top
Login to vote
Corin Froese

External


Since: Jan 05, 2004
Posts: 1



(Msg. 2) Posted: Mon Jan 05, 2004 8:46 pm
Post subject: Re: connect to database using calender value in query [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Greetings,

I'm not sure which calendar object you are using so I can can't say for
sure, but I suggest taking a look at the default property for the
object. It would be silly (though possible) that it's not returning the
date as the default property.

Another possibility is the formatting of the date in the query. It's
been a while since I used Oracle so I don't remember what it is but not
all databases like dates wrapped with '.

Corin

aneurin wrote:
 > hi i have the below code that connects to an oracle database
 > what i want it to do is the user selects the date required on a
 > calender object types in a number in the a text box and press a
 > button it then should the carry out the query
 > it works fine if i have sysdate- 1 in the code
 > but when i use the caleder it does not work
 > does any one have any ideas
 >
 >
 > Private Sub Command2_Click()
 >
 > Dim db As Connection
 > Dim txtsql As String
 >
 > Set db = New Connection
 > db.CursorLocation = adUseClient
 > db.Open "Provider=OraOLEDB.Oracle.1;Persist Security Info=False;User
 > ID=rep;password=rep;Data Source=live;"
 >
 > Set adoPrimaryRS = New Recordset
 > txtsql = "select MOMENT,CAMPAIGN,STARTED from CAMPAIGN_SUMMARY WHERE
 > TRUNC(CAMPAIGN_SUMMARY.MOMENT)= " & "'" & cale1 & "'" & " and
 > GAS_CAMPAIGN_SUMMARY.WEEK = " & "'" & txtbox & "'" & ""
 > adoPrimaryRS.Open txtsql, db, adOpenStatic, adLockOptimistic
 >
 >
 > Set grdDataGrid.DataSource = adoPrimaryRS
 > lblStartedval(0).Caption = "" & adoPrimaryRS.Fields("started").Value
 > mbDataChanged = False
 > End Sub<!-- ~MESSAGE_AFTER~ -->

 >> Stay informed about: connect to database using calender value in query 
Back to top
Login to vote
Display posts from previous:   
   Database Help (Home) -> Visual Basic -> ODBC All times are: Pacific Time (US & Canada) (change)
Page 1 of 1

 
You can post new topics in this forum
You can reply to topics in this forum
You can edit your posts in this forum
You can delete your posts in this forum
You can vote in polls in this forum



[ Contact us | Terms of Service/Privacy Policy ]