How can a SQL Server CE database be simultaneously connectable and un-?

后端 未结 1 380
死守一世寂寞
死守一世寂寞 2021-01-26 01:53

I have a SQL Server CE database in my Windows CE app. I can see it (HHS.sdf) in my project in Server Explorer:

\"ent

1条回答
  •  走了就别回头了
    2021-01-26 02:25

    Well first I'll say that I have never, ever, ever used the "Add Connection" stuff to try to connect directly to a database on the device. May pas dozen-plus years of developing for Windows CE have taught me that just about anything that requires interaction between the PC and the device outside of the debugger itself is fraught with peril. ActiveSync == "There be Monsters Here" on the map.

    So am I surprised this doesn't work? Not at all. I'm actually more surprised it's even an option on the dialog. It's possible that maybe the device version of SQL CE and the PC version differ, and it's that difference that's making it so the desktop can't read the remove file properly. Or maybe it's just a buggy connection (again, see "ActiveSync").

    So how do you move forward? Easy. Copy the database from the device to the PC, then open up the PC copy with Studio. Seriously. That's exactly how I do it, and it works just fine.

    I think I've already recommended this to you before, but it's worth repeating. Avoid DataTables. They are gigantic memory hogs, and under CE you can't afford a memory hog. Basically it duplicates the entire source table into RAM for you. SqlCeDataReader and SqlCeResultSet are your friends.

    0 讨论(0)
提交回复
热议问题