|
-
Jul 8th, 2007, 03:14 PM
#1
Thread Starter
Fanatic Member
[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
-
Jul 8th, 2007, 03:21 PM
#2
Re: Db question:am I missing something?
use Because the Table resulting from the Select statement has no name
"I'm not normally a praying man, but if you're up there, save me... Superman!" - Homer Simpson
My Blog
-
Jul 8th, 2007, 03:31 PM
#3
Thread Starter
Fanatic Member
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
-
Jul 8th, 2007, 03:36 PM
#4
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
"I'm not normally a praying man, but if you're up there, save me... Superman!" - Homer Simpson
My Blog
-
Jul 9th, 2007, 12:40 AM
#5
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.
-
Jul 9th, 2007, 01:04 AM
#6
Thread Starter
Fanatic Member
Re: Db question:am I missing something?
 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
-
Jul 9th, 2007, 06:07 PM
#7
Thread Starter
Fanatic Member
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
-
Jul 9th, 2007, 09:03 PM
#8
Thread Starter
Fanatic Member
Re: Db question:am I missing something?
Never mind it was the query that was off
thanks for your help
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|