PC Review


Reply
Thread Tools Rate Thread

how to connect SQL CE database on PocketPC

 
 
Microsoft
Guest
Posts: n/a
 
      8th Mar 2004
I have one SQL CE database (two tables : one has 100 records, another has
30,000+ records) on my PocketPC.
And I try a lot of ways to connect and query it.

What components I have to use?
What commands I have to use?
How can I query it?

Thank you so much for any help.

Regards,
(E-Mail Removed)


 
Reply With Quote
 
 
 
 
Jon Skeet [C# MVP]
Guest
Posts: n/a
 
      8th Mar 2004
Microsoft <(E-Mail Removed)> wrote:
> I have one SQL CE database (two tables : one has 100 records, another has
> 30,000+ records) on my PocketPC.
> And I try a lot of ways to connect and query it.
>
> What components I have to use?
> What commands I have to use?
> How can I query it?


Use SqlCeDataAdapter, SqlCeConnection, SqlCeCommand etc. The
documentation for each of them should provide you with enough
information to go from there, if you've got other ADO.NET experience -
if not, look through a "normal" (desktop) ADO.NET tutorial first.

--
Jon Skeet - <(E-Mail Removed)>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
 
Reply With Quote
 
Microsoft
Guest
Posts: n/a
 
      8th Mar 2004
Yes, I try it, but fail.

My code is like this :
Dim SqlConnection1 As New System.Data.SqlClient.SqlConnection

Dim SqlSelectCommand1 As New System.Data.SqlClient.SqlCommand

Dim SqlDataAdapter1 As New System.Data.SqlClient.SqlDataAdapter

Dim SqlDataSet1 As New System.Data.DataSet

SqlConnection1.ConnectionString = "data source=" &
openFileDialog1.FileName() & ";Password=abc;persist security
info=True;packet size=4096"

SqlDataAdapter1.SelectCommand = SqlSelectCommand1

SqlSelectCommand1.CommandText = "SELECT * from tblBook"

SqlSelectCommand1.Connection = SqlConnection1

SqlConnection1.Open()

SqlDataAdapter1.Fill(SqlDataSet1)

SqlDataAdapter1.TableMappings.Add("tblBook", "strBookFullThai")

SqlDataSet1.Tables("tblBook").Columns("strBookFullThai")






"Jon Skeet [C# MVP]" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Microsoft <(E-Mail Removed)> wrote:
> > I have one SQL CE database (two tables : one has 100 records, another

has
> > 30,000+ records) on my PocketPC.
> > And I try a lot of ways to connect and query it.
> >
> > What components I have to use?
> > What commands I have to use?
> > How can I query it?

>
> Use SqlCeDataAdapter, SqlCeConnection, SqlCeCommand etc. The
> documentation for each of them should provide you with enough
> information to go from there, if you've got other ADO.NET experience -
> if not, look through a "normal" (desktop) ADO.NET tutorial first.
>
> --
> Jon Skeet - <(E-Mail Removed)>
> http://www.pobox.com/~skeet
> If replying to the group, please do not mail me too



 
Reply With Quote
 
Jon Skeet [C# MVP]
Guest
Posts: n/a
 
      8th Mar 2004
Microsoft <(E-Mail Removed)> wrote:
> Yes, I try it, but fail.
>
> My code is like this :


Right, and what goes wrong? Bear in mind that when you fill a DataSet,
it will only create tables called Table, Table1, Table2 etc as far as I
know.


--
Jon Skeet - <(E-Mail Removed)>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
 
Reply With Quote
 
Franky
Guest
Posts: n/a
 
      8th Mar 2004
If you whant to use CsqlCE you need to use SQLCE objects like this:
if(System.IO.File.Exists(@"\My Documents\TestDB.sdf"))
{
SqlCeConnection oConn = new SqlCeConnection(@"Data Source=\My
Documents\TestDB.sdf");
SqlCeCommand sqlProd;

sqlProd = new SqlCeCommand("SELECT * from tblBook", oConn);

SqlCeDataAdapter daProduct = new SqlCeDataAdapter(sqlProd);
if (daProduct == null)
{
dtsProduct = new DataSet();
}
dtsProduct.Clear();
daProduct.Fill(dtsProduct,"tblBook");
DataGrid1.DataSource = dtsProduct.Tables["tblBook"];
}


____________________
Franky
(E-Mail Removed)



"Microsoft" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Yes, I try it, but fail.
>
> My code is like this :
> Dim SqlConnection1 As New System.Data.SqlClient.SqlConnection
>
> Dim SqlSelectCommand1 As New System.Data.SqlClient.SqlCommand
>
> Dim SqlDataAdapter1 As New System.Data.SqlClient.SqlDataAdapter
>
> Dim SqlDataSet1 As New System.Data.DataSet
>
> SqlConnection1.ConnectionString = "data source=" &
> openFileDialog1.FileName() & ";Password=abc;persist security
> info=True;packet size=4096"
>
> SqlDataAdapter1.SelectCommand = SqlSelectCommand1
>
> SqlSelectCommand1.CommandText = "SELECT * from tblBook"
>
> SqlSelectCommand1.Connection = SqlConnection1
>
> SqlConnection1.Open()
>
> SqlDataAdapter1.Fill(SqlDataSet1)
>
> SqlDataAdapter1.TableMappings.Add("tblBook", "strBookFullThai")
>
> SqlDataSet1.Tables("tblBook").Columns("strBookFullThai")
>
>
>
>
>
>
> "Jon Skeet [C# MVP]" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > Microsoft <(E-Mail Removed)> wrote:
> > > I have one SQL CE database (two tables : one has 100 records, another

> has
> > > 30,000+ records) on my PocketPC.
> > > And I try a lot of ways to connect and query it.
> > >
> > > What components I have to use?
> > > What commands I have to use?
> > > How can I query it?

> >
> > Use SqlCeDataAdapter, SqlCeConnection, SqlCeCommand etc. The
> > documentation for each of them should provide you with enough
> > information to go from there, if you've got other ADO.NET experience -
> > if not, look through a "normal" (desktop) ADO.NET tutorial first.
> >
> > --
> > Jon Skeet - <(E-Mail Removed)>
> > http://www.pobox.com/~skeet
> > If replying to the group, please do not mail me too

>
>



 
Reply With Quote
 
Valentin Iliescu
Guest
Posts: n/a
 
      8th Mar 2004
You must use the classes from the System.Data.SqlServerCe
namespace (SqlCeEngine, SqlCeConnection, SqlCeDataAdapter,
SqlCeCommand etc.) not from the System.Data.SqlClient
namespace.

>-----Original Message-----
>I have one SQL CE database (two tables : one has 100

records, another has
>30,000+ records) on my PocketPC.
>And I try a lot of ways to connect and query it.
>
>What components I have to use?
>What commands I have to use?
>How can I query it?
>
>Thank you so much for any help.
>
>Regards,
>(E-Mail Removed)
>
>
>.
>

 
Reply With Quote
 
Jon Skeet [C# MVP]
Guest
Posts: n/a
 
      8th Mar 2004
Franky <(E-Mail Removed)> wrote:
> If you whant to use CsqlCE you need to use SQLCE objects like this:


<snip>

Whoops - yes, having already pointed the OP to the SqlCe* classes, I
didn't notice that he then hadn't used them...

--
Jon Skeet - <(E-Mail Removed)>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
 
Reply With Quote
 
Valentin Iliescu
Guest
Posts: n/a
 
      8th Mar 2004
For example, to create a new SQL CE database, you use this
code (the new database will be created in the "Test.sdf"
file):

Dim connStr As String = "Data Source = Test.sdf; Password
= <password>"

Dim engine As New SqlCeEngine(connStr)
engine.CreateDatabase()
engine.Dispose()

To connect to this database use:

Dim conn As SqlCeConnection
conn = New SqlCeConnection(connStr)
conn.Open()


>-----Original Message-----
>I have one SQL CE database (two tables : one has 100

records, another has
>30,000+ records) on my PocketPC.
>And I try a lot of ways to connect and query it.
>
>What components I have to use?
>What commands I have to use?
>How can I query it?
>
>Thank you so much for any help.
>
>Regards,
>(E-Mail Removed)
>
>
>.
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Can't connect to SqlServer anymore! (from PocketPC) Lloyd Dupont Microsoft Dot NET Compact Framework 4 21st Sep 2004 08:53 PM
I can not connect SqlServer2000 with PocketPC with WIFI =?Utf-8?B?RmxhdHRyb24=?= Microsoft Dot NET Compact Framework 3 23rd Aug 2004 11:05 PM
Cannot connect to SQL via the PocketPC emulator. Byron Hopp Microsoft VB .NET 0 30th May 2004 09:40 PM
Re: Connect PocketPC to SQL Server Paul G. Tobey [eMVP] Microsoft Dot NET Compact Framework 6 26th May 2004 07:06 PM
Can't connect to pocketpc? Dave Corun Microsoft Dot NET Compact Framework 8 28th Jul 2003 12:35 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:06 AM.