Pocket PC Error

G

Guest

Hi, I got this error when I tried to create a table in sqlce database:

Here is the error message:
"An unhandled exception of type 'System.Data.SqlServerCe.SqlCeException'
occurred in System.Data.SqlServerCe.dll"

Also this msg for the same problem:
"sqlCreateTable.ExecuteNonQuery Run-time exception thrown :
System.InvalidOperationException - ExecuteNonQuery requires an open and
available Connection. The connection's current state is 5."

Following is my code:

Dim sqlEngine As New SqlCeEngine( _
"dataSource= " & _
"\My Documents\Business\BookStores.sdf")
sqlEngine.CreateDatabase()

Dim conn As New SqlCeConnection( _
"Data Source = \My Documents\Business\BookStores.sdf")


conn.Open()
Dim sqlCreateTable As SqlCeCommand = conn.CreateCommand()
sqlCreateTable.CommandText = _
"Create Table Stores(storeID int " & _
"Priomary Key Not Null, " & _
"storeName nvarchar(20))"
sqlCreateTable.ExecuteNonQuery()
...

Can anybody help me to solve the problem? Thanks a lot.

It will be the best New Year present I can ever have if I can have this
solved.

Sharon
 
G

Graeme Richardson

Hi, is the line

"Priomary Key Not Null"

a typo in this message or in code?

Also, Not Null is probably not required since a Primary Key, by definition,
cannot be null.

HTH, Graeme.
 
A

abbi

Hi,
This is my first time asking for help in a forum, Hope im sending
the message to right place.

I have somehow the same sort of problem as Sharon,

I am using SQL Server 2000 and Pocket PC on the Visual Studio 2003.
I followed the book(SQL Server CE Databse Developemnt with the.NET Compact Framework, by Rob Tiffany) step by step to create a connection between the database (NorthwindDemo) and Pocket PC application. But im gettin an error:

An unhandled exception of type 'System.Data.SqlServerCe.SqlCeException' occurred in System.Data.SqlServerCe.dll

I tryed alot to solve it but I failed, the codes for the prog are as follows;

using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.IO;
using System.Data.SqlServerCe;
using System.Data.Common;

private void button5_Click(object sender, System.EventArgs e)
{
SqlCeConnection cn = null;
cn = new SqlCeConnection("Data Source=\\My Documents\\NorthwindDemo.sdf;" +
"Password=");
cn.Open();
SqlCeCommand cmd = cn.CreateCommand();
cmd.CommandText = "Products";
cmd.CommandType = CommandType.TableDirect;
//Create a SqlCeDataAdapter object
SqlCeDataAdapter da = new SqlCeDataAdapter(cmd);
//Create a DataSet object
DataSet ds = new DataSet();
//Fill the DataSet
da.Fill(ds);
//Bind the DataGrid to the DataTable contained in the DataSet
dataGrid1.DataSource = ds.Tables[0];


I have added the NorthWindDemo.sdf to the project, placed a copy of the file in the My Documents and imprted the references as mentioned in the book. I repeated the steps many times, but I still get the above error. Its really stressing me and its only the beggining of the project:)

Your help will be very much appreciated

From http://www.developmentnow.com/g/18_2004_12_0_0_33156/Pocket-PC-Error.ht

Posted via DevelopmentNow.com Group
http://www.developmentnow.com
 
A

azerty

one technic to have more information about an exception :

in VS2003, change Exception handler option to stop your program at each
exception occurs (somewhere in Debug/Exception menu item)

Execute your application to obtain your exception >> VS2003 stop execution
of your applicaiton.

in call stack windows, right clic >>> Show not user code

the last line in call stack shwo you the method where exception occurs in
SQLCe.DLL with MSIL offset

use Reflector tools (http://www.aisto.com/roeder/dotnet/) to decompil
SQLCeResultSet

found the good function

with MSIL view, you can find the place in code where the exception occurs,
with C# view you can locate the same place ...

I hope this can help you !


abbi said:
Hi,
This is my first time asking for help in a forum, Hope im sending
the message to right place.

I have somehow the same sort of problem as Sharon,

I am using SQL Server 2000 and Pocket PC on the Visual Studio 2003.
I followed the book(SQL Server CE Databse Developemnt with the.NET Compact
Framework, by Rob Tiffany) step by step to create a connection between
the database (NorthwindDemo) and Pocket PC application. But im gettin an
error:

An unhandled exception of type 'System.Data.SqlServerCe.SqlCeException'
occurred in System.Data.SqlServerCe.dll

I tryed alot to solve it but I failed, the codes for the prog are as
follows;

using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.IO;
using System.Data.SqlServerCe;
using System.Data.Common;

private void button5_Click(object sender, System.EventArgs e)
{
SqlCeConnection cn = null;
cn = new SqlCeConnection("Data Source=\\My Documents\\NorthwindDemo.sdf;"
+
"Password=");
cn.Open();
SqlCeCommand cmd = cn.CreateCommand();
cmd.CommandText = "Products";
cmd.CommandType = CommandType.TableDirect;
//Create a SqlCeDataAdapter object
SqlCeDataAdapter da = new SqlCeDataAdapter(cmd);
//Create a DataSet object
DataSet ds = new DataSet();
//Fill the DataSet
da.Fill(ds);
//Bind the DataGrid to the DataTable contained in the DataSet
dataGrid1.DataSource = ds.Tables[0];


I have added the NorthWindDemo.sdf to the project, placed a copy of the
file in the My Documents and imprted the references as mentioned in the
book. I repeated the steps many times, but I still get the above error.
Its really stressing me and its only the beggining of the project:)

Your help will be very much appreciated.

From
http://www.developmentnow.com/g/18_2004_12_0_0_33156/Pocket-PC-Error.htm

Posted via DevelopmentNow.com Groups
http://www.developmentnow.com
 

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