Y
YYZ
I am using Data for the first time with VB.Net, and it's in an odd way,
so that makes it more strange.
I have created a dataset based on a simple SELECT * FROM Table WHERE
1=0 -- I do that because I don't want any rows returned, only the
structure of what a row would look like. Make sense?
The first thing I want to do is to add a row to the dataset so that I
can run a query against it. I know that sounds strange, but I really
do have a reason for it.
So, Create connection, fine, connect, fine, create dataadapter, fine,
create dataset use the fill of the adapter to fill it (with no rows)
fine.
Adding a row. I can do it by doing this:
dim rowVals(0) as Object
dim row as DAtaRow
row = oDsLoans.Tables("Loans").Rows.Add(rowVals)
After that, row points to something, and it all works great. I know
I'm going to ahve to do this many times in the future, and I really
don't want to have to type out declaring an object array with 1 element
and then use that in the Add statement for the row just to get
something added. However, I can't work out the syntax for something
like this:
row = oDsLoans.Tables("Loans").Rows.Add( x(0) as object) -- see what I
mean - that doesn't work, but I don't need the damn array at all, but
the add function expects an object array to intialize the row variable.
If I could just use the row, I would, but at this point row doesn't
actually point to anything, and I can't figure out how to make a new
row...
Does any of this make sense? Am I doing this correctly at all? Am I
re-inventing some kind of wheel here?
All the examples that I've found for data access in .Net are geared
towards binding. Well, I want to do that, too, in other places, but
not here!
Any help is appreciated.
Matt
so that makes it more strange.
I have created a dataset based on a simple SELECT * FROM Table WHERE
1=0 -- I do that because I don't want any rows returned, only the
structure of what a row would look like. Make sense?
The first thing I want to do is to add a row to the dataset so that I
can run a query against it. I know that sounds strange, but I really
do have a reason for it.
So, Create connection, fine, connect, fine, create dataadapter, fine,
create dataset use the fill of the adapter to fill it (with no rows)
fine.
Adding a row. I can do it by doing this:
dim rowVals(0) as Object
dim row as DAtaRow
row = oDsLoans.Tables("Loans").Rows.Add(rowVals)
After that, row points to something, and it all works great. I know
I'm going to ahve to do this many times in the future, and I really
don't want to have to type out declaring an object array with 1 element
and then use that in the Add statement for the row just to get
something added. However, I can't work out the syntax for something
like this:
row = oDsLoans.Tables("Loans").Rows.Add( x(0) as object) -- see what I
mean - that doesn't work, but I don't need the damn array at all, but
the add function expects an object array to intialize the row variable.
If I could just use the row, I would, but at this point row doesn't
actually point to anything, and I can't figure out how to make a new
row...
Does any of this make sense? Am I doing this correctly at all? Am I
re-inventing some kind of wheel here?
All the examples that I've found for data access in .Net are geared
towards binding. Well, I want to do that, too, in other places, but
not here!
Any help is appreciated.
Matt