|
-
Jun 7th, 2004, 10:17 AM
#1
Thread Starter
Frenzied Member
Return Respective Type
Hello Ladies and Gents,
I created small class to make my data access easier on this project (why else should we have classes if not to make our lives a little more sane and keep our hair longer???).
The only snag I have run into is the following:
I would like for the code snippet below to be changed so that it returns the data in whatever datatype it was formatted in within my Access DB...
I'm sure this has been done before and that one of you will probably deside to doze of as you answer it, but it's been buggin' me just the same.
VB Code:
Public Function GetVal(ByVal Field As String) As String
If IsNothing(RS) Then Exit Function
Try
Return Convert.ToString(RS.Fields(Field).Value)
Catch ex As Exception
Return ""
End Try
End Function
Thanks in advance,
Squirrelly1
Now happily married and still crankin' away at the keyboard.  Life is grand for a coder, no?
-
Jun 7th, 2004, 12:06 PM
#2
Hyperactive Member
Squirrelly1,
Hate to answer your question with a question, but what kind of object is RS?
Also, how do you know which row/record you are on?
John
-
Jun 7th, 2004, 12:07 PM
#3
You would use the generic type Object:
VB Code:
Public Function GetVal(ByVal Field As String) As Object
If IsNothing(RS) Then Return
Try
Return RS.Fields(Field).Value
Catch ex As Exception
Return
End Try
End Function
-
Jun 7th, 2004, 02:14 PM
#4
Thread Starter
Frenzied Member
John,
The object is an ADODB Recordset.
Edneeis,
Thanks, I'll give it a shot.
,
Squirrelly1
Now happily married and still crankin' away at the keyboard.  Life is grand for a coder, no?
-
Jun 7th, 2004, 02:34 PM
#5
Why are you using an ADODB Recordset in .NET?
-
Jun 7th, 2004, 03:00 PM
#6
Thread Starter
Frenzied Member
What should I use in .Net? I'm just used to having implemented ADODB this way... Is there a better one?
Squirrelly1
Now happily married and still crankin' away at the keyboard.  Life is grand for a coder, no?
-
Jun 7th, 2004, 03:59 PM
#7
Yes in .NET there are DataReaders or DataSets to replace the Recordset and they work much better. Poke around here for an example or check out the here:
http://samples.gotdotnet.com/quickstart/winforms/
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
|