Hi!
My program worked very well untill yesterday, when i was running it, my grid view that got data source from a data table of sql data base didn't show any thing. i tried to understand what was wrong with a break point, i understood that program jumps this part and doesn't connect to data base:
SqlConnection cs = new SqlConnection("Data Source=.\\local_2008; Initial Catalog=Library; User Id=userLibrary; Password=123456");
the interesting part is that, it doesn't show any error and when i used try/catch the exception doesn't show anything about error.
and what made me crazy is that when i use a breakpoint on this line to get the error and select the part and use Quick Watch it shows no error and then i click f5 to continue the program works as it should and shows the table!!!!!!
please help me to solve this unbelievable problem
thank you
SqlConnection cs = new SqlConnection("Data Source=.\\local_2008; Initial Catalog=Library; User Id=userLibrary; Password=123456");
SqlCommand cmd = new SqlCommand("searchBook", cs);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add("@biCode", SqlDbType.Int).Value = biCode;
cmd.Parameters.Add("@biName", SqlDbType.NVarChar).Value = biName;
cmd.Parameters.Add("@biAuthor", SqlDbType.NVarChar).Value = biAuthor;
cmd.Parameters.Add("@biTranslator", SqlDbType.NVarChar).Value = biTranslator;
cmd.Parameters.Add("@biPublisher", SqlDbType.NVarChar).Value = biPublisher;
cmd.Parameters.Add("@biSubject", SqlDbType.Int).Value = biSubject;
cmd.Parameters.Add("@biStatus", SqlDbType.Int).Value = biStatus;
cmd.Parameters.Add("@biIssueDate", SqlDbType.VarChar).Value = biIssueDate;
cmd.Parameters.Add("@biLink", SqlDbType.NVarChar).Value = biLink;
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataTable dt = new DataTable();
da.Fill(dt);
return dt;
Good news:
I used app.config again and the old error didn't happened again but now it jumps out from da.Fill(dt) with
Instance failure
error now what should i do?
new part:
string str = System.Configuration.ConfigurationManager.AppSettings["cs"];
SqlConnection cs = new SqlConnection(str);