Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Development Tools
 ASP.NET
 Bind records from the table, datalist control C#

Author  Topic 

macupryk
Starting Member

9 Posts

Posted - 2004-10-07 : 19:29:52
I tried egghead.
Not much help.
I am trying to bind the records from the table to a datalist control in C#
private DataSet BindTBCOMMANDTYPE()
{
OdbcConnection myConnection = new OdbcConnection("DSN=POS;UID=system;PWD=system");

// Populate the ddlDataSet1
myConnection.Open();
const string strSQLDDL = @"SELECT DT_REF, DT_DESCRIPTION FROM TBCOMMANDTYPE ORDER BY DT_REF";
OdbcDataAdapter myDataAdapter = new OdbcDataAdapter(strSQLDDL, myConnection);
ddlDataSet1.Clear();
myDataAdapter.Fill(ddlDataSet1, "ddlDATATYPE");
DataSet1.DataSource = ddlDataSet1;
DataSet1.DataBind();
myDataAdapter.Dispose();
myDataAdapter = null;
myConnection.Close();
return ddlDataSet1;
}

Just need the correct syntax.


http://www.eggheadcafe.com/forums/ForumPost.asp?ID=14586&INTID=6


Let's share our knowledge together!!!
mcupryk@sun.net.bb
Matt Cupryk
514-685-0449

chadmat
The Chadinator

1974 Posts

Posted - 2004-10-08 : 14:35:52
What error are you getting?

What is DataSet1? I assume it is your datalist, but if so, bad naming convention.

Also, You don't have to Open/Close the conection. The DataAdapter will open it when you call fill, and close it when it is done.

-Chad

http://www.clrsoft.com

Software built for the Common Language Runtime.
Go to Top of Page
   

- Advertisement -