I'm not using VS.NET's Server Explorer. Below is a copy of my code, I
replaced my sa password with password for this post (for security purposes).
The code works when I change Server=(db) to Server=(local), db is the remote
server. My local license database is a copy of db license database.
The error occurs at oCn.Open(), the error message is "
See the end of this message for details on invoking
just-in-time (JIT) debugging instead of this dialog box.
************** Exception Text **************
System.Data.SqlClient.SqlException: SQL Server does not exist or access
denied.
at System.Data.SqlClient.ConnectionPool.GetConnection(Boolean&
isInTransaction)
at
System.Data.SqlClient.SqlConnectionPoolManager.GetPooledConnection(SqlConnectionString options, Boolean& isInTransaction)
at System.Data.SqlClient.SqlConnection.Open() ……………………"
string sConnString = "Server=(db);Database=License;Integrated
Security=False;User ID=sa;password=password";
string sProc = "prGet_DealerInfo";
using (SqlConnection oCn = new
SqlConnection(sConnString))
{
using (SqlCommand oCmd = new
SqlCommand(sProc, oCn))
{
oCn.Open();
oCmd.CommandType =
CommandType.StoredProcedure;
oCmd.Parameters.Add("@sDealerNum", SqlDbType.NChar, 6);
oCmd.Parameters["@sDealerNum"].Value = txtDealerNum.Text;
oCmd.Parameters.Add("@sSaleID", SqlDbType.Int, 10);
oCmd.Parameters["@sSaleID"].Direction = ParameterDirection.Output;
oCmd.Parameters.Add("@sSiteName", SqlDbType.NVarChar, 40);
oCmd.Parameters["@sSiteName"].Direction = ParameterDirection.Output;
oCmd.Parameters.Add("@sName", SqlDbType.NVarChar, 40);
oCmd.Parameters["@sName"].Direction = ParameterDirection.Output;
oCmd.Parameters.Add("@sAmount", SqlDbType.Decimal, 10);
oCmd.Parameters["@sAmount"].Direction = ParameterDirection.Output;
oCmd.ExecuteNonQuery();
oCn.Close();
string sSaleID =
oCmd.Parameters["@sSaleID"].Value.ToString();
string sSiteName =
oCmd.Parameters["@sSiteName"].Value.ToString();
string sName =
oCmd.Parameters["@sName"].Value.ToString();
string sAmount =
oCmd.Parameters["@sAmount"].Value.ToString();
}
}
Also, I checked ODBC connections and added db to User DSN, System DSN and
File DSN but still get same error when I run the code.