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
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