Click here to Skip to main content
15,886,689 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i create a smart device project in visual studio 2008.
i try to connect to data base in sql server 2016 with ado.net.
but a SqlException error has occurred in con.open();.
our pda device has windows ce 6 .our sqlserver is 2016.


SqlConnection con2 = new SqlConnection("Data Source = 192.168.0.48,1432;Initial Catalog = DB_ForooshgahSadraMarkazi;Integrated Security=SSPI;User ID=Test1;Password=Test1@Mostafa_1366;");


SqlDataAdapter da1 = new SqlDataAdapter("PDA_Fee", con2);
            da1.SelectCommand.CommandType = CommandType.StoredProcedure;
            da1.SelectCommand.Parameters.AddWithValue("@IdShobe", 5);
            da1.SelectCommand.Parameters.AddWithValue("@BarCodeKala", 0);
            da1.SelectCommand.Parameters.AddWithValue("@CodeDoreh",1399);
            da1.SelectCommand.Parameters.AddWithValue("@Tarikh", "1399/05/05");
            da1.SelectCommand.Parameters.AddWithValue("@IdKala", "1399/05/05");

            DataTable dt1 = new DataTable();
            con2.Open();
            da1.Fill(dt1);
            con2.Close();


What I have tried:

i used sqlconnection but a SqlException error has occurred.
Posted
Updated 1-Aug-20 4:41am
v3
Comments
Richard MacCutchan 1-Aug-20 3:37am    
Sorry, but we cannot see your screen, so we have no idea what the exception is, or where it occurs.
Sandeep Mewara 1-Aug-20 4:15am    
It would help others understand with details of error.
[no name] 1-Aug-20 4:49am    
You should also post the error/exception message.

1 solution

Because you did not post the exact exception message the following is only a guess.

You mentined the exception will be thrown at
C#
con2.Open();
Therefore most probably it is a problem with the connection string (resources). So check:
a.) Is the server 192.168.0.48 available
b.) Does the sql server really use port 1432 which is not the standard port
c.) Make sure that no firewall does block the communication for port 1432

For more help please post the exact exception message.
I hope it helps.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900