SQL exception

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I encountered an SQL exception when I load the following codes. The exception "SQL server does not exist or access denied, Line 0 .NET sqlclient data provider". I used the .NET smart device application and run it with its emulator or with a PDA the above exception occurred occasionally but if I run it using the compiled exe application on my computer it works perfectly. Can anyone help? Thanks alots for ur attention


string tempStr = "SELECT CountryCode " +
"FROM Inventory_Dept_Mapping " +
"WHERE (DeptCode = @DeptCode) " +
"GROUP BY CountryCode"
DataSet tempDS = new DataSet()
SqlCommand sqlCom = new SqlCommand(tempStr, new SqlConnection(DataBaseConnectionString))
sqlCom.Parameters.Add("@DeptCode", SqlDbType.VarChar)
sqlCom.Parameters["@DeptCode"].Value = this.DeptCode
SqlDataAdapter sAdapter = new SqlDataAdapter(sqlCom)
try

sAdapter.Fill(tempDS, "ctrycode")

catch (SqlException ex

MessageBox.Show(ex.Message + "\nLine " + ex.LineNumber + "\n" + ex.Source)
}
 
I think it's related to your connection string and the authentication
parameters accepted by your SQLServer instance .....

--
ihookdb
Get your data mobile
http://www.ihookdb.com


angka said:
I encountered an SQL exception when I load the following codes. The
exception "SQL server does not exist or access denied, Line 0 .NET sqlclient
data provider". I used the .NET smart device application and run it with its
emulator or with a PDA the above exception occurred occasionally but if I
run it using the compiled exe application on my computer it works perfectly.
Can anyone help? Thanks alots for ur attention.
string tempStr = "SELECT CountryCode " +
"FROM Inventory_Dept_Mapping " +
"WHERE (DeptCode = @DeptCode) " +
"GROUP BY CountryCode";
DataSet tempDS = new DataSet();
SqlCommand sqlCom = new SqlCommand(tempStr, new SqlConnection(DataBaseConnectionString));
sqlCom.Parameters.Add("@DeptCode", SqlDbType.VarChar);
sqlCom.Parameters["@DeptCode"].Value = this.DeptCode;
SqlDataAdapter sAdapter = new SqlDataAdapter(sqlCom);
try
{
sAdapter.Fill(tempDS, "ctrycode");
}
catch (SqlException ex)
{
MessageBox.Show(ex.Message + "\nLine " + ex.LineNumber + "\n" + ex.Source);
}
 
But it is only occassionally

string DataBaseConnection = "uid=username; server=devel-server; database=devel-db; pwd=password

this is the connection string that I am using and the window form counter part have no such problem
Is there some level of prematurity to the .Net compact framework network stack? This is one of the possible reason I can think of. The Sql exception always thrown at the .Fill method. Thanks alots.
 
Ok, my 1st idea was wrong.
I have another idea (might be wrong too), use IP of server instead of server
name in the server property

--
ihookdb
Get your data mobile
http://www.ihookdb.com


angka said:
But it is only occassionally.

string DataBaseConnection = "uid=username; server=devel-server;
database=devel-db; pwd=password"
this is the connection string that I am using and the window form counter part have no such problem.
Is there some level of prematurity to the .Net compact framework network
stack? This is one of the possible reason I can think of. The Sql exception
always thrown at the .Fill method. Thanks alots.
 
Back
Top