使用disconnetcted体系结构重新传输数据 [英] Retrive data using disconnetcted architecture

查看:130
本文介绍了使用disconnetcted体系结构重新传输数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想要检索存储在sql数据库中的一组名称

你能不能用c#中的代码发送给我一个依赖于where子句的列中的一个。

I want to retrive the set of names which are stored in sql database
Can you send me the code in c# to retrive one of the column which is depend on where clause.

推荐答案

尝试使用以下代码,其中使用了断开连接的体系结构。

Try the following code in which disconnected architecture is used.
Public DataSet GetData()
        {
            String connectionstring = "your connection string";
            using (SqlConnection connection = new SqlConnection(connectionstring))
            {
                if (connection.State == ConnectionState.Closed)
                    connection.Open();
                SqlCommand command = new SqlCommand("Select * from tablename where colName = value", connection);
                SqlDataAdapter adapter = new SqlDataAdapter(command);
                DataSet ds = new DataSet();
                adapter.Fill(ds);
                if(connection.State == ConnectionState.Open)
                    connection.Close();
                return ds;
            }
        }





如果解决方案对您有帮助,请接受解决方案



if the solutions is helful to you then pls accept the solution


这篇关于使用disconnetcted体系结构重新传输数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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