Data not showing up in DataGrid

Please support our VB.NET advertiser: Intel Parallel Studio Home
Reply

Join Date: Sep 2006
Posts: 88
Reputation: bajanpoet is an unknown quantity at this point 
Solved Threads: 0
bajanpoet bajanpoet is offline Offline
Junior Poster in Training

Data not showing up in DataGrid

 
0
  #1
Aug 21st, 2008
Hi guys! Long time no see!

I'm trying to get a datagrid to work, but although when I run it there is no error, nothing appears on the datagrid. Yet, there seems nothing wrong with my code:
  1. SQL = "select * from upload " & _
  2. "where field003 like 'P'+'%'+'" & PONo & "' " & _
  3. "and field009 like 'Being received' order by field003"
  4.  
  5. 'Set up connections
  6. Dim SQLCommand = New SqlCommand(SQL, conn)
  7. conn.Open()
  8. Dim da As SqlDataAdapter = New SqlDataAdapter(SQLCommand)
  9. Dim ds As New DataSet
  10.  
  11. da.Fill(ds, SQL)
  12.  
  13. 'Attach dataset to datagrid
  14. dgBlowOut.DataSource = da

Thank you for your help
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 1,160
Reputation: dickersonka will become famous soon enough dickersonka will become famous soon enough 
Solved Threads: 137
dickersonka dickersonka is offline Offline
Veteran Poster

Re: Data not showing up in DataGrid

 
0
  #2
Aug 21st, 2008
If you are using asp.net you need to use bind
Reply With Quote Quick reply to this message  
Join Date: Sep 2006
Posts: 88
Reputation: bajanpoet is an unknown quantity at this point 
Solved Threads: 0
bajanpoet bajanpoet is offline Offline
Junior Poster in Training

Re: Data not showing up in DataGrid

 
0
  #3
Aug 21st, 2008
Not using asp.net. I'm creating a small desktop application.
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 1,160
Reputation: dickersonka will become famous soon enough dickersonka will become famous soon enough 
Solved Threads: 137
dickersonka dickersonka is offline Offline
Veteran Poster

Re: Data not showing up in DataGrid

 
0
  #4
Aug 21st, 2008
try setting the datamember
The dataset can have multiple tables, when you set the datasource you need to specify which table to use
Last edited by dickersonka; Aug 21st, 2008 at 11:37 am.
Reply With Quote Quick reply to this message  
Join Date: Sep 2006
Posts: 88
Reputation: bajanpoet is an unknown quantity at this point 
Solved Threads: 0
bajanpoet bajanpoet is offline Offline
Junior Poster in Training

Re: Data not showing up in DataGrid

 
0
  #5
Aug 21st, 2008
Setting the datamember to the name of the table?

[code=VB.NET] dgBlowOut.DataMember = "upload"
[\code]

When I added that it gave me an error: 'Child list for field upload cannot be created'
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 1,160
Reputation: dickersonka will become famous soon enough dickersonka will become famous soon enough 
Solved Threads: 137
dickersonka dickersonka is offline Offline
Veteran Poster

Re: Data not showing up in DataGrid

 
0
  #6
Aug 21st, 2008
The dataset table, not the sql table
  1. Dim ds As New DataSet("uploads")
  2.  
  3. ....
  4.  
  5. dgBlowOut.DataMember = "uploads"
Reply With Quote Quick reply to this message  
Join Date: Sep 2006
Posts: 88
Reputation: bajanpoet is an unknown quantity at this point 
Solved Threads: 0
bajanpoet bajanpoet is offline Offline
Junior Poster in Training

Re: Data not showing up in DataGrid

 
0
  #7
Aug 21st, 2008
I have also realized that in trying to run this application, after a while this error appears:
"An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this error may be caused by the fact that under the default settings SQL Server does not allow remote connections."

I had never seen this error before this time because when I clicked the View button and it did not change the datagrid, I would have closed it immediately..... it came up after about 4 seconds.

Does this help anyone to assist me?
Last edited by bajanpoet; Aug 21st, 2008 at 1:02 pm.
Reply With Quote Quick reply to this message  
Join Date: Sep 2006
Posts: 88
Reputation: bajanpoet is an unknown quantity at this point 
Solved Threads: 0
bajanpoet bajanpoet is offline Offline
Junior Poster in Training

Re: Data not showing up in DataGrid

 
0
  #8
Aug 21st, 2008
the Dataset is using a raw SQL statement that is being stored in a string variable SQL -
  1. SQL = "select field003 as 'PO #',field009 as 'Status' from upload " & _
  2. "where field003 like 'P'+'%'+'" & PONo & "' " & _
  3. "and field009 like 'Being received' order by field003"
  4. .....

I don't understand what the dataset table is...
Reply With Quote Quick reply to this message  
Join Date: Sep 2006
Posts: 88
Reputation: bajanpoet is an unknown quantity at this point 
Solved Threads: 0
bajanpoet bajanpoet is offline Offline
Junior Poster in Training

Re: Data not showing up in DataGrid

 
0
  #9
Aug 21st, 2008
One more piece of info: Here's the connection string (As the issue seems to be a connection one.
[code=VB.NET]
Public Const ConnectionString = "Data Source=SBIDB2SVR;Initial Catalog=rbeacon;User Id=sbiapps;Password=sbiapps123;"
[\code]
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 1,160
Reputation: dickersonka will become famous soon enough dickersonka will become famous soon enough 
Solved Threads: 137
dickersonka dickersonka is offline Offline
Veteran Poster

Re: Data not showing up in DataGrid

 
0
  #10
Aug 21st, 2008
As long as you are sure the the datasource is correct and you can 'ping' the server then you need to configure the sql server to allow tcp ip connections.

Here's some links to show you how
http://www.datamasker.com/SSE2005_SCM1.htm

http://www.datamasker.com/SSE2005_SAC.htm
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC