How SqlDataSource put in C#?

techques used Ask the Experts™
There is a datalist in aspx page:

<asp:DataList ID="DataList1" runat="server" DataSourceID="SqlDataSource1" RepeatColumns="3" RepeatDirection="Horizontal" OnItemDataBound="DataList1_ItemCommand">

Currently, I use

<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>" SelectCommand="select id,col,name,age,width,height from operation">

to bind the data source in aspx page.

How can I put it to VC#?

Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Sr. System Analyst
Sqlconnection con= new sqlconnection( );
con.ConnectionString = "Persist Security Info=False;Integrated Security=SSPI;database=northwind;server=mySQLServer;Connect Timeout=30"
// or ConnectionStrings:ConnectionString , not sure about this;

sql command cmd =new command("select id,col,name,age,width,height from operation",con);
sqldataadpater da= new dataadpter(cmd);
dataset ds();
da.fill(ds," tablename");



Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial