Direct connection to SQL Server 2005 from a mobile device

H

Hezal

Hi,
I've created an SQL Server database and I've created a smart device
application in visual studio 2005. I then added the SQL Server database as a
data source to this project. Then I used one table from the database to
display it on the mobile device's form. I also don't know if thats the right
way to directly access the SQL SERVER database from a mobile device using
SQLClient .
When I build it, there is no error.
But when I debug it through the emulator I get the following error:

this._connection = new System.Data.SqlClient.SqlConnection();
this._connection.ConnectionString = "Data
Source=.\\SQLEXPRESS;AttachDbFilename=|DataDirectory|\\MainRestaurantManagementdb.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True;";
}

Can anyone help me please, I'm really stuck?

Thanks,
 
S

Simon Hart [MVP]

Lose the integrated security. Explicitly define a user id and password
instead.
 
H

Hezal

Thanks Simon.
Since I am using Vista I had to run the VS 2005 as the Administrator which
I din't before so that's why the connection couldn't be made directly to the
SQL Server database. In other words I couldn't create a SQL Server database
unless I am the admin.
Now I've sorted that problem by correcting the connection srting to
explicity connect rather than attaching the db as a file...

Chris, that link was very helpful, I followed the guidelines but I am
getting another error when I debug:

" int returnValue = this.Adapter.Fill(dataTable); "

exception was unheld.
But this is an automatically generated code so any ideas how I can overcome
this ?

Thanks,
Hezal
 
G

Grzegorz Makarewicz

Hezal said:
Hi,
I've created an SQL Server database and I've created a smart device
application in visual studio 2005. I then added the SQL Server database as a
data source to this project. Then I used one table from the database to
display it on the mobile device's form. I also don't know if thats the right
way to directly access the SQL SERVER database from a mobile device using
SQLClient .
When I build it, there is no error.
But when I debug it through the emulator I get the following error:

this._connection = new System.Data.SqlClient.SqlConnection();
this._connection.ConnectionString = "Data
Source=.\\SQLEXPRESS;AttachDbFilename=|DataDirectory|\\MainRestaurantManagementdb.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True;";
}

Can anyone help me please, I'm really stuck?

Just google about Your platform (PPC/SP) and ODBC connection strings,
then look at security - I use only user/password connections, not NTLM
and it just works:

Server=192.168.2.1[\named_instance];Database=dbname;Uid=user;Pwd=password

mak
 

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