Hi,
The following code sample is from the Book "Professional ADO.NET with
VB.NET (Wrox)". I am getting the following error for the foreach loop. The error is "'System.Data.DataSet.Tables' denotes a 'property' where a 'method' was expected"
The Code is:
using System;
using System.Data;
using System.Data.SqlClient;
namespace PublicTest
{
class myClass
{
[STAThread]
static void Main(string[] args)
{
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");
Console.WriteLine("gjjhhj", ds.Tables(0).ToString());
foreach (DataColumn dc in ds.Tables
{
Console.Write("{0,15}", dc.ColumnName);
}
Console.ReadLine();
}
}
}
Please help me.
Thanks and Regards,
Ravi