Datatable.compute

star_sky

Member
Joined
Jun 19, 2007
Messages
5
Programming Experience
Beginner
i need to compute a column name

i have the following codes.
objSum = (DataGridView1.DataSource.Compute("SUM(" & table & "))", "")) where " & table &" is my column name

however i got this error

object variable or with block variable not set

what does this mean??

pls helP!! thnx u
 
oh i realise must use
dim dt as new datatable
dt = ds.tables("abc")

to remove the error.

however at the same codes mention above, i receive column nt found? why is this the case when i had indicated


dt = ds.tables("abc")


help is greatly appreciated thnx!
 
hi,

ya i guess so but

dt= ds.tables(abc)

doesnt this help to indicate which table i am looking for? how should i go about it then?

i have different tables with different names

thnx for helping!
 
ya i knw the diff between a table n column. maybe i had phrase the question in a wrong manner.


the sequence of the codings is lidat

dim dt as new datatable
dt= ds.tables(abc)
dim objsum as object
objSum = dt.compute ("SUM(" & table & "), "")

where " & table &" is my column name

this is what i had understand from msdn website on how to compute.

but somehow it doesnt work and i dont knw why.

sorry for my ignorance. am super new to these stuffs.
 
ya i knw the diff between a table n column. maybe i had phrase the question in a wrong manner.
So why, when the VB error message is "Column not found" do you keep focusing on telling it what the table is?

where " & table &" is my column name
Yeah, cause that really leads me to believe youre firm on the difference between a table and a column!


dim dt as new datatable
You dont need to make a new one, youre going to assign it to an already existing one in a minute

dt= ds.tables(abc)
This is a bit moot. VB doesnt care whether you say dt. or ds("abc"). in the line below

dim objsum as object
objSum = dt.compute ("SUM(" & table & "), "")
So.. what's the table variable again? The table?
 
dim objsum as object
objSum = dt.compute ("SUM(" & table & "), "")
So.. what's the table variable again? The table?

---------------------------------------------------------------
what do you mean by your last sentence table variable? The table?
" & table & " is my column name.
n am manipulating the sum of the column.
 
table is my column name
I'm sure you know what youre talking about, but to everyone else out there on the Internet, it reads like complete gibberish. Smarten your code up and start calling things by their proper names.. If something is a chair, call it a chair, not a rug.
 

Latest posts

Back
Top