Z
Zahid
Hi,
the following code always throws the exception. Why? It
should simply create the table with the two rows:
If Not System.IO.File.Exists("\Program
files\testSQLCE\MyDB.sdf") Then
Dim sqlEngine As New
SqlCeEngine("Data Source = \Program
files\testSQLCE\MyDB.sdf")
sqlEngine.CreateDatabase()
gSqlEngine = sqlEngine
Try
Dim myConnectionString As String =
"Data Source =\Program
files\testSQLCE\MyDB.sdf;"
Dim myConnection As New SqlCeConnection
(myConnectionString)
Dim myCreateQuery As String
myCreateQuery = "CREATE TABLE Products
(PLU INTEGER NOT NULL,
Description VARCHAR(40) DEFAULT 'Description' NOT
NULL" _
& ", V$ATpos INTEGER DEFAULT 0 NOT NULL)"
Dim myCommand As New SqlCeCommand(myCreateQuery)
myCommand.Connection = myConnection
myConnection.Open()
myCommand.ExecuteNonQuery()
myCommand.Connection.Close()
Catch oExcept As Exception
MessageBox.Show(oExcept.Message, _
"is thrown as Exception - z")
End Try
Else
MsgBox("Database Already Exists")
End If
Thanks in advance.
the following code always throws the exception. Why? It
should simply create the table with the two rows:
If Not System.IO.File.Exists("\Program
files\testSQLCE\MyDB.sdf") Then
Dim sqlEngine As New
SqlCeEngine("Data Source = \Program
files\testSQLCE\MyDB.sdf")
sqlEngine.CreateDatabase()
gSqlEngine = sqlEngine
Try
Dim myConnectionString As String =
"Data Source =\Program
files\testSQLCE\MyDB.sdf;"
Dim myConnection As New SqlCeConnection
(myConnectionString)
Dim myCreateQuery As String
myCreateQuery = "CREATE TABLE Products
(PLU INTEGER NOT NULL,
Description VARCHAR(40) DEFAULT 'Description' NOT
NULL" _
& ", V$ATpos INTEGER DEFAULT 0 NOT NULL)"
Dim myCommand As New SqlCeCommand(myCreateQuery)
myCommand.Connection = myConnection
myConnection.Open()
myCommand.ExecuteNonQuery()
myCommand.Connection.Close()
Catch oExcept As Exception
MessageBox.Show(oExcept.Message, _
"is thrown as Exception - z")
End Try
Else
MsgBox("Database Already Exists")
End If
Thanks in advance.