SQLCE Problem on Create TABLE

E

Enver A

*The code is below. It always stuck on line "command4.ExecuteNonQuery()" and
it throws an Sqlce exception

Under Public Class Form1 definition:

Private Const filename4 As String = "MUSTERI.SDF"

Private connstr4 As String = String.Format("Datasource={0};Password={1}",
filename4, "Admin")

Private connection4 As SqlCeConnection



Under Private sub CreateDB Click():



Dim engine4 As New SqlCeEngine(connstr4)

If Not File.Exists(filename4) Then

engine4.CreateDatabase()

Else

MsgBox("FILE EXISTS")

End If

engine4.Dispose()

connection4 = New SqlCeConnection(connstr4)

connection4.Open()

Dim command4 As SqlCeCommand = connection4.CreateCommand

command4.CommandText = "CREATE TABLE MUSTERI (INDEXMS nvarchar(5),MSAD
nvarchar(30),MSSOYAD nvarchar(30),MSSEMT nvarchar(30),MSSEMTRCH
nvarchar(30),MSTLF nvarchar(15),FIYAT nvarchar(3),INDEXBY
nvarchar(4),VHMARKA nvarchar(30),VHMODEL nvarchar(50),VHLSEBAT
nvarchar(20),VHYIL nvarchar(4),LASONMRK nvarchar(20),LASONDSN
nvarchar(30),LASRKMRK nvarchar(20),LASRKDSN nvarchar(30),VHDSSGON
nvarchar(10),VHDSSGRK nvarchar(10),VHDSSLON nvarchar(10),VHDISSLRK
nvarchar(10),VHPLAKA nvarchar(15),VHIDHVON nvarchar(3),VHIDHVRK
nvarchar(3),TARIH nvarchar(10),USER nvarchar(5))"

command4.ExecuteNonQuery()

command4.Dispose()

MsgBox("MUSTERI.SDF TAMAM")

' 4TH Creation Complete

connection4.Close()
 
R

Richard Thombs

I think USER might be a reserved word, try enclosing it in double-quotes.

Why oh why SqlCe wants quotes rather than being compatibile with
SqlServer and using square brackets is beyond me, but basically:

"USER" nvarchar(5)

Might do it.

R.
 
C

chris

Possibly objects to the use of a fieldname 'User', try putting it
inside square braces eg [User] or just try a different fieldname
first.

Chris.
 
E

Enver A

Thank you so much Chris and Richard. My problem has been solved. I ve
changed the Field name "USER" to something else and it is working perfectly
now.
Thanks again,

Enver

chris said:
Possibly objects to the use of a fieldname 'User', try putting it
inside square braces eg [User] or just try a different fieldname
first.

Chris.

"Enver A" <[email protected]> wrote in message
*The code is below. It always stuck on line "command4.ExecuteNonQuery()" and
it throws an Sqlce exception

Under Public Class Form1 definition:

Private Const filename4 As String = "MUSTERI.SDF"

Private connstr4 As String = String.Format("Datasource={0};Password={1}",
filename4, "Admin")

Private connection4 As SqlCeConnection



Under Private sub CreateDB Click():



Dim engine4 As New SqlCeEngine(connstr4)

If Not File.Exists(filename4) Then

engine4.CreateDatabase()

Else

MsgBox("FILE EXISTS")

End If

engine4.Dispose()

connection4 = New SqlCeConnection(connstr4)

connection4.Open()

Dim command4 As SqlCeCommand = connection4.CreateCommand

command4.CommandText = "CREATE TABLE MUSTERI (INDEXMS nvarchar(5),MSAD
nvarchar(30),MSSOYAD nvarchar(30),MSSEMT nvarchar(30),MSSEMTRCH
nvarchar(30),MSTLF nvarchar(15),FIYAT nvarchar(3),INDEXBY
nvarchar(4),VHMARKA nvarchar(30),VHMODEL nvarchar(50),VHLSEBAT
nvarchar(20),VHYIL nvarchar(4),LASONMRK nvarchar(20),LASONDSN
nvarchar(30),LASRKMRK nvarchar(20),LASRKDSN nvarchar(30),VHDSSGON
nvarchar(10),VHDSSGRK nvarchar(10),VHDSSLON nvarchar(10),VHDISSLRK
nvarchar(10),VHPLAKA nvarchar(15),VHIDHVON nvarchar(3),VHIDHVRK
nvarchar(3),TARIH nvarchar(10),USER nvarchar(5))"

command4.ExecuteNonQuery()

command4.Dispose()

MsgBox("MUSTERI.SDF TAMAM")

' 4TH Creation Complete

connection4.Close()

create
a
 

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

Similar Threads


Top