using System;
using System.Data;
using System.Data.SqlClient;
namespace PublicTest
{
///
/// Summary description for Class1.
///
class myClass
{
///
/// The main entry point for the application.
///
[STAThread]
static void Main(string[] args)
{
//
// TODO: Add code to start application here
//
string strCon = "Server=LOGICON-SERVER1,1433;Database=pubs;integrated security=SSPI;persist security info=False;Connection Timeout=10000;";
string strSQL = "Select au_fname, au_lname, phone from authors where city = 'Oakland'";
SqlConnection myCon = new SqlConnection(strCon);
SqlCommand myCom = new SqlCommand(strSQL, myCon);
SqlDataAdapter da = new SqlDataAdapter(myCom);
DataSet ds = new DataSet();
da.Fill(ds, "authors");
foreach (DataColumn dc in ds.Tables(0).Columns)
{
Console.Write("{0,15}", dc.ColumnName);
}
}
}
}
==============
Thanks & Regards,
Ravi
Andrzej WegierskiPosted Sep 19, 2005, 6:40 AM
ds.Tables(0)
should be:
ds.Tables[0]
Check presence of this table. May be strange column names can generate error too.