vb.net 2008 and CE 3.5 - Table Does Not Exist error

M

Mike B

I am just starting a project that will use a SQL Server Compact db on the
desktop. I am trying to write my data access classes and getting an odd
error.

This code:

Sub BindGridCE_Fails()
Dim cx As SqlCeConnection
Try
cx = New SqlCeConnection("Data Source = croe2db.sdf")
cx.Open()
Dim cm As SqlCeCommand = cx.CreateCommand()
cm.CommandText = "select * from MyTable2"

' ERROR OCCURS ON NEXT LINE
Dim rs As SqlCeResultSet =
cm.ExecuteResultSet(ResultSetOptions.Updatable Or
ResultSetOptions.Scrollable)

Me.DataGrid1.DataSource = rs
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub

Produces the error message: "The specified table does not exist. [
MyTable2 ]"

The table does exist. If I simply drag it to the data grid, it works fine.

If I use the example provided at MSDN:
http://msdn.microsoft.com/en-us/library/system.data.sqlserverce.sqlceresultset(VS.80).aspx

With the "Me.DataGrid1.DataSource = rs" line added, the dataGrid binding
works. So I doubt that is the issue. But, when is the ResultSet failing when
the table exists? I must be missing something obvious, no?

Also, from the example, the new table is added programmatically and can be
binded to the grid, but
it DOES NOT APPEAR in the dataset.xsd designer. Where is it hiding?

I apologize for the cross-post, but I wasn't sure which group was
appropriate. I posted to teh SQL Server CE group and nobody answered.

Thanks in advance for help.

MB
 
W

William \(Bill\) Vaughn

Okay, but when the code is executed and the referenced path is used to open
the .SDF, the table is not there. Consider that if the .SDF is referenced
without a full path the code looks in the current directory. Since Visual
Studio (might) copy a fresh copy of the database to this location (like the
Debug directory) or not, you can see how this can happen. Try to set a hard
path or check the Copydatabase options to see if the unmolested database is
being copied.

hth

--
__________________________________________________________________________
William R. Vaughn
President and Founder Beta V Corporation
Author, Mentor, Dad, Grandpa
Microsoft MVP
(425) 556-9205 (Pacific time)
Hitchhiker's Guide to Visual Studio and SQL Server (7th Edition)
http://betav.com/blog/billva
____________________________________________________________________________________________
 
M

Mike B

Thanks Bill.

I did try an absolute path and got the same result. Sorry for not mentioning
that.

I also brought the .sdf into the project root to begin with.





William (Bill) Vaughn said:
Okay, but when the code is executed and the referenced path is used to
open the .SDF, the table is not there. Consider that if the .SDF is
referenced without a full path the code looks in the current directory.
Since Visual Studio (might) copy a fresh copy of the database to this
location (like the Debug directory) or not, you can see how this can
happen. Try to set a hard path or check the Copydatabase options to see if
the unmolested database is being copied.

hth

--
__________________________________________________________________________
William R. Vaughn
President and Founder Beta V Corporation
Author, Mentor, Dad, Grandpa
Microsoft MVP
(425) 556-9205 (Pacific time)
Hitchhiker's Guide to Visual Studio and SQL Server (7th Edition)
http://betav.com/blog/billva
____________________________________________________________________________________________



Mike B said:
I am just starting a project that will use a SQL Server Compact db on the
desktop. I am trying to write my data access classes and getting an odd
error.

This code:

Sub BindGridCE_Fails()
Dim cx As SqlCeConnection
Try
cx = New SqlCeConnection("Data Source = croe2db.sdf")
cx.Open()
Dim cm As SqlCeCommand = cx.CreateCommand()
cm.CommandText = "select * from MyTable2"

' ERROR OCCURS ON NEXT LINE
Dim rs As SqlCeResultSet =
cm.ExecuteResultSet(ResultSetOptions.Updatable Or
ResultSetOptions.Scrollable)

Me.DataGrid1.DataSource = rs
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub

Produces the error message: "The specified table does not exist. [
MyTable2 ]"

The table does exist. If I simply drag it to the data grid, it works
fine.

If I use the example provided at MSDN:
http://msdn.microsoft.com/en-us/library/system.data.sqlserverce.sqlceresultset(VS.80).aspx

With the "Me.DataGrid1.DataSource = rs" line added, the dataGrid binding
works. So I doubt that is the issue. But, when is the ResultSet failing
when
the table exists? I must be missing something obvious, no?

Also, from the example, the new table is added programmatically and can
be binded to the grid, but
it DOES NOT APPEAR in the dataset.xsd designer. Where is it hiding?

I apologize for the cross-post, but I wasn't sure which group was
appropriate. I posted to teh SQL Server CE group and nobody answered.

Thanks in advance for help.

MB
 
M

Michael Barrett

Bill,

I am now getting an error that says:

Unable to load DLL sqlceme30.dll: The specified module could not be found.

That dll is on my machine, as is sqlceme35. I googled it but haven't had any
success with teh replies I have seen. What is the catch here? Also, why
isn't it looking for sqlceme35? I have it installed and created an sdf with
SQL Server 2005 express.

Thanks.


William (Bill) Vaughn said:
Okay, but when the code is executed and the referenced path is used to
open the .SDF, the table is not there. Consider that if the .SDF is
referenced without a full path the code looks in the current directory.
Since Visual Studio (might) copy a fresh copy of the database to this
location (like the Debug directory) or not, you can see how this can
happen. Try to set a hard path or check the Copydatabase options to see if
the unmolested database is being copied.

hth

--
__________________________________________________________________________
William R. Vaughn
President and Founder Beta V Corporation
Author, Mentor, Dad, Grandpa
Microsoft MVP
(425) 556-9205 (Pacific time)
Hitchhiker's Guide to Visual Studio and SQL Server (7th Edition)
http://betav.com/blog/billva
____________________________________________________________________________________________



Mike B said:
I am just starting a project that will use a SQL Server Compact db on the
desktop. I am trying to write my data access classes and getting an odd
error.

This code:

Sub BindGridCE_Fails()
Dim cx As SqlCeConnection
Try
cx = New SqlCeConnection("Data Source = croe2db.sdf")
cx.Open()
Dim cm As SqlCeCommand = cx.CreateCommand()
cm.CommandText = "select * from MyTable2"

' ERROR OCCURS ON NEXT LINE
Dim rs As SqlCeResultSet =
cm.ExecuteResultSet(ResultSetOptions.Updatable Or
ResultSetOptions.Scrollable)

Me.DataGrid1.DataSource = rs
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub

Produces the error message: "The specified table does not exist. [
MyTable2 ]"

The table does exist. If I simply drag it to the data grid, it works
fine.

If I use the example provided at MSDN:
http://msdn.microsoft.com/en-us/library/system.data.sqlserverce.sqlceresultset(VS.80).aspx

With the "Me.DataGrid1.DataSource = rs" line added, the dataGrid binding
works. So I doubt that is the issue. But, when is the ResultSet failing
when
the table exists? I must be missing something obvious, no?

Also, from the example, the new table is added programmatically and can
be binded to the grid, but
it DOES NOT APPEAR in the dataset.xsd designer. Where is it hiding?

I apologize for the cross-post, but I wasn't sure which group was
appropriate. I posted to teh SQL Server CE group and nobody answered.

Thanks in advance for help.

MB
 
P

Paul Clement

¤ Bill,
¤
¤ I am now getting an error that says:
¤
¤ Unable to load DLL sqlceme30.dll: The specified module could not be found.
¤
¤ That dll is on my machine, as is sqlceme35. I googled it but haven't had any
¤ success with teh replies I have seen. What is the catch here? Also, why
¤ isn't it looking for sqlceme35? I have it installed and created an sdf with
¤ SQL Server 2005 express.

Have you tried adding it to your project? See if the following helps:

http://blogs.msdn.com/smartclientdata/archive/2005/07/15/439008.aspx


Paul
~~~~
Microsoft MVP (Visual Basic)
 
P

Paul Clement

¤ > Have you tried adding it to your project? See if the following helps:
¤ >
¤ > http://blogs.msdn.com/smartclientdata/archive/2005/07/15/439008.aspx
¤
¤ Yes, that worked. Thank you.
¤
¤ However, how do I ensure that version 3.5 is being used? It is still using
¤ 3.0. If 3.5 is on the machine, and I create a new sdf, shouldn't it default
¤ to teh most recent version?

If you want to use 3.5 then you will have to reference the 3.5 files. It's not going to use version
3.5 automatically.


Paul
~~~~
Microsoft MVP (Visual Basic)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top