Device To SQL 2K Server Pull Uable In VB.NET

Device To SQL 2K Server Pull Uable In VB.NET

Post by MJS » Fri, 11 Oct 2002 20:46:33



I am haveing a lot of difficulty trying the following code: I have just
about exhausted every newsgroup article, microsoft whitepaper, SQL CE 2
Online Help. I want to accessa 2000 SQL server from the device connected to
a Cradle. Doesn't see difficult. I have read alot about it but get only
partial code and no thourough setup. I can access the SSCECA.DLL for the web
site but my return is

I guess I am not that familar with this stuff so I would appreciate any
help.

****** Question 1,

Why the System.Data.SqlClient is used in the Microsoft PPC example
"Inventory" and all other refrences state to use RDA in
System.Data.SqlServerCe?

****** Question 2,

Sample code from button Event on single form upon which I get the following
error after clicking on button:

An unhandled exception of type 'System.NullReferenceException' occurred in
GAC_System.Windows.Forms_v1_0_3300_0_cneutral_1.dll

I am just trying to get connected to a SQL server, not the device
SQlServerCe, but a SQL 2K Server.

Dim LocalConnectString As String =
"Provider=Microsoft.SQLSERVER.OLEDB.CE.2.0;Data Source=\My
documents\Northwind.sdf"

Dim RDAOLEDBConnectString As String = "Provider=sqloledb;Data Source=HOME1;
Initial Catalog=northwind; UserId=SA; Password=password;"

Dim InternetURLString As String = "http://home1/CEAlias/sscesa20.dll"

' This returns the following : SQL Server CE Server Agent when open in a
browser.

Dim InternetLoginString As String = "SA"

Dim InternetPasswordString As String = ""

Dim cerda As System.Data.SqlServerCe.RemoteDataAccess

Try

cerda = New System.Data.SqlServerCe.RemoteDataAccess(InternetURLString,
InternetLoginString, InternetPasswordString, LocalConnectString)

cerda.Pull("[Order Details]", "Select * from [Order Details]",
RDAOLEDBConnectString)

Catch ex As System.Data.SqlServerCe.SqlCeException

MsgBox(ex.Message & "-" & ex.NativeError.ToString & " - " &
ex.Errors.Item(0).ToString & " - " & ex.Errors.Item(1).ToString)

cerda.Dispose()

End Try

MsgBox("HERE end")

End Sub

 
 
 

Device To SQL 2K Server Pull Uable In VB.NET

Post by Larry Roo » Fri, 11 Oct 2002 22:17:25


Question #1:

System.Data.SqlClient is used when you want to work with a SQL Server
database directly, just as you would from a desktop application.
System.Data.SqlServerCe is used when you want to work with a SQL Server CE
database.

Question #2:

I recently wrote an article on accessing a SQL Server database. It is
available online at:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnro...


Quote:> I am haveing a lot of difficulty trying the following code: I have just
> about exhausted every newsgroup article, microsoft whitepaper, SQL CE 2
> Online Help. I want to accessa 2000 SQL server from the device connected
to
> a Cradle. Doesn't see difficult. I have read alot about it but get only
> partial code and no thourough setup. I can access the SSCECA.DLL for the
web
> site but my return is

> I guess I am not that familar with this stuff so I would appreciate any
> help.

> ****** Question 1,

> Why the System.Data.SqlClient is used in the Microsoft PPC example
> "Inventory" and all other refrences state to use RDA in
> System.Data.SqlServerCe?

> ****** Question 2,

> Sample code from button Event on single form upon which I get the
following
> error after clicking on button:

> An unhandled exception of type 'System.NullReferenceException' occurred in
> GAC_System.Windows.Forms_v1_0_3300_0_cneutral_1.dll

> I am just trying to get connected to a SQL server, not the device
> SQlServerCe, but a SQL 2K Server.

> Dim LocalConnectString As String =
> "Provider=Microsoft.SQLSERVER.OLEDB.CE.2.0;Data Source=\My
> documents\Northwind.sdf"

> Dim RDAOLEDBConnectString As String = "Provider=sqloledb;Data
Source=HOME1;
> Initial Catalog=northwind; UserId=SA; Password=password;"

> Dim InternetURLString As String = "http://home1/CEAlias/sscesa20.dll"

> ' This returns the following : SQL Server CE Server Agent when open in a
> browser.

> Dim InternetLoginString As String = "SA"

> Dim InternetPasswordString As String = ""

> Dim cerda As System.Data.SqlServerCe.RemoteDataAccess

> Try

> cerda = New System.Data.SqlServerCe.RemoteDataAccess(InternetURLString,
> InternetLoginString, InternetPasswordString, LocalConnectString)

> cerda.Pull("[Order Details]", "Select * from [Order Details]",
> RDAOLEDBConnectString)

> Catch ex As System.Data.SqlServerCe.SqlCeException

> MsgBox(ex.Message & "-" & ex.NativeError.ToString & " - " &
> ex.Errors.Item(0).ToString & " - " & ex.Errors.Item(1).ToString)

> cerda.Dispose()

> End Try

> MsgBox("HERE end")

> End Sub


 
 
 

Device To SQL 2K Server Pull Uable In VB.NET

Post by Kevin Boske - [MS » Sat, 12 Oct 2002 01:42:58


****** Question 1, Answer:
SqlCeRemoteDataAccess is part of the Sql Server CE product.  It is part of
the SQL Server CE namespace.  It doesn't exist for SQL Server.  The
System.Data.SqlClient namespace exists on both the desktop and the device.

****** Question 2, Answer:
 Your code is not catching generic system exceptions.  That is why you are
recieving the unhandled exception.  Add the following after your
SqlCeException catch:

Catch except As Exception

    MessageBox.Show(except.Message)

--
Kevin Boske
SQL Server CE Team
Microsoft
----------------------------------------------------------------------------
----------------------------------------
SQL Server CE Security Whitepaper:

http://www.microsoft.com/sql/techinfo/administration/2000/securitymod...
SQL Server CE Connectivity Troubleshooting Whitepaper :

http://www.microsoft.com/sql/techinfo/administration/2000/CEconnectiv...
sp

----------------------------------------------------------------------------
----------------------------------------
This posting is provided "AS IS" with no warranties, and confers no rights.
----------------------------------------------------------------------------
----------------------------------------


I am haveing a lot of difficulty trying the following code: I have just
about exhausted every newsgroup article, microsoft whitepaper, SQL CE 2
Online Help. I want to accessa 2000 SQL server from the device connected to
a Cradle. Doesn't see difficult. I have read alot about it but get only
partial code and no thourough setup. I can access the SSCECA.DLL for the web
site but my return is

I guess I am not that familar with this stuff so I would appreciate any
help.

****** Question 1,

Why the System.Data.SqlClient is used in the Microsoft PPC example
"Inventory" and all other refrences state to use RDA in
System.Data.SqlServerCe?

****** Question 2,

Sample code from button Event on single form upon which I get the following
error after clicking on button:

An unhandled exception of type 'System.NullReferenceException' occurred in
GAC_System.Windows.Forms_v1_0_3300_0_cneutral_1.dll

I am just trying to get connected to a SQL server, not the device
SQlServerCe, but a SQL 2K Server.

Dim LocalConnectString As String =
"Provider=Microsoft.SQLSERVER.OLEDB.CE.2.0;Data Source=\My
documents\Northwind.sdf"

Dim RDAOLEDBConnectString As String = "Provider=sqloledb;Data Source=HOME1;
Initial Catalog=northwind; UserId=SA; Password=password;"

Dim InternetURLString As String = "http://home1/CEAlias/sscesa20.dll"

' This returns the following : SQL Server CE Server Agent when open in a
browser.

Dim InternetLoginString As String = "SA"

Dim InternetPasswordString As String = ""

Dim cerda As System.Data.SqlServerCe.RemoteDataAccess

Try

cerda = New System.Data.SqlServerCe.RemoteDataAccess(InternetURLString,
InternetLoginString, InternetPasswordString, LocalConnectString)

cerda.Pull("[Order Details]", "Select * from [Order Details]",
RDAOLEDBConnectString)

Catch ex As System.Data.SqlServerCe.SqlCeException

MsgBox(ex.Message & "-" & ex.NativeError.ToString & " - " &
ex.Errors.Item(0).ToString & " - " & ex.Errors.Item(1).ToString)

cerda.Dispose()

End Try

MsgBox("HERE end")

End Sub