connect to my cdb file...

  • Thread starter Thread starter amiga500
  • Start date Start date
A

amiga500

Hello,

I have a cdb file called data.cdb stored into my PocketPC. Below is my
code, I am using msgbox for debugging purpose:

' Here we I do all the necessary coding to display the contents in
Dim strHandHeld As String = TheReaderData.Text
Dim Conn As New SqlConnection("User
ID=DSUSER;PASSWORD=silentk;Data Source=NTSERVER-2;Initial
Catalog=Direct Source System;Persist Security Info=False;Packet
Size=4096")
Dim objDataReader As SqlDataReader = Nothing
Dim myCommand As New SqlCommand()
Dim strSQL As String = "SELECT Item_Number FROM Product WHERE
UPC = '" & Mid(strHandHeld, 1, 1) & " " & Mid(strHandHeld, 2, 5) & " "
& Mid(strHandHeld, 7, 5) & " " & Mid(strHandHeld, 12, 1) & "'"
txtUPC.Text = Mid(strHandHeld, 1, 1) & " " & Mid(strHandHeld,
2, 5) & " " & Mid(strHandHeld, 7, 5) & " " & Mid(strHandHeld, 12, 1)
Dim strLocation As String = ""
MsgBox("1")
Dim objSQLCeCommand As System.Data.SqlServerCe.SqlCeCommand =
Nothing
MsgBox("2")
Dim objSQLCeConnection As New
System.Data.SqlServerCe.SqlCeConnection("Data Source=\Data.cdb")
MsgBox("3")
Dim objSQLCeDataReader As
System.Data.SqlServerCe.SqlCeDataReader = Nothing
MsgBox("4")
objSQLCeConnection.Open()
MsgBox("5")
objSQLCeCommand = New
System.Data.SqlServerCe.SqlCeCommand(strSQL, objSQLCeConnection)
MsgBox("6: " & strSQL)
objSQLCeDataReader = objSQLCeCommand.ExecuteReader
MsgBox("7: " & objSQLCeCommand.ExecuteReader.Read)
MsgBox(objSQLCeDataReader("Item_Number"))
MsgBox("8")
objSQLCeConnection.Close()
MsgBox("9")
MsgBox("Arrived safely")

Anyways as soon as the line hits for number 4 it refuses to open the
connection...this is how I am connecting to my data.cdb:

Dim objSQLCeConnection As New
System.Data.SqlServerCe.SqlCeConnection("Data Source=\Data.cdb")

is this wrong? If so how do I connect to my .cdb file in my PocketPC?
Thanks, appreciate it big time.
 
CDB files are not SQL CE files, so the SqlCE classes cannot open them. CDBs
are a deprecated Pocket Access format and there are no built-in managed
libraries for talking to them. InTheHand does have a commercial solution
that works well.
 
Are you telling me there are absolutely no alternative what so ever but
to get a third party program to do this?
 
There's always some alternative, but not necessarily a practical one. You
could wrap the deprecated API yourself.

Paul T.
 
No. If it *must* be a CDB then you have 2 options:
1. Use a third-party library
2. Write your own library P/Invoking the system APIs to talk to the CDB.

#2 is a lot of work, which is why the 3rd party libraries exist in the first
place.

If the CDB is not a requirement, then you could use a number of other better
supported database formats, like SQL CE/Mobile/Everywhere/Anywhere or MySQL.
 
Back
Top