How can I connect to a SQL server(not SQL Compact Edition)Database from my Smart device. I am a bit stuck on this because the connection string does not seem to work it gives me a (Null reference error) I checked the SQLcommand text and that was working properly as well

This is the code I used

This is the connection string that was shown to me when I added the database connection and I tested the connection and it worked fine but still the data set is Null

string sConnection = "Data Source=SOFTSERVER;Initial Catalog=Resmanagement;User ID=sa;Password=thadiya";


This is the connection string i used earlier with the IP address and the Port on the server which I am connected to with a network.

string sConnection = "Data Source=192.168.1.1,1433;Initial Catalog=Resmanagement;User ID=sa;Password=thadiya;";


SqlConnection sqlceconn = new SqlConnection(sConnection);


SqlCommand command = sqlceconn.CreateCommand();

command.CommandText = "Select CashierName from REF_Cashiers";

SqlDataAdapter adapter = new SqlDataAdapter(command);

DataSet ds = new DataSet();

even though there is one record in the table it still shows this error.
is there any thing to do in addition when using smart devices apps.

I tried to populate a datagridview using your way of coding

string con = "Data Source=.\\SQLEXPRESS; Initial Catalog=tbl; Integrated Security=true";
            SqlConnection sqlcon = new SqlConnection(con);
            SqlCommand cmd = sqlcon.CreateCommand();
            cmd.CommandText = "SELECT * FROM tbl";
            SqlDataAdapter da = new SqlDataAdapter(cmd);
            DataSet ds = new DataSet();
            da.Fill(ds);
            dataGridView1.DataSource = ds.Tables[0];

It works, I don't really know what's wrong..
Maybe you forgot to fill the dataset..

I tried to populate a datagridview using your way of coding

string con = "Data Source=.\\SQLEXPRESS; Initial Catalog=tbl; Integrated Security=true";
            SqlConnection sqlcon = new SqlConnection(con);
            SqlCommand cmd = sqlcon.CreateCommand();
            cmd.CommandText = "SELECT * FROM tbl";
            SqlDataAdapter da = new SqlDataAdapter(cmd);
            DataSet ds = new DataSet();
            da.Fill(ds);
            dataGridView1.DataSource = ds.Tables[0];

It works, I don't really know what's wrong..
Maybe you forgot to fill the dataset..

maybe its because when i try to add a new data source halfway through tha data source wizzard it gives me this error

-------------------------------------------------------------------------------------
un expected error has occurred

error message: Could not load type

Microsoft.visualStudio.DataDesign.SyncDesigner.SyncFacede.SyncManager,from Assembly

Microseoft.VisualStudio.DataDesign.SyncDesigner.DslPackage
Version=9.0.0.0 culture=neutral,PublicKeyToken=b03f5f7ff11d50a3a'.
-------------------------------------------------------------------------------------

is there any way pass this because it will not let me add a new data source.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.