|
-
Nov 13th, 2003, 10:23 AM
#1
Thread Starter
Lively Member
Object Oriented Problems (classes)
Hi,
I'm trying to write a class for a dataadapter that I have to use numerous times in my application.
I did it the following way:
Imports System
Imports System.Data
Imports System.Data.OleDb
Public Class ClassMainGroup
Dim connectionDatabase As OleDbConnection = New OleDbConnection("Jet OLEDB:Global Partial Bulk Ops=2;Jet OLEDB:Registry Path=;Jet OLEDB atabase L" & _
"ocking Mode=1;Data Source=""C:\softlist\Softlist_database.mdb"";Jet OLEDB:Engine T" & _
"ype=5;Provider=""Microsoft.Jet.OLEDB.4.0"";Jet OLEDB:System database=;Jet OLEDB:SF" & _
"P=False;persist security info=False;Extended Properties=;Mode=Share Deny None;Je" & _
"t OLEDB:Encrypt Database=False;Jet OLEDB:Create System Database=False;Jet OLEDB:" & _
"Don't Copy Locale on Compact=False;Jet OLEDB:Compact Without Replica Repair=Fals" & _
"e;User ID=Admin;Jet OLEDB:Global Bulk Transactions=1")
Dim oledbdataadapterMainGroup As OleDbDataAdapter = New OleDbDataAdapter
Dim oledbselectcommandMainGroup As OleDbCommand = New OleDbCommand
oledbselectcommandMainGroup.commandtext = "SELECT CategoryID FROM categories"
End Class
I didn't even try to compile it because I know it won't work. The problem is the following: I defined oledbselectcommandMainGroup as an oledbcommand but when I try to give a commandtext to it, the codehelp says: declaration expected. I don't understand this because I defined it???
Can anybody help me or give me a link to a good tutorial on OO programming in VB.NET?
Thanx
Tom
-
Nov 13th, 2003, 11:05 AM
#2
You have to be in some form of method inside the class to set properties and what not that aren't part of the constructor. You should move the commandtext to your classes constructor.
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
|