Click here to Skip to main content
15,880,405 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
In the server(SQL Server-2005) I have two database. They are TERMSUS and TERMSSUP.
In the following codes when I close the connection for TERMSUS then run a select query from another database and that is TERMSSUP. After the select query I open the connection for TERMSSUP. Can anyone help me about connection? How can the second select query execute before opening the connection?

C#
ConManager.DBConnection("TERMSUS");
DataTable DTLocalEmp = new DataTable();
string EmpCode = string.Empty;
string strSQLE = "select EmpCode from tblUser where UserLoginId='"+Session["USER"].ToString()+"'";
ConManager.OpenDataTableThroughAdapter(strSQLE, out DTLocalEmp, true);
ConManager.CloseConnection();
EmpCode = DTLocalEmp.Rows[0]["EmpCode"].ToString();
strSQL = "";
strSQL = "select * from tblSheduleEntry where EmpCode='" + EmpCode + "'";
ConManager.DBConnection("TERMSSUP");
DataTable DTLocal = new DataTable();
ConManager.OpenDataTableThroughAdapter(strSQL, out DTLocal, true);
DTLocal.TableName = "Shedule";
Posted
Updated 5-Jun-13 0:32am
v3

1 solution

It doesn't.
Check my comments.
C#
//here you define command text
strSQL = "select * from tblSheduleEntry where EmpCode='" + EmpCode + "'";

//here you open your connection
ConManager.DBConnection("TERMSSUP");
DataTable DTLocal = new DataTable();

//and then you actually execute your query
ConManager.OpenDataTableThroughAdapter(strSQL, out DTLocal, true);
DTLocal.TableName = "Shedule";



Also you should know that:
In Visual studio right click in code editor gives you context menu with standard actions.
Two of particular interest are Go to definition and Find all references.
Right click on above methods and explore!

Good luck!
 
Share this answer
 
v2
Comments
Sumon562 5-Jun-13 6:53am    
Thank you Mr. Oshtri Deka.
Oshtri Deka 6-Jun-13 13:17pm    
If you like this answer, up-vote and solution acceptance would be nice.
Sumon562 5-Jun-13 7:35am    
Can you help me please How can I find Visual Studio code editor. I can not find out Go to definition and Find all references.
Oshtri Deka 5-Jun-13 15:41pm    
Right click on any object inside code (while in Visual Studio), for instance right click on OpenDataTableThroughAdapter method. That action will open context menu with above mentioned actions.

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