Results 1 to 12 of 12

Thread: DataSource on windows mobile 6 (cant connect to sqlce database file [sdf])

  1. #1

    Thread Starter
    New Member
    Join Date
    Sep 2007
    Posts
    5

    DataSource on windows mobile 6 (cant connect to sqlce database file [sdf])

    Hi,
    I am currently developing an application using vb.net 2005 and windows mobile 6 sdk,and sql server ce for my database.

    I try to connect to the database i created using the following code: I get an identifier expected error
    pointing the dot[.] .The code is this ("Data Source =".\ MyDatabase.sdf;"")

    Visual Basic.Net 2005. The whole class is the following:

    Dim conn As SqlCeConnection = Nothing

    Try
    conn = New SqlCeConnection("Data Source =".\ MyDatabase.sdf;"")
    conn.Open()

    Dim cmd As SqlCeCommand = conn.CreateCommand()
    cmd.CommandText = "INSERT INTO Customers (Customerid], Name) Values('9', 'Smith')"

    cmd.ExecuteNonQuery()
    Finally
    conn.Close()
    End Try

  2. #2
    King of sapila
    Join Date
    Oct 2006
    Location
    Greece
    Posts
    6,763

    Re: DataSource on windows mobile 6 (cant connect to sqlce database file [sdf])

    In witch line you get the error?
    ..
    Where are you from?

  3. #3

    Thread Starter
    New Member
    Join Date
    Sep 2007
    Posts
    5

    Re: DataSource on windows mobile 6 (cant connect to sqlce database file [sdf])

    hi, I get the error on :

    vb Code:
    1. conn.Open()
    It informs that the database file can't be found.

    I am from Cyprus,studying in the uk
    Last edited by Sgiorgos; Sep 13th, 2007 at 04:49 AM.

  4. #4
    King of sapila
    Join Date
    Oct 2006
    Location
    Greece
    Posts
    6,763

    Re: DataSource on windows mobile 6 (cant connect to sqlce database file [sdf])

    Well it's kinda obvious that you don't point to the correct location...
    Gia sou file giorgo

  5. #5

    Thread Starter
    New Member
    Join Date
    Sep 2007
    Posts
    5

    Re: DataSource on windows mobile 6 (cant connect to sqlce database file [sdf])

    Geia sou pali ,

    The problem is not this as i get the connection string from vb.net itself.

    I have uploaded screen shots of the error i get.


  6. #6
    King of sapila
    Join Date
    Oct 2006
    Location
    Greece
    Posts
    6,763

    Re: DataSource on windows mobile 6 (cant connect to sqlce database file [sdf])

    "data source ="".\mydatabase.sdf;"""

  7. #7
    King of sapila
    Join Date
    Oct 2006
    Location
    Greece
    Posts
    6,763

    Re: DataSource on windows mobile 6 (cant connect to sqlce database file [sdf])

    if you are correct with the (")
    here you write data source =".\mydatabase.sdf;"

  8. #8
    Frenzied Member
    Join Date
    Oct 2005
    Posts
    1,286

    Re: DataSource on windows mobile 6 (cant connect to sqlce database file [sdf])

    Hi,
    surely it should be
    Try
    conn = New SqlCeConnection("Data Source=\MyDatabase.sdf")
    conn.Open()


    or
    conn = New SqlCeConnection("Data Source=\My Documents\MyDatabase.sdf")

    Pete
    Pete Vickers
    MVP - Device Application Development
    http://www.gui-innovations.com http://mobileworld.appamundi.com/blogs/

  9. #9

    Thread Starter
    New Member
    Join Date
    Sep 2007
    Posts
    5

    Re: DataSource on windows mobile 6 (cant connect to sqlce database file [sdf])

    Unfortunately none of the solutions work .

    Could somebody rewrite and test the application on his vb.net?

    and email me the zip file containing the code and the sdf file.

    It would be greatly appreciated . Thank you =)

  10. #10
    King of sapila
    Join Date
    Oct 2006
    Location
    Greece
    Posts
    6,763

    Re: DataSource on windows mobile 6 (cant connect to sqlce database file [sdf])

    Explain what the problem is and we will try to help you.
    Check your solution in a windowsapplication also to see if you are doing it correctly.


    (ela mi variesai )

  11. #11
    Frenzied Member
    Join Date
    Oct 2005
    Posts
    1,286

    Re: DataSource on windows mobile 6 (cant connect to sqlce database file [sdf])

    The screenshots you posted explain EXACTLY what your problem is - missing identifier.
    In which folder on the device is your database - your connection string needs to point to that folder.

    Look at your connection string carefully - that is where your problem lies.

    You have been given the correct solution already.

    Pete
    Pete Vickers
    MVP - Device Application Development
    http://www.gui-innovations.com http://mobileworld.appamundi.com/blogs/

  12. #12

    Thread Starter
    New Member
    Join Date
    Sep 2007
    Posts
    5

    Re: DataSource on windows mobile 6 (cant connect to sqlce database file [sdf])

    ok, I have found the answer.

    vb Code:
    1. Dim MyConnection As SqlCeConnection
    2.  
    3.      Dim datalocation As String = "\Program Files\ApplicationName\MyDatabase.sdf"
    4.  
    5.         MyConnection = New SqlCeConnection("Data Source=" & datalocation)

    Thank you for your help

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width