Results 1 to 20 of 20

Thread: sqlCE & sqlClient.. is this possible?

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2006
    Posts
    398

    sqlCE & sqlClient.. is this possible?

    connection1 is in sqlCE.. -- db1.sdf
    connection2 is in sqlClient.. -- db1.mdf

    connection2 will load data from table1 of db1.mdf,
    then after loading, display the data in a grid control or listview control,
    by pressing a command button all data in the grid/listview control will be added to table1 of db1.sdf using connection1.

    is this possible?
    ________
    Iolite Vaporizer
    Last edited by rothj0hn; Feb 15th, 2011 at 01:51 PM.

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: sqlCE & sqlClient.. is this possible?

    Absolutely. A DataTable doesn't know or care anything about where the data it contains came from or goes to. The gotcha is that, when you call Fill on a DataAdapter to populate a DataTable, the table's AcceptChanges method is called after the data is added by default. This will set the RowState of each DataRow to Unchanged, meaning they can't be saved anywhere. What you need to do is set the filling DataAdapter's AcceptChangesDuringFill property to False. That way AcceptChanges will not be called and all the RowStates will remain as Added, meaning they are considered new rows ready to be inserted.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2006
    Posts
    398

    Re: sqlCE & sqlClient.. is this possible?

    i had tried this but it does not work. can you give me examples?
    ________
    Digital Scales
    Last edited by rothj0hn; Feb 15th, 2011 at 01:51 PM.

  4. #4
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: sqlCE & sqlClient.. is this possible?

    How about you show us what you tried and then we can help you tweak that? Also, please explain what "it does not work" means. What happens that shouldn't? What doesn't happen that should?
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  5. #5

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2006
    Posts
    398

    Re: sqlCE & sqlClient.. is this possible?

    OMG! i already deleted the project. ill try to create a new one and post it.. thanks
    ________
    Vaporgenie reviews
    Last edited by rothj0hn; Feb 15th, 2011 at 01:52 PM.

  6. #6

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2006
    Posts
    398

    Re: sqlCE & sqlClient.. is this possible?

    i cant establish connection on the .sdf files..

    code:
    vb Code:
    1. Imports System.Data
    2. Imports System.Data.SqlServerCe
    3.  
    4. Public Class Form1
    5.  
    6.     Public cn As New SqlCeConnection
    7.  
    8.     Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    9.         cn.ConnectionString = "Data Source=\Program Files\MPOS\DATAs\dbMPOS.sdf;"
    10.         If cn.State = 1 Then cn.Close()
    11.         cn.Open()
    12.         MsgBox("Connection Ok")
    13.     End Sub
    14.  
    15. End Class

    error:
    cn.open ---->The path is not valid. Check the directory for the database. [ Path = \Program Files\MPOS\DATAs\dbMPOS.sdf ]

    SqlCeException was unhandled

    im sure that my database path is correct
    ________
    Los angeles dispensaries
    Last edited by rothj0hn; Feb 15th, 2011 at 01:52 PM.

  7. #7
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: sqlCE & sqlClient.. is this possible?

    I don't develop for mobile devices so I don't know how file paths work on Windows Mobile. That said, I'm guessing that your SDF file is in the same folder as your EXE. In that case you shouldn't have to specify a path, just a file name.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

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

    Re: sqlCE & sqlClient.. is this possible?

    Hi,
    check your path is valid.
    If you didn't create it yourself, and your app is MPOS the path would be by default
    \program Files\Mpos\dbmpos.sdf
    Pete Vickers
    MVP - Device Application Development
    http://www.gui-innovations.com http://mobileworld.appamundi.com/blogs/

  9. #9

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2006
    Posts
    398

    Re: sqlCE & sqlClient.. is this possible?

    i already created it.. by the way im using windows application form. does it has something to do with the error?
    ________
    Italian recipes
    Last edited by rothj0hn; Feb 15th, 2011 at 01:52 PM.

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

    Re: sqlCE & sqlClient.. is this possible?

    Quote Originally Posted by rothj0hn View Post
    i already created it.. by the way im using windows application form. does it has something to do with the error?
    You mean you are using a desktop application, not a device application?
    Pete Vickers
    MVP - Device Application Development
    http://www.gui-innovations.com http://mobileworld.appamundi.com/blogs/

  11. #11

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2006
    Posts
    398

    Re: sqlCE & sqlClient.. is this possible?

    it goes like this i have a window application connected to db1.mdf and a device application connected to db1.sdf.. what i want to do now is connect my window application to the db1.sdf of my device..
    ________
    Plymouth pronto spyder specifications
    Last edited by rothj0hn; Feb 15th, 2011 at 01:52 PM.

  12. #12
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: sqlCE & sqlClient.. is this possible?

    Quote Originally Posted by rothj0hn View Post
    it goes like this i have a window application connected to db1.mdf and a device application connected to db1.sdf.. what i want to do now is connect my window application to the db1.sdf of my device..
    In future, please provide a FULL and CLEAR description of the problem in the first post. If we only have half the relevant information it makes it rather hard to provide a relevant solution.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  13. #13

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2006
    Posts
    398

    Re: sqlCE & sqlClient.. is this possible?

    sorry about that..
    ________
    Silver Surfer Vaporizer
    Last edited by rothj0hn; Feb 15th, 2011 at 01:53 PM.

  14. #14
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: sqlCE & sqlClient.. is this possible?

    So this code is being executed on a desktop machine to access an SDF file on a mobile device, correct? In that case it can't work like that because there's nothing in your connection string to indicate that the database is on the device. The path you're specifying will be interpreted as relative to the folder containing the current EXE. You need to specify the same path you would need to use to access the file in Windows Explorer. If the device is connected to the network then that would presumably require either a UNC path or a mapped network drive. If the device is connected directly to the desktop machine then I don't know but I'd guess that the device would appear as a drive. Regardless, simply navigate to the SDF file in Windows Explorer and you've got your path.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

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

    Re: sqlCE & sqlClient.. is this possible?

    Hi,
    OK - you can't do that directly, open a database on the device from a windows forms application.

    You can open a database on the device, and a database on the desktop (using the network), but you can't open a database on the device without using a 3rd party tool, or writing your own 'plumbing'.

    The exception would be if your PPC could act as a USB drive which SOME devices can. In that case you would treat it as another disk drive.

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

  16. #16

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2006
    Posts
    398

    Re: sqlCE & sqlClient.. is this possible?

    PPC that im using now doesnt act as a disk drive. i simply open its content on the explore of the active sync. and the usual path that i get is just program files/foldername/filename..
    no drives.

    what is plumbing anyway?
    ________
    Mercury Turnpike Cruiser Picture
    Last edited by rothj0hn; Feb 15th, 2011 at 01:53 PM.

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

    Re: sqlCE & sqlClient.. is this possible?

    Plumbing: writing your own routines to access the database on the device and pass it across the network
    Pete Vickers
    MVP - Device Application Development
    http://www.gui-innovations.com http://mobileworld.appamundi.com/blogs/

  18. #18
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: sqlCE & sqlClient.. is this possible?

    Quote Originally Posted by rothj0hn View Post
    PPC that im using now doesnt act as a disk drive. i simply open its content on the explore of the active sync. and the usual path that i get is just program files/foldername/filename..
    no drives.
    Think about it. Would you really expect that path to lead to the database file on the device from the desktop? How would your desktop app know that the path was on an attached device?
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  19. #19

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2006
    Posts
    398

    Re: sqlCE & sqlClient.. is this possible?

    thats what im trying to find out..
    ________
    Toyota rav4 ev history
    Last edited by rothj0hn; Feb 15th, 2011 at 01:53 PM.

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

    Re: sqlCE & sqlClient.. is this possible?

    Just messing in Explorer in Vista - I can actually navigate to a path using
    Computer\Petes_Serra\\\My Documents\ - Petes_Serra being the name of my phone.

    Having said that, I doubt if it would work using SqlServer to address it, and it looks to be Vista specific.

    I really think you are down to using a 3rd party solution, or attempting to write your own.

    You could always do it the other way round - access your desktop database, and device database from your device
    Last edited by petevick; Jul 6th, 2009 at 01:19 AM.
    Pete Vickers
    MVP - Device Application Development
    http://www.gui-innovations.com http://mobileworld.appamundi.com/blogs/

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