connect to sql server

jason2

Member
Joined
Feb 17, 2007
Messages
8
Programming Experience
Beginner
hi,
i try to build a app for a pda device and i want that app comunicate with a sql server on other machine.
Now i have problems with very small resources with the compact framework anyone know who can i connect to a sql server with compact framework and execute some sql commands?

thanks for the help
Bruno
 
you can add a reference to SQLClient inside your Compact Framework application.

then you can connect to sql server directly from your device (providing the device has network connection (Wifi,GPRS, or over ActiveSync)

sqlconnection string
Persist Security Info=False;Integrated Security=False;Server=192.168.1.1;initial catalog=<DATABASE NAME>;user id=<USER ID>;password=<PASSWORD;
 
hi,
thanks for the help :)

but a still have some question who can i connect to a sql server and send querys?
i have this but don´t work

Dim cnn As System.Data.SqlClient.SqlConnection
Dim cmd As System.Data.SqlClient.SqlCommand


cmd.CommandText =
"Persist Security Info=False;Integrated Security=False;Server=192.168.1.14;initial catalog=new;user id=sa;password=14;"
cnn.Open()

what i doing wrong?
thans a lot for the help
:)
 
Last edited:
in the code you posted you are not creating an instance of the SqlConnection or the SqlCommand.

Dim l_sqlConn As New SqlConnection("Persist Security Info=False;Integrated Security=False;Server=192.168.1.14;initial catalog=new;user id=sa;password=14;")

l_sqlConn.Open

Dim l_sqlCmd As SqlCommand

l_sqlCmd = l_sqlConn.createCommand
l_sqlCmd.CommandText = "SELECT * FROM tbl_myTable"

also put a try catch around what you are trying to do
 
hi, i have this code:

Dim l_sqlConn As New System.Data.SqlClient.SqlConnection("Persist Security Info=False;Integrated Security=False;Server=192.168.2.114;initial catalog=new_one;user id=sa;password=1234;")

l_sqlConn.Open()


Dim l_sqlCmd As System.Data.SqlClient.SqlCommand
l_sqlCmd = l_sqlConn.createCommand
l_sqlCmd.CommandText =
"SELECT * FROM clientes"

but they display this error: sql server does not exist or acess denied

what i doing wrong? :confused:

thanks a lot for the help :)
 
you may need to put in the port number that sqlserver uses.
try this as your connectionstring
"Data Source=192.168.2.114,<PORT_NUMBER>;Initial Catalog=new_one;User ID=sa;Password=1234;"

If that doesnt work it sounds like wrong IPaddress, wrong user, wrong password, firewall blocking access.
 
Back
Top