473,387 Members | 1,578 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.

Stupid Question

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

Nov 23 '05 #1
2 914
How 'bout this:

workRow = workTable.NewRow()
workRow(0) = I
workRow(1) = "CustName" & I.ToString()
workTable.Rows.Add(workRow)

you can get workTable when you call:
worktable = oDsLoans.Tables("Loans")
HTH
Steve

"YYZ" <ma********@gmail.com> wrote in message
news:11**********************@f14g2000cwb.googlegr oups.com...
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

Nov 23 '05 #2
YYZ
> workRow = workTable.NewRow()

And we have a winner. That's all I needed. I can't believe I missed
NewRow as a method on the Table object!

Thanks so much -- that is much cleaner in my opinion.

Matt

Nov 23 '05 #3

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

Similar topics

119
by: rhat | last post by:
I heard that beta 2 now makes ASP.NET xhtml compliant. Can anyone shed some light on what this will change and it will break stuff as converting HTML to XHTML pages DO break things. see,...
5
by: raz | last post by:
Greetings all. I apologize for what is almost certainly a stupid question, but I can't figure this out, and have no more time for head bashing... The short version: what is the appropriate...
4
by: IS | last post by:
At the recommendation of several people in this newsgroup I have downloaded two or three Compilers. One is the Beta version of Microsoft's Visual C++ 2005. I have entered a complete beginner code...
2
by: Ron Weldy | last post by:
I read that you don't need .cs files to deploy but I suppose if you are trying to reconstruct someone's work, you will need these files. Is that correct?
3
by: rroman | last post by:
I have a very simple form, takes information from the user, updates a SQL database, now I just want to redirect to a "Thank You For Your Time" web page within the same bowser. ASP. NET VB
6
by: Adam Smith | last post by:
I have posted this and similar questions repeatedly and can't even raise a single response. I am being led to believe that this then 'Must be a stupid question' although people say that there is no...
5
by: Alberto Salvati | last post by:
Hi, List. My company has a VERY BIG product base on db2 udb v7.x. We want to di an upgrade to v9, but.... current db has a lot of procedure (cobol..!). Therefore, we've planned to rewrite this...
2
by: Lynx101 | last post by:
Hi, Is this a stupid question? Senario: Two tables linked together with an ID number. Question: When using a combo box, which refences another table by indexed autonumber, is there a way to...
9
by: AWW | last post by:
Running XP - Visual Studio 2005 - VB Want to have duplicate projects - one safe and stable - other for experimenting Can't fine easy way to make duplicate project. Stupid question? or stupid ME?...
9
by: Alec | last post by:
Sorry guys, stupid question.... Am no programming expert and have only just started using php for creating dynamic news pages. Then I see a dynamic website without the php extension. ...
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: 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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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.