473,513 Members | 2,661 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Extracting a row out a dataset and working with it

1 public void AddItem(string itemCode)
2 {
3 DataRow[] itemRow = DBAdmin.Products.Select("Code =
'"+itemCode+"'");
4 addItemRow["Code"] = itemRow[0]["Code"].ToString();
5 addItemRow["Amount"] = itemRow[0]
["SellPriceIn"].ToString();
6 addItemRow["Vat"] = itemRow[0]["Vat"].ToString();
7 addItemRow["Qty"] = 1;
8 addItemRow["DocNo"] = 2;
DBAdmin.DLitem.Rows.Add(addItemRow);
}
This my code and this is the error i get on line 4

"Index was outside the bounds of the array"

Any suggestions ? on what i am doing wrong
Jun 27 '08 #1
3 1021
Cdude wrote:
1 public void AddItem(string itemCode)
2 {
3 DataRow[] itemRow = DBAdmin.Products.Select("Code =
'"+itemCode+"'");
4 addItemRow["Code"] = itemRow[0]["Code"].ToString();
5 addItemRow["Amount"] = itemRow[0]
["SellPriceIn"].ToString();
6 addItemRow["Vat"] = itemRow[0]["Vat"].ToString();
7 addItemRow["Qty"] = 1;
8 addItemRow["DocNo"] = 2;
DBAdmin.DLitem.Rows.Add(addItemRow);
}
This my code and this is the error i get on line 4

"Index was outside the bounds of the array"

Any suggestions ? on what i am doing wrong
Check itemRow.Count to see if there's even any records found by your select. The
error you're getting would seem to indicate there are no entries in the itemRow
array.

Chris.
Jun 27 '08 #2
On May 5, 7:36*am, Cdude <camelj...@yahoo.comwrote:
1 public void AddItem(string itemCode)
2 * * * *{
3 * * * * * *DataRow[] itemRow = DBAdmin.Products.Select("Code =
'"+itemCode+"'");
4 * * * * * addItemRow["Code"] = itemRow[0]["Code"].ToString();
5 * * * * * *addItemRow["Amount"] = itemRow[0]
["SellPriceIn"].ToString();
6 * * * * * *addItemRow["Vat"] = itemRow[0]["Vat"].ToString();
7 * * * * * *addItemRow["Qty"] = 1;
8 * * * * * *addItemRow["DocNo"] = 2;
* * * * * * DBAdmin.DLitem.Rows.Add(addItemRow);
* * * *}
This my code and this is the error i get on line 4

"Index was outside the bounds of the array"

Any suggestions ? on what i am doing wrong
Are you sure that you are getting at least one row?
Jun 27 '08 #3
I don't see where you have created "addItemRow", but you proceed to use it
anyway. example:

DataRow addItemRow = DBAdmin.Producst.NewRow();

-- Peter
To be a success, arm yourself with the tools you need and learn how to use
them.

Site: http://www.eggheadcafe.com
http://petesbloggerama.blogspot.com
http://ittyurl.net
"Cdude" wrote:
1 public void AddItem(string itemCode)
2 {
3 DataRow[] itemRow = DBAdmin.Products.Select("Code =
'"+itemCode+"'");
4 addItemRow["Code"] = itemRow[0]["Code"].ToString();
5 addItemRow["Amount"] = itemRow[0]
["SellPriceIn"].ToString();
6 addItemRow["Vat"] = itemRow[0]["Vat"].ToString();
7 addItemRow["Qty"] = 1;
8 addItemRow["DocNo"] = 2;
DBAdmin.DLitem.Rows.Add(addItemRow);
}
This my code and this is the error i get on line 4

"Index was outside the bounds of the array"

Any suggestions ? on what i am doing wrong
Jun 27 '08 #4

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

Similar topics

13
3709
by: PS | last post by:
I want to display the image from database to picture box through ado.net and vb.net I have some images present in a sql server 2000 table stored under 'image' datatype. I want to extract and...
0
1080
by: Oldhandandy | last post by:
I've created a dataset from a stored procedure. I want to extract data from certain fields within the dataset without having to create a datagrid.
1
17130
by: v0lcan0 | last post by:
Any help on extracting the time part from the datetime field in SQL database. even though i had entered only the time part in the database when i extract the field it gives me only the date...
3
3999
by: Elena | last post by:
I need to extract data from a recordset. I have to find the identifier of the table and add 1 to it. In VB6, I used a recordset, as in the code below: 'get a new item number strsql = "Select...
1
2105
by: Terry Olsen | last post by:
Ok, now that I've got my disk imager program working, I'd like to attach a "self-extractor" to the front end of the image file and make it a self-extracting disk image executable file. The idea...
4
1408
by: Byron Hopp | last post by:
We have the need to extract data from an ADO dataset to an Access MDB. We have this working be having an empty MDB that we copy and utilize for the extract. We get errors on an irregular basis. ...
13
3717
by: Randy | last post by:
Is there any way to do this? I've tried tellg() followed by seekg(), inserting the stream buffer to an ostringstream (ala os << is.rdbuf()), read(), and having no luck. The problem is, all of...
1
2508
by: matt | last post by:
hello, i have a web app that allows users to query our oracle db and produce a dataset of report data. they then have the option to serialize this data and store it in the database. later, then...
3
1748
by: Clarisa | last post by:
Hello Folks I am working on extracting lines of data in a text file based on the string it contains. This is the text file called info.txt:
4
3006
by: apatel85 | last post by:
Hey Guys, Total Number of Records (Based on 5 fields): 1000 Total Unique Records (Based on 5 Fields): 990 Total number of fields: 5 I have question regarding extracting duplicates from the...
0
7257
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
7157
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
7379
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
7098
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7521
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
5084
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4745
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
1
798
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
455
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.