473,811 Members | 2,963 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.Product s.Select("Code =
'"+itemCode+"'" );
4 addItemRow["Code"] = itemRow[0]["Code"].ToString();
5 addItemRow["Amount"] = itemRow[0]
["SellPriceI n"].ToString();
6 addItemRow["Vat"] = itemRow[0]["Vat"].ToString();
7 addItemRow["Qty"] = 1;
8 addItemRow["DocNo"] = 2;
DBAdmin.DLitem. Rows.Add(addIte mRow);
}
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 1041
Cdude wrote:
1 public void AddItem(string itemCode)
2 {
3 DataRow[] itemRow = DBAdmin.Product s.Select("Code =
'"+itemCode+"'" );
4 addItemRow["Code"] = itemRow[0]["Code"].ToString();
5 addItemRow["Amount"] = itemRow[0]
["SellPriceI n"].ToString();
6 addItemRow["Vat"] = itemRow[0]["Vat"].ToString();
7 addItemRow["Qty"] = 1;
8 addItemRow["DocNo"] = 2;
DBAdmin.DLitem. Rows.Add(addIte mRow);
}
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...@yaho o.comwrote:
1 public void AddItem(string itemCode)
2 * * * *{
3 * * * * * *DataRow[] itemRow = DBAdmin.Product s.Select("Code =
'"+itemCode+"'" );
4 * * * * * addItemRow["Code"] = itemRow[0]["Code"].ToString();
5 * * * * * *addItemRow["Amount"] = itemRow[0]
["SellPriceI n"].ToString();
6 * * * * * *addItemRow["Vat"] = itemRow[0]["Vat"].ToString();
7 * * * * * *addItemRow["Qty"] = 1;
8 * * * * * *addItemRow["DocNo"] = 2;
* * * * * * DBAdmin.DLitem. Rows.Add(addIte mRow);
* * * *}
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.Producs t.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.Product s.Select("Code =
'"+itemCode+"'" );
4 addItemRow["Code"] = itemRow[0]["Code"].ToString();
5 addItemRow["Amount"] = itemRow[0]
["SellPriceI n"].ToString();
6 addItemRow["Vat"] = itemRow[0]["Vat"].ToString();
7 addItemRow["Qty"] = 1;
8 addItemRow["DocNo"] = 2;
DBAdmin.DLitem. Rows.Add(addIte mRow);
}
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
3741
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 display them in a picture box present in a vb.net form I appreciate any help on this Thanks PS
0
1102
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
17196
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 part. i’m using Vb.net datagrid as a front end. any assistance appreciated!! :?: --
3
4007
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 * from Action where item_identifier = " & intActionID & " order by action_identifier" Set rsAction = CriticalItems.cn.Execute(strsql) If rsAction.RecordCount = 0 Then intActionIdentifier = 1
1
2117
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 being that the user would double-click on the file and the disk would be created. I would like to be able to "create" the self-extracting disk image from my program. Any guidance on how to go about doing this? thanks.
4
1422
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. What would be the best practice to provide this to a user in an MDB format. Is there something like ADOX in .net? Any ideas? Thanks, Byron...
13
3743
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 these methods EXTRACT the data at one point or another. The other problem is there appears to be NO WAY to get at the actual buffer pointer (char*) of the characters in the stream. There is a way to get the streambuf object associated with the...
1
2540
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 can re-run the report and get fresh data. now, they would like to be able to compare the fresh data to the stored data, getting a break-down of added/deleted/changed rows. on the surface, this sounded plausible -- by deserializing the stored
3
1764
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
3026
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 dataset. I have 2 fields that makes a record unique. I have used group by function to find duplicates and got 10 records that are duplicating. Each records duplicating 1 times, thus, 10 unique records and 10
0
9734
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9607
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10663
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10138
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9217
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5567
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4357
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3881
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3029
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.