|
-
Jul 18th, 2005, 05:33 PM
#1
Thread Starter
Frenzied Member
Back to basics: Accessing Database
Right, well on many occasions i have accessed databases fine, but this occasion it wont work. Please can i have an example of accessing a database, with SQL based on a query.
I am sure i can fill in the gaps.
Thank You
ILMV
-
Jul 18th, 2005, 05:55 PM
#2
Re: Back to basics: Accessing Database
Check out the tutorials in the Database forum.
http://www.vbforums.com/showthread.php?t=81916
Cheers
Pete
No trees were harmed in the making of this post, however a large number of electrons were greatly inconvenienced.
-
Jul 18th, 2005, 07:28 PM
#3
Thread Starter
Frenzied Member
Re: Back to basics: Accessing Database
No No Help?
-
Jul 18th, 2005, 07:55 PM
#4
Re: Back to basics: Accessing Database
Exactly what sort of help do you need? Are you using DAO or ADO?
Post the code you're having trouble with or give me some specifics and I'll try and knock something together for you.
Pete
No trees were harmed in the making of this post, however a large number of electrons were greatly inconvenienced.
-
Jul 18th, 2005, 07:57 PM
#5
Re: Back to basics: Accessing Database
 Originally Posted by I_Love_My_Vans
... well on many occasions i have accessed databases fine, but this occasion it wont work. ...
What exactly would that mean? Can you show us some code of yours that "won't work", please.
-
Jul 18th, 2005, 08:26 PM
#6
Re: Back to basics: Accessing Database
We really can't guess what exactly you are having trouble with, it would be better if you post your code where the problem is existing or be more elaborative on explaining it.
-
Jul 19th, 2005, 11:44 AM
#7
Re: Back to basics: Accessing Database
What kind of database?
Access
SQL Server
Oracle
?
-
Jul 19th, 2005, 03:12 PM
#8
Thread Starter
Frenzied Member
Re: Back to basics: Accessing Database
Sorry everyone.
Right well i am using MS Access witd DAO...
here is the code i have used so far, but it doesnt seem to find the record...
Code to access record
VB Code:
SQLTXT = "SELECT Date, Subject, Entry"
SQLTXT = SQLTXT + " From Entry"
SQLTXT = SQLTXT + " WHERE Date = " & DatePicker.value
Set MySearch = MyDatabase.OpenRecordset(SQLTXT)
txtSubject.Text = MySearch!Subject
txtEntry.Text = MySearch!Entry
All variables are definetly defined, and the database has def been loaded.
Thank you
Ben @k@ ILMV
-
Jul 19th, 2005, 04:31 PM
#9
Re: Back to basics: Accessing Database
Date is a keyword, surround it with square brackets. When a date value is used as a criteria it must be delimited by the # sign. To avoid other trouble, always use one of these date formats mm/dd/yyyy (Microsoft database standard), yyyymmdd (ISO standard) or a non ambiguous format such as dd-MMM-yyyy, when concatenating date values to a string. Also, get into the habit of using the & to concatenate strings.
VB Code:
SQLTXT = "SELECT [Date], Subject, Entry"
SQLTXT = SQLTXT & " From Entry"
SQLTXT = SQLTXT & " WHERE [Date] = #" & Format$(DatePicker.value,"mm/dd/yyyy") & "#"
-
Jul 19th, 2005, 05:31 PM
#10
Thread Starter
Frenzied Member
Re: Back to basics: Accessing Database
Oh my god i love you!!!
Um, sorry.
Cheers buddy, good effort.
ILMV
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|