Link to home
Start Free TrialLog in
Avatar of Steve7423
Steve7423Flag for Canada

asked on

missing a directive or namespace

I'm using the dataAdapter as you see in the code below.  I'm using VS 2005.  what does the error; The type or namespace name 'SqlDataAdapter' could not be found (are you missing a using directive or an assembly reference?)      mean?

 string strConn = "Database=adventureworks;User ID=se;Password=steve";
            string sqlstr = "select * from production.productcategory";
            using(SqlDataAdapter AWdataadapter = new SqlDataAdapter(strConn,sqlstr));   ****
            DataTable table = new DataTable();
            table.Locale = System.Globalization.CultureInfo.InvariantCulture;
            AWdataadapter.Fill(table);
            dbBindSource.DataSource(table);
            dataGridView1.AutoResizeColumn(DataGridViewAutoSizeColumnMode.AllCellsExceptHeader);
            dataGridView1.DataSource(dbBindSource);
ASKER CERTIFIED SOLUTION
Avatar of aaronfeng
aaronfeng

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Steve7423

ASKER

Awsome !!! thanks Aaron.  
out of curiosity, how do I add the reference at the top so I don't have to make that reference each time I instantiate a data object like dataadapter?

Avatar of aaronfeng
aaronfeng

Not sure what you mean, you can just type using System.Data.SqlClient on top of your file, so you can use it within the class.  If you have multiple classes that use DataAdaptor you'll need to add it per file.

Cheers,

Aaron