Welcome to dbFreaks.com!
FAQFAQ      ProfileProfile    Private MessagesPrivate Messages   Log inLog in

Refresh Datagrid

 
   Database Help (Home) -> Visual Basic RSS
Next:  Help needed with script  
Author Message
vbdotnetmania

External


Since: Feb 08, 2005
Posts: 2



(Msg. 1) Posted: Tue Feb 08, 2005 4:15 am
Post subject: Refresh Datagrid
Archived from groups: microsoft>public>vb>database (more info?)

I'm struglling to find info on refreshing a datagrid, I'm using Sql server,
the datagrid is based on several tables, when changes have been made to the
data (NOT DONE WITHIN THE DATAGRID ITSELF - only used for viewing and
selecting purposes) I want to be able to refresh the datagrid with the added
records, I've tried various methods with no success, begiining to wonder if
the onmly way of doing it is to run teh query again and then set the
datasource = to same again or is there a more convenient way?

To make it more clearer this is the main part of the code I used to get the
original data, any suggestion greatly appreciated

gConnection = New SqlClient.SqlConnection(gConnString)
sSQL = "Select j.id as ID," & _
"j.description as Description," & _
"e.name as Employee,tp.description as Priority, " & _
"tj.description as Status," & _
"CONVERT(CHAR(11),datelogged,106) as DateLogged ," & _
"j.notes as Notes from Jobs j " & _
"inner join Employees e on e.id = j.employeeid " & _
"inner join Type_JobStatus tj on tj.id = j.status " & _
"inner join Type_Priority tp on tp.id = j.priorityid" & _
" order by j.id"
Dim da As SqlClient.SqlDataAdapter = New _
SqlClient.SqlDataAdapter(sSQL, _
gConnection)

da.Fill(ds, "Jobs")

dgJobs.DataSource = ds.Tables("Jobs")
dgJobs.SetDataBinding(ds, "Jobs")

 >> Stay informed about: Refresh Datagrid 
Back to top
Login to vote
vbdotnetmania

External


Since: Feb 08, 2005
Posts: 2



(Msg. 2) Posted: Tue Feb 08, 2005 4:27 am
Post subject: RE: Refresh Datagrid [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Have got it working the way I want now with the following addition
I had to change the scope of the datasource and datadapter to get this to
work, hope this may be helpful to somebody.

Private Sub Refresh Data
ds.Clear()
da.Fill(ds, "Jobs")
dgJobs.DataSource = ds.Tables("Jobs")

End Sub

If anybody else knows of a neater way of doing this then that would be great
however.


"vbdotnetmania" wrote:

 > I'm struglling to find info on refreshing a datagrid, I'm using Sql server,
 > the datagrid is based on several tables, when changes have been made to the
 > data (NOT DONE WITHIN THE DATAGRID ITSELF - only used for viewing and
 > selecting purposes) I want to be able to refresh the datagrid with the added
 > records, I've tried various methods with no success, begiining to wonder if
 > the onmly way of doing it is to run teh query again and then set the
 > datasource = to same again or is there a more convenient way?
 >
 > To make it more clearer this is the main part of the code I used to get the
 > original data, any suggestion greatly appreciated
 >
 > gConnection = New SqlClient.SqlConnection(gConnString)
 > sSQL = "Select j.id as ID," & _
 > "j.description as Description," & _
 > "e.name as Employee,tp.description as Priority, " & _
 > "tj.description as Status," & _
 > "CONVERT(CHAR(11),datelogged,106) as DateLogged ," & _
 > "j.notes as Notes from Jobs j " & _
 > "inner join Employees e on e.id = j.employeeid " & _
 > "inner join Type_JobStatus tj on tj.id = j.status " & _
 > "inner join Type_Priority tp on tp.id = j.priorityid" & _
 > " order by j.id"
 > Dim da As SqlClient.SqlDataAdapter = New _
 > SqlClient.SqlDataAdapter(sSQL, _
 > gConnection)
 >
 > da.Fill(ds, "Jobs")
 >
 > dgJobs.DataSource = ds.Tables("Jobs")
 > dgJobs.SetDataBinding(ds, "Jobs")<!-- ~MESSAGE_AFTER~ -->

 >> Stay informed about: Refresh Datagrid 
Back to top
Login to vote
nrford

External


Since: Feb 11, 2005
Posts: 1



(Msg. 3) Posted: Fri Feb 11, 2005 10:38 am
Post subject: Re: Refresh Datagrid [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Since you solved it, I didn't try to read everything
in your first message, but I have a program which
uses a datagrid with separate input boxes (no direct
grid data entry) and after saving an entry, I just
refresh the data control to which the grid is tied
(not the grid itself).


"vbdotnetmania" <vbdotnetmania DeleteThis @discussions.microsoft.com> wrote in message
news:6ADD8B81-4B2D-4DBE-BD75-7F96921719D3@microsoft.com...
 > Have got it working the way I want now with the following addition
 > I had to change the scope of the datasource and datadapter to get this to
 > work, hope this may be helpful to somebody.
 >
 > Private Sub Refresh Data
 > ds.Clear()
 > da.Fill(ds, "Jobs")
 > dgJobs.DataSource = ds.Tables("Jobs")
 >
 > End Sub
 >
 > If anybody else knows of a neater way of doing this then that would be
 > great
 > however.
 >
 >
 > "vbdotnetmania" wrote:
 >
  >> I'm struglling to find info on refreshing a datagrid, I'm using Sql
  >> server,
  >> the datagrid is based on several tables, when changes have been made to
  >> the
  >> data (NOT DONE WITHIN THE DATAGRID ITSELF - only used for viewing and
  >> selecting purposes) I want to be able to refresh the datagrid with the
  >> added
  >> records, I've tried various methods with no success, begiining to wonder
  >> if
  >> the onmly way of doing it is to run teh query again and then set the
  >> datasource = to same again or is there a more convenient way?
  >>
  >> To make it more clearer this is the main part of the code I used to get
  >> the
  >> original data, any suggestion greatly appreciated
  >>
  >> gConnection = New SqlClient.SqlConnection(gConnString)
  >> sSQL = "Select j.id as ID," & _
  >> "j.description as Description," & _
  >> "e.name as Employee,tp.description as Priority, " & _
  >> "tj.description as Status," & _
  >> "CONVERT(CHAR(11),datelogged,106) as DateLogged ," & _
  >> "j.notes as Notes from Jobs j " & _
  >> "inner join Employees e on e.id = j.employeeid " & _
  >> "inner join Type_JobStatus tj on tj.id = j.status " & _
  >> "inner join Type_Priority tp on tp.id = j.priorityid" & _
  >> " order by j.id"
  >> Dim da As SqlClient.SqlDataAdapter = New _
  >> SqlClient.SqlDataAdapter(sSQL, _
  >> gConnection)
  >>
  >> da.Fill(ds, "Jobs")
  >>
  >> dgJobs.DataSource = ds.Tables("Jobs")
  >> dgJobs.SetDataBinding(ds, "Jobs")<!-- ~MESSAGE_AFTER~ -->
 >> Stay informed about: Refresh Datagrid 
Back to top
Login to vote
Display posts from previous:   
   Database Help (Home) -> Visual Basic All times are: Pacific Time (US & Canada) (change)
Page 1 of 1

 
You can post new topics in this forum
You can reply to topics in this forum
You can edit your posts in this forum
You can delete your posts in this forum
You can vote in polls in this forum



[ Contact us | Terms of Service/Privacy Policy ]