Steve7423
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;U ser ID=se;Password=steve";
string sqlstr = "select * from production.productcategory ";
using(SqlDataAdapter AWdataadapter = new SqlDataAdapter(strConn,sql str)); ****
DataTable table = new DataTable();
table.Locale = System.Globalization.Cultu reInfo.Inv ariantCult ure;
AWdataadapter.Fill(table);
dbBindSource.DataSource(ta ble);
dataGridView1.AutoResizeCo lumn(DataG ridViewAut oSizeColum nMode.AllC ellsExcept Header);
dataGridView1.DataSource(d bBindSourc e);
string strConn = "Database=adventureworks;U
string sqlstr = "select * from production.productcategory
using(SqlDataAdapter AWdataadapter = new SqlDataAdapter(strConn,sql
DataTable table = new DataTable();
table.Locale = System.Globalization.Cultu
AWdataadapter.Fill(table);
dbBindSource.DataSource(ta
dataGridView1.AutoResizeCo
dataGridView1.DataSource(d
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
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?
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
Cheers,
Aaron
ASKER