I have a application in which in app.config i mentioned my connection string such as
connectionString="Data Source=ASPKCO-DANISH\SQLEXPRESS1;Initial Catalog=DMS2008;Integrated Security=True;Connect Timeout=30"
providerName="System.Data.SqlClient" />
and in code i am using this line
public ClsUserLoging IsValidLog(string UserID, string PassWord)
{
try
{
objClsUsers = null;
con = new SqlConnection(DMS_2008_Data.Properties.Settings.Default.DataConnection.ToString());
con.Open();
com = new SqlCommand();
com.Connection = con;
com.CommandType = CommandType.Text;
com.CommandText = "SELECT UserName, IsNever, CreateDate, ValidDays, ExpireDate FROM Users WHERE (UserID = @UserID) AND (UserPassWord = @UserPassWord)";
com.Parameters.Add("@UserID", SqlDbType.NVarChar, 30).Value = UserID.ToString().Trim();
com.Parameters.Add("@UserPassWord", SqlDbType.NVarChar, 60).Value = PassWord.ToString().Trim();
reader = com.ExecuteReader();
while (reader.Read())
{
objClsUsers = new ClsUserLoging();
objClsUsers.UserName = reader.GetString(0).ToString();
objClsUsers.Never = reader.GetBoolean(1);
objClsUsers.CreateDate = reader.GetDateTime(2);
objClsUsers.ValidDays = (short)reader.GetInt32(3);
objClsUsers.ExpireDate = reader.GetDateTime(4);
}
reader.Close();
com.Parameters.Clear();
}
catch (Exception ex)
{
objClsUsers = null;
throw ex;
}
finally
{
if (com != null)
com.Dispose();
if (con != null)
con.Dispose();
com = null;
con = null;
}
return objClsUsers;
}
I am getting an error a network or instance related error occured and there is not issue with DB and connection string because i am using another web application accessing the same db using web.config please assist

Danish HabibRank #2,024 · 715 reputationPosted Oct 13, 2015, 1:25 AM EDT
Mukesh KumarRank #119 · 18.2K reputationPosted Oct 11, 2015, 9:48 PM EDT
Danish HabibRank #2,024 · 715 reputationPosted Oct 11, 2015, 9:51 PM EDT
Ravi PatelRank #439 · 5.7K reputationPosted Oct 11, 2015, 9:51 PM EDT
Danish HabibRank #2,024 · 715 reputationPosted Oct 11, 2015, 11:01 PM EDT
Ravi PatelRank #439 · 5.7K reputationPosted Oct 11, 2015, 11:18 PM EDT
Danish HabibRank #2,024 · 715 reputationPosted Oct 11, 2015, 11:25 PM EDT
Ravi PatelRank #439 · 5.7K reputationPosted Oct 11, 2015, 11:38 PM EDT
Danish HabibRank #2,024 · 715 reputationPosted Oct 11, 2015, 11:45 PM EDT
Danish HabibRank #2,024 · 715 reputationPosted Oct 11, 2015, 11:48 PM EDT
Ravi PatelRank #439 · 5.7K reputationPosted Oct 12, 2015, 1:21 AM EDT
Danish HabibRank #2,024 · 715 reputationPosted Oct 12, 2015, 10:15 PM EDT
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questionsTop experts