从SQL Server数据库获取数据集 [英] Obtaining a dataset from a SQL Server database

查看:179
本文介绍了从SQL Server数据库获取数据集的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是一个新手,C#和我需要从我做了一个虚拟的数据库中获取的数据集。我已经习惯了编码Objective-C和使用PHP / MySQL来处理数据的插入/拔出....

I am a newbie to C# and I need to obtain a dataset from a dummy database I have made. I'm used to coding in objective-c and using php/mysql to deal with the data insertion/extraction....

谁能告诉我如何从一个SQL Server数据库中获取数据的整个表?或者至少指向我一个可靠的事实上的源的方向?

Can anyone tell me how to obtain an entire table of data from a SQL Server database? Or at least point me in the direction of a reliable defacto source?

推荐答案

您必须使用供应商MSSQL - 的 SqlDataAdapter类

You have to use provider for MSSQL - SqlDataAdapter class.

string CnStr=@"put_here_connection_string";
SqlDataAdapter adp=new SqlDataAdapter("select * from tableName",CnStr);
DataSet ds=new DataSet();
adp.Fill(ds,"TableName");

这篇关于从SQL Server数据库获取数据集的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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