Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DataGrid...SQL Error...Please Help 1

Status
Not open for further replies.

Darci

IS-IT--Management
Jul 23, 2002
37
US
Hi,

I have a datagrid that is populated from a view in SQL server. When I set the datasource on load it works fine. However, when I update and then try to reload the grid I get an error saying column dos not belong to table. anyone have any ideas?

Darci
 
It would seem that when you are reloading your data you are using a different dataset to when you first load it, with one of the columns that the datagrid is expecting missing.

Transcend
[gorgeous]
 
That is the thing....it is the exact same code...


Connect = New SqlConnection("Server=SERVER;Integrated Security=SSPI;Database=ATMTracking;")

strSQLCall = "SELECT * FROM ViewCallDetail"

dsCallDetails = New DataSet

cmCallLog = New SqlDataAdapter(strSQLCall, Connect)

cmCallLog.Fill(dsCallDetails, "ViewCallDetails")

CallGrid.DataSource = dsCallDetails.Tables("ViewCallDetails")
 
And you call that same bit of code when you load and re-load? hrm .. will have to think about that then!

Have you tried stepping through all of the code in debug mode and checking the status of everything, ie the dscalldetails dataset gets repopulated properly ...

Transcend
[gorgeous]
 
Yes, I have stepped through the code....I really appreciate you trying to help, cause I am stumped! What I am doing exactly is updating a table that my view is pulling from. After I update the table, I am trying to reload the grid using the code above. (Same code I use to load it). I have tried everything. Anything you can come up is appreciated.

Darci
 
Here is the other weird thing...and maybe you can determine the problem from this. It will work the first time the code is called to reload the grid. It throws the error on the second time the code is called. And if I change the table name...ie...
cmCallLog.Fill(dsCallDetails, "ViewCallDetails")

to

cmCallLog.Fill(dsCallDetails, "ViewCallDetails1")

it will work....should I try to rename the table everytime the code is called?

Darci
 
It is the column does not belong to the table error.....
 
Ok this has me stumped for now

But i will be back later with research!

Just out of curiosity do you get the error message on this line
cmCallLog.Fill(dsCallDetails, "ViewCallDetails")

or the callgrid.datasource line ... ?

Best of luck

Transcend
[gorgeous]
 
I get the error on the callgrid.datasource line.....I appreciate you looking into it.

Thanks

Darci
 
Ok i have searched hi and low but I haven't found anything.

Just do me one favour. Put a stop at this line

cmCallLog.Fill(dsCallDetails, "ViewCallDetails") and step over it at it the second time you load the grid (after the update) but don't execute the line where you bind the grid.

Have a look and tell me what the value of
dsCallDetails.tables("ViewcallDetails").rows.count is

Sorry but I have run out of ideas! Maybe it's something to do with creating a table in a dataset that already exists ...

Transcend
[gorgeous]


 
I so appreciate your help....and so you know ....I did do what you requested to no avail...I had a valid row count ...and when updating tables that my view pulls from I had a valid number of updated rows...that is why I was so stumped...but I did solve the error...and here is how...I still can't believe this solved it ...but for future reference and for anyone else who may encounter this...I had to first call the schematype to load the table metadata.....
cmCallLog.FillSchema(ds,schemaType.Source, "ViewCallDetail")

cmCallLog.Fill(ds, "ViewCallDetail")
Me.CallGrid.DataSource = ds.Tables("ViewCallDetail")

Thank you Transcend for your diligence....it is so much appreciated....a star for you

Darci
 
Ahhh

I think i had my asp .net datagrid hat on :p

Never would have come up with that! (Well not quickly)

Well done

Transcend
[gorgeous]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top