Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. Visual Basic
  4. help connecting to sql server ce using vb.net

help connecting to sql server ce using vb.net

Scheduled Pinned Locked Moved Visual Basic
databasehelpcsharpsql-server
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • G Offline
    G Offline
    gundamhamtaro
    wrote on last edited by
    #1

    Hi all, i'm trying to create a new database in CE but it doesnt seem to work for some reason........can someone help? thanks!! Imports System.Data.SqlServerCe Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click 'create DB Dim engine As New SqlServerCe.SqlCeEngine("Data Source = \My Documents\test.sdf") engine.CreateDatabase() 'error here 'connect to DB Dim ssceconn As New SqlServerCe.SqlCeConnection("Data Source = \My Documents\test.sdf") ssceconn.Open() 'ceate table Dim sqlCreateTable As SqlServerCe.SqlCeCommand = ssceconn.CreateCommand() sqlCreateTable.CommandText = _ "CREATE TABLE People(people_id int IDENTITY(0,1) PRIMARY KEY, f_name ntext, l_name ntext)" sqlCreateTable.ExecuteNonQuery() 'inserting rows Dim sqlInsertRow As SqlServerCe.SqlCeCommand = ssceconn.CreateCommand() sqlInsertRow.CommandText = "INSERT INTO People(f_name, l_name) VALUES('John', 'Doe')" sqlInsertRow.ExecuteNonQuery() 'close connection ssceconn.Close() End Sub An unhandled exception of type 'System.Data.SqlServerCe.SqlCeException' occurred in System.Data.SqlServerCe.dll Additional information: SqlCeException

    D 1 Reply Last reply
    0
    • G gundamhamtaro

      Hi all, i'm trying to create a new database in CE but it doesnt seem to work for some reason........can someone help? thanks!! Imports System.Data.SqlServerCe Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click 'create DB Dim engine As New SqlServerCe.SqlCeEngine("Data Source = \My Documents\test.sdf") engine.CreateDatabase() 'error here 'connect to DB Dim ssceconn As New SqlServerCe.SqlCeConnection("Data Source = \My Documents\test.sdf") ssceconn.Open() 'ceate table Dim sqlCreateTable As SqlServerCe.SqlCeCommand = ssceconn.CreateCommand() sqlCreateTable.CommandText = _ "CREATE TABLE People(people_id int IDENTITY(0,1) PRIMARY KEY, f_name ntext, l_name ntext)" sqlCreateTable.ExecuteNonQuery() 'inserting rows Dim sqlInsertRow As SqlServerCe.SqlCeCommand = ssceconn.CreateCommand() sqlInsertRow.CommandText = "INSERT INTO People(f_name, l_name) VALUES('John', 'Doe')" sqlInsertRow.ExecuteNonQuery() 'close connection ssceconn.Close() End Sub An unhandled exception of type 'System.Data.SqlServerCe.SqlCeException' occurred in System.Data.SqlServerCe.dll Additional information: SqlCeException

      D Offline
      D Offline
      Dave Kreskowiak
      wrote on last edited by
      #2

      It would appear that your connection string isn't valid. Specifically, my first suspect would be the path you provided for Data Source. But, your question really belongs in the Embedded/Mobile forum. RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome

      G 1 Reply Last reply
      0
      • D Dave Kreskowiak

        It would appear that your connection string isn't valid. Specifically, my first suspect would be the path you provided for Data Source. But, your question really belongs in the Embedded/Mobile forum. RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome

        G Offline
        G Offline
        gundamhamtaro
        wrote on last edited by
        #3

        hmm ok. i'll try my luck in the Mobile forum. thanks for the reply anyway.

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups