[RESOLVED] Db question:am I missing something?
Hi all
I seem to have everything working but I just cant get my DGV to load
I think I might be missing something but I'm not sure
c# Code:
DataSet ds = new DataSet();
SqlConnection conn = new SqlConnection("Server=gci-mocsqdb01;Database=mdb_rpt;Uid=caiahd_rpt;Pwd=dashboard;");//Driver={SQL Server};
String SelectCmdString = "select * from gci_requests where (gci_requests.group_name='USAT-Publishing Solutions')";
SqlDataAdapter da = new SqlDataAdapter(SelectCmdString, conn);
da.Fill(ds, "gci_requests");
MessageBox.Show("done loading");
dataGridView1.DataSource = ds;
Thanks for takeing a look
Re: Db question:am I missing something?
use Because the Table resulting from the Select statement has no name
Re: Db question:am I missing something?
Done but still nothing showing up in the DGV
is there a way in debug to see if the dataset actually has data in it
mabey my query sucks or something
Re: Db question:am I missing something?
First you should check that your query is really returning data. Use the SQL profiler to check that the query is being executed and then check the results.
You can use a break point after the "Fill" call and check if the dataset has tables and data in it
Re: Db question:am I missing something?
You should ALWAYS specify the name of Datatable you're populating. This:is legal but this:
C# Code:
da.Fill(ds, "gci_requests");
is much better.
If you're going to assign the DataSet itself to the grid's DataSource then you need to set its DataMember too; specifically to the name of the DataTable. Because you did the right thing and specified a name when you populated it then it's simply:
C# Code:
dataGridView1.DataMember = "gci_requests";
dataGridView1.DataSource = ds;
Alternatively you could assign the DataTable itself to the DataSource.
Re: Db question:am I missing something?
Quote:
Originally Posted by jmcilhinney
Alternatively you could assign the DataTable itself to the DataSource.
thanks for the help
I will try it out when i get to work tomorrow
if you have time could you expaned the dataTable part more im not sure exactly what you mean
thanks
Re: Db question:am I missing something?
Well i did the above and still no dice
The dataset is null so i dont think that its picking up any data from the query
the weird thing is that i just did a select * from gci_requests
and the network addapter is showing activity and the cpu is up around 50-60% so its doing something
Re: Db question:am I missing something?
Never mind it was the query that was off
thanks for your help