Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / Compact Framework / April 2006

Tip: Looking for answers? Try searching our database.

i am having trouble in creating new database using SQL CE

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
alexoh84@gmail.com - 25 Apr 2006 11:15 GMT
hi,

i am new to SQL CE. i am trying to create a new database n i doesn't
seem to work. this is my code which i copy from msdn.com for testing
purposes n it dun work as well.

       Dim SQLEngine As SqlCeEngine
           SQLEngine = New SqlCeEngine("data source=c:\test.sdf")
           SQLEngine.CreateDatabase()

           sql = "CREATE TABLE ADR_ADDRESS ( "
           sql &= "Address_ID INT IDENTITY(1,1) PRIMARY KEY "
           sql &= ",Name nvarchar(50) "
           sql &= ",Address ntext "
           sql &= ",Telephone ntext "
           sql &= ",Last_Edited datetime "
           sql &= ",IsPrivate_Flag nvarchar(10) "
           sql &= ")"

           Dim objConn As New SqlCeConnection

           objConn.ConnectionString = "data source=c:\test.sdf"
           objConn.Open()

           Dim objCmd As SqlCeCommand = New SqlCeCommand(sql, objConn)
           objCmd.CommandType = Data.CommandType.Text
           objCmd.ExecuteNonQuery()
           objCmd.Dispose()

it gave me an error when running saying that the path is invalid. i
even try to manually create the database n try to connect to it n it
still came up with the same error. need help figuring out why.. thanks
Alejandro Mezcua - 25 Apr 2006 11:45 GMT
I assume you are trying to run this code on a CE device or a CE emulator. If
so, the path you are trying to use is not valid, there is no C: drive on a
CE device. You can try using "data source=\test,sdf" as the connection
string to create the database file on the root folder of the device.

Cheers,

Alejandro Mezcua
MVP .NET Compact Framework
http://www.byteabyte.net/

> hi,
>
[quoted text clipped - 28 lines]
> even try to manually create the database n try to connect to it n it
> still came up with the same error. need help figuring out why.. thanks
alexoh84@gmail.com - 25 Apr 2006 13:04 GMT
icic..thanks for the info. really appreciate it. but if that is the
case, then how would i able to connect to a databse which reside in my
PC? is there anyway to do that or that i am unable to do that ?
<ctacke/> - 25 Apr 2006 14:36 GMT
You can't through SqlCe.  You can make a direct connection to a full SQL
Server of a network connection.

-Chris

> icic..thanks for the info. really appreciate it. but if that is the
> case, then how would i able to connect to a databse which reside in my
> PC? is there anyway to do that or that i am unable to do that ?

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.