C夏普sql连接 [英] C Sharp sql connection

查看:69
本文介绍了C夏普sql连接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在服务器(SQL Server-2005)中我有两个数据库。它们是 TERMSUS TERMSSUP

在关闭 TERMSUS 的连接时,在以下代码中运行选择从另一个数据库查询,即 TERMSSUP 。在选择查询之后,我打开了 TERMSSUP 的连接。任何人都可以帮我联系吗?如何在打开连接之前执行第二个选择查询?



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?

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";

推荐答案

它没有。

检查我的评论。

It doesn't.
Check my comments.
//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";







您还应该知道:

在Visual Studio中右键单击代码编辑器,为您提供标准操作的上下文菜单。

两个特别感兴趣的是 转到定义 查找所有引用

右键点击上面的方法并探索!



祝你好运!




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!


这篇关于C夏普sql连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆