|
-
Feb 27th, 2010, 05:15 AM
#1
Thread Starter
New Member
Read field from database into variable
Hi, I simply wont to read one field in a databasetable into a variable.
dim text as string
text = table.field
How do I do that.
A beginner
-
Feb 27th, 2010, 05:58 AM
#2
Re: Read field from database into variable
I'd recommend reading a tutorial on database access in the first instance.
Jmcilhinney's code bank article covers all you need to know to get you going.
-
Feb 27th, 2010, 06:12 AM
#3
Thread Starter
New Member
Re: Read field from database into variable
This is what I found on the internet but this is not working
Dim a As String
a = Me.dataset.tabel.row(1).field(1)
-
Feb 27th, 2010, 06:41 AM
#4
Re: Read field from database into variable
 Originally Posted by albel
This is what I found on the internet but this is not working
Dim a As String
a = Me.dataset.tabel.row(1).field(1)
Have you followed the link provided? If you have then you've got the answer, so posting something else that doesn't work is of no value.
-
Feb 27th, 2010, 07:39 AM
#5
Addicted Member
Re: Read field from database into variable
 Originally Posted by albel
This is what I found on the internet but this is not working
Dim a As String
a = Me.dataset.tabel.row(1).field(1)
You do not need to create and fill an entire dataset if all you are returning is a single value. Your using more resources then you need. Follow JMC's advice and also take a look at the command objects executescalar method for returning a single value.
-
Feb 27th, 2010, 07:11 PM
#6
Re: Read field from database into variable
 Originally Posted by Tom.Net
Follow JMC's advice and also take a look at the command objects executescalar method for returning a single value.
Which is exactly what the first code example, entitled something like "Getting a single value", in my CodeBank thread does.
-
Feb 27th, 2010, 08:27 PM
#7
Addicted Member
Re: Read field from database into variable
 Originally Posted by jmcilhinney
Which is exactly what the first code example, entitled something like "Getting a single value", in my CodeBank thread does.
Awww I shouldve assumed as much...
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
|