473,387 Members | 1,483 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Datagrid not Refreshing

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(dat asetkey), "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.Paramet ers.Item("MAFLD").Value = MAFL
mydot.getAdapter(datasetkey).SelectCommand.Paramet ers.Item("MASYS").Value = MASY

mydot.refreshData(datasetkey
dg_MappingInfo.Refresh(

Any suggestions?
Jul 21 '05 #1
3 2723
Cor
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(dat asetkey), "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
Jul 21 '05 #2
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.Paramet ers.Item("MAFLD").Value = MAFL
mydot.getAdapter(datasetkey).SelectCommand.Paramet ers.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.
Jul 21 '05 #3
Cor
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.

Jul 21 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: msnews | last post by:
Hi -- I'm very, very new to ASP.Net, and I've been trying for several days to figure out how to update a datagrid AND refresh it on the client side so that the page doesn't refresh. I've torn my...
0
by: msnews | last post by:
Hi -- I'm very, very new to ASP.Net, and I've been trying for several days to figure out how to update a datagrid AND refresh it on the client side so that the page doesn't refresh. I've torn my...
1
by: James | last post by:
I have a data grid refresh problem. I have a few columns and the first column is data in the form of numbers. And in the form of the data grid if I specify for example something like a code(in a...
1
by: Hans | last post by:
I have a Windows.Forms.Form containing a DataGrid where the DataSource is a DataView. Everything refreshes fine after adding, deleting or editing rows. When I close the dialog and reopen it with a...
7
by: A.M | last post by:
Hi, I want to refresh my DataGrid data on every postback. I have following code in Page_Load event, but after first page load, the DataGrid never gets refresh. Here is the code i have in...
1
by: aliansari | last post by:
HI ... i am facing a problem while refreshing my datagrid ... i am developing a "Real time/Live data Stocks Trading Screen" ... what i want is to refresh my datagrid without refreshing the whole...
1
by: msnews | last post by:
Hi -- I'm very, very new to ASP.Net, and I've been trying for several days to figure out how to update a datagrid AND refresh it on the client side so that the page doesn't refresh. I've torn my...
0
by: rraw | last post by:
hello! i have a poblem refreshing the datagrid the datagrid gets updated but what should i do in order to make the grid invisible once i am thru the dataviewing from the datagrid.. plz help me out
6
by: =?Utf-8?B?TWFyaw==?= | last post by:
Hi - I'm having trouble refreshing a datagrid control bound to a dataset that was created from the New Data Source wizard. What is the code required to refresh the datagrid with data from the...
17
lee123
by: lee123 | last post by:
I know this is a free site and the moderators or anybody don't have to answer if they don't want to.. but if there is someone who knows how to answer this question please help with this one. i...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.