|
-
Feb 16th, 2004, 09:06 AM
#1
Thread Starter
New Member
DataSet "Type Expected" Error
HELP!!!
I have some forms which I had programmed to use for database manipulations using OLE DB. These forms work perfectly! Now I tried to copy the code to a new similar form rather than re-coding all over and I keep getting a "Type Expected" error pointing to my dataset instantiation. Has anyone out there ever met this. If yes how did you solve it and most of all why does it occur?
Here is my code:
' Set up the connection string
Dim strConn As String = "Provider=Microsoft.Jet.OLEDB.4.0; DataSource=Students.mdb"
' Set up the connection
Dim Conn As New OleDbConnection(strConn)
' Set up the query
Dim sqlQuery As String = "SELECT * FROM Students"
' Set up the data adapter
Dim daStudents As New OleDbDataAdapter(sqlQuery, Conn)
' Set up the dataset
Dim dsStudents As New DataSet '<== This is the line where it gives the error
' Populate the dataset
daStudents.Fill(dsStudents, "Students")
Thanks
Orion
-
Feb 16th, 2004, 09:28 AM
#2
New Member
First I have to say that I have not encountered exactly this error, as I haven't been working with OLE DB at all, but anyway, here it goes, maybe it can be of some help...
a) Your environment doesn't recognize DataSet as a type. Maybe you are not just using another form, but have created a new project in which a form is the target for your pasting. It is then necessary (in vb6) to set the appropriate references (Project menu). When the right references are checked, the DataSet should be recognized as a type.
b) You are using vb.NET, and I don't know much about this (yet). However, vb.NET uses "imports blabla.blabla" syntax to make types and classes in different namespaces visible.
Hope this can be of any help
regards
/Kolden
-
Feb 16th, 2004, 09:35 AM
#3
Thread Starter
New Member
.NET Namespaces
Thanks for your reply.
Yes it true in VB.NET you need to import System.Data.OleDb in order to have the necessary tools and methods. This is not the case. Also the form is the main form and it is not called and needs no parameters. It is just a main form presenting a datagrid. The strange thing is that in other identical situations it worked perfectly, same structure same code! Honestly I am suspecting a bug of some kind!
regards
Orion
-
Feb 16th, 2004, 11:32 AM
#4
Thread Starter
New Member
any suggestions?
Help!?!
any further suggestions are appreciated
10x
Orion
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
|