Call a stored proc. from a Smart Device.

G

Guest

Hi,
I am needing to call a stored proc. from a Smart Device app in VS .NET.
Does anyone have an example of this?
Thanks,
Steve
 
G

Guest

Hi!

Use System.Data.SqlClient namespace and call stored procedures on your SQL
Server like from typical Windows app.

Regards!
Krzysztof
 
G

Guest

Hi!

Thanks for the responses. I am kind of struggling here. I have gone into
VS .NET and created a VB .NET Smart Devise project. On the default form, I
put a button, on the click event of the button, I tried to put in the code to
call a stored procedure from the link
http://www.knowdotnet.com/articles/storedprocsvb.html
..

It says about everything in there is undefined. I want to just add the code
to this click event to call the stored proce, or one of the Northwind ones,
just to get me going. What would I be doing wrong??

Thanks again,
Steve
 
G

Guest

I thought maybe I was missing an Imports statement. I tried putting in
Imports System.Data.SqlClient
like I would in a VB Windows form, but is says the SqlClient is not
recognized. . ?
 
G

Guest

I tried putting the Imports System.Data.SqlClient
as the first line, right before Public Class Form1,
but it doesn't see the SqlClient. says it is undefined?
 
D

Daniel Moth

The Imports statement saves you from fully qualifying the classes of a
namespace. To actually use the namespaces/classes of an assembly you need to
reference the assembly they are in. Right click on references in solution
explorer and add SqlClient (like Bill suggested).

Cheers
Daniel
 
G

Guest

Daniel,
Thanks for advising me on right clicking and adding the reference. When I
did that I was able to add the Imports statement. Thanks.

I am still stuck. I have a VB .NET Smart Device project open. I added one
button, and on the click event I added the following code:

Dim mySelectQuery As String = "SELECT OrderID, CustomerID FROM Orders"
Dim myConnection As New SqlConnection("Initial Catalog=Northwind;" & _
"Data Source=COMPUTER-CD9T4F;Integrated Security=SSPI;")
Dim myCommand As New SqlCommand(mySelectQuery, myConnection)
myConnection.Open()
Dim myReader As SqlDataReader
myReader = myCommand.ExecuteReader()
While myReader.Read()
Console.WriteLine((myReader.GetInt32(0) & ", " &
myReader.GetString(1)))
End While
myReader.Close()
myConnection.Close()

I'm pretty sure the connection is good, I wrote a Window Form app and cut
the SqlConnection from that. When I deploy this to the CE emulator in VS
..NET, and when I click the button, I get:

An unhandled exception of type 'System.Data.SqlClient.SqlException' occurred
in System.Data.SqlClient.dll

Additional information: SqlException

I just can't seem to get this thing right. All I want to do is connect from
a Smart Device app to the SQL server.

Any thoughts?

Thanks,
Steve
 
S

Sergey Bogdanov

If you want to use Integrated Security you must explicitly set User ID
and Password:

"Integrated Security=SSPI;User
ID=<domain>\<username>;Password=<password>;..."

also you may try use SQL Server Authentication:

"User ID=sa;Password=<your password>;Initial Catalog=Northwind;Data
Source=COMPUTER-CD9T4F;"

Hope this help,
Sergey Bogdanov
http://www.sergeybogdanov.com
 
G

Guest

Sergey,
I switched it over to SQL Server Authentication, and I still get the same
error on the myConnection.Open() statement. I get seem to get it.
Steve
 
G

Guest

...and I cut this code out and put it on a plain windows form project and it
connected and worked. So I guess i am just not getting the connection from
the CE emulator?

I really appreciate everyone who has hopped in and tried to get me going!

Steve
 
S

Sergey Bogdanov

Can you somehow verify that COMPUTER-CD9T4F is available from your
device? What about set IIS and try to connect from IE on your device?

Best regards,
Sergey Bogdanov
http://www.sergeybogdanov.com
Sergey,
I switched it over to SQL Server Authentication, and I still get the same
error on the myConnection.Open() statement. I get seem to get it.
Steve

:
 
G

Guest

I'm not completely sure how to do that on the Windows CE emulator out of VS
..NET IDE, but I look into that now.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top