PC Review


Reply
Thread Tools Rate Thread

Datagrid not Refreshing

 
 
=?Utf-8?B?U3RldmUgRG9ubm9y?=
Guest
Posts: n/a
 
      11th Feb 2004
Here's my question..

I can't seem to get my datagrid to refresh. I have a Dataset that automagically populates the datagrid. It's a two parameter SQL statement that I am using. Here's an example of that code..

datasetkey = mydot.OpenDataAdapter("Select MASYS, MAFLD, MADATA, MAEQV from QS36F.MAPDATA WHERE MASYS = ? AND MAFLD = ?"

Dim adapter As System.Data.Odbc.OdbcDataAdapter = mydot.getAdapter(datasetkey
mydot.CreateODBCParameter(adapter.SelectCommand, Odbc.OdbcType.Text, "MASYS", MASYS
mydot.CreateODBCParameter(adapter.SelectCommand, Odbc.OdbcType.Text, "MAFLD", MAFLD

mydot.OpenDataset(datasetkey

dg_MappingInfo.SetDataBinding(mydot.getDataSet(datasetkey), "Table"

ts.MappingName = dg_MappingInfo.DataMembe

This is what the functions in the above code are..

Public Function CreateODBCParameter(ByVal dbcmd As System.Data.Odbc.OdbcCommand, ByVal type As Odbc.OdbcType, ByVal name As String, ByVal value As Object
'returns a new paramete
Dim dbParm As Odbc.OdbcParamete
dbParm = dbcmd.CreateParameter(
dbParm.OdbcType = typ
dbParm.ParameterName = nam
dbParm.Value = valu
dbcmd.Parameters.Add(dbParm
End Functio

Public Function OpenDataSet(ByVal key As Integer) As Intege
Dim RS As New System.Data.DataSe
Tr
Me.getAdapter(key).Fill(RS
recordsets.Add(key, RS
Catch ex As Exception When Connection.State =
'forgot to open a connection
MsgBox("No connection to the database", MsgBoxStyle.Critical, "Error"
Return ke
Catch ex As Exceptio
'general error trappin
MessageBox.Show(ex.Message
End Tr
End Functio

Public Function OpenDataSet(ByVal key As Integer) As Intege
Dim RS As New System.Data.DataSe
Tr
Me.getAdapter(key).Fill(RS
recordsets.Add(key, RS
Catch ex As Exception When Connection.State =
'forgot to open a connection
MsgBox("No connection to the database", MsgBoxStyle.Critical, "Error"
Return ke
Catch ex As Exceptio
'general error trappin
MessageBox.Show(ex.Message
End Tr
End Functio

Public Function getAdapter(ByVal key As Integer) As System.Data.Odbc.OdbcDataAdapte
'returns the requested adapte
If adaptersets.Contains(key) The
Return adaptersets.Item(key
Els
Return Nothin
End I
End Functio

Following that when I change the two parameter variables....is it suppose to automagically update the dataset
If so how does it refresh the info on the datagrid

Here's my refresh code when I change the variables...

mydot.getAdapter(datasetkey).SelectCommand.Parameters.Item("MAFLD").Value = MAFL
mydot.getAdapter(datasetkey).SelectCommand.Parameters.Item("MASYS").Value = MASY

mydot.refreshData(datasetkey
dg_MappingInfo.Refresh(

Any suggestions?
 
Reply With Quote
 
 
 
 
Cor
Guest
Posts: n/a
 
      11th Feb 2004
Hi Steve,

Did you know that when you post to a newsgroup some names in code are
standard.
This makes it for the one who helps you more readable.
So is a ds or a dataset1 mostly a dataset, a RS always a recordset and a
datasetkey something as the key object from the dataset datatable

That is not with you so helping you is very difficult.

The first thing I would change in your code is
> mydot.OpenDataset(datasetkey)
>
> dg_MappingInfo.SetDataBinding(mydot.getDataSet(datasetkey),

"Table")
> ts.MappingName = dg_MappingInfo.DataMember

The two rows above in
dg_MappingInfo.datasource = datsetkey.tables("Table")

And than try again.

I hope this helps,

Cor


 
Reply With Quote
 
=?Utf-8?B?U3RldmUgRG9ubm9y?=
Guest
Posts: n/a
 
      11th Feb 2004
I appologize for the confusing code.
I did however figure out what the problem was

When I did the refresh function (which I forgot to include) I was doing a reset instead of a clear
Like so..

'My code that refreshes the changed params...then calls the refresh function
mydot.getAdapter(datasetkey).SelectCommand.Parameters.Item("MAFLD").Value = MAFL
mydot.getAdapter(datasetkey).SelectCommand.Parameters.Item("MASYS").Value = MASY

mydot.refreshData(datasetkey
dg_MappingInfo.Refresh(


Public Function refreshData(ByVal key As Integer
'This used to be getdataset(key).reset(
getDataSet(key).Clear(
Me.getAdapter(key).Fill(getDataSet(key)
End Functio

Not sure if any of the code makes sense cause of how 'non standard' it is. But bottom line is it works now
Thanks anyhow.
 
Reply With Quote
 
Cor
Guest
Posts: n/a
 
      11th Feb 2004
Hi Steve,

Very good, however as an answer on this sentence.

It makes no sence how standard your code is to let it work, only if you show
it to others and ask advices, than can confusing names give problems.

Cor

> Not sure if any of the code makes sense cause of how 'non standard' it is.



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Refreshing a Datagrid =?Utf-8?B?T3dlbiBSaWNoYXJkc29u?= Microsoft ASP .NET 1 25th Sep 2006 07:01 PM
Refreshing a datagrid. AinO Microsoft C# .NET 0 25th May 2005 11:08 PM
refreshing DataGrid after insert? =?Utf-8?B?TXJOb2JvZHk=?= Microsoft C# .NET 1 7th Jan 2005 09:37 PM
Datagrid refreshing ??? =?Utf-8?B?c2VyZ2UgY2FsZGVyYXJh?= Microsoft Dot NET 0 17th Dec 2004 06:37 AM
Re: Problems with DataGrid refreshing Erik Microsoft Dot NET Framework Forms 7 6th Oct 2004 08:41 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:04 AM.