473,779 Members | 2,078 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to read values from a datatable? Or just increment values...

97 New Member
OK here's my code:

Expand|Select|Wrap|Line Numbers
  1. SqlConnection dbConnection = new SqlConnection(xmldb);
  2. SqlCommand cmd = new SqlCommand(" SELECT * FROM dbo.fnInvoiceID() ", dbConnection);
  3. cmd.CommandType = CommandType.Text;
  4. SqlDataAdapter da = new SqlDataAdapter(cmd);
  5. DataTable dt = new DataTable();
  6.  
  7. int invNum = da.Fill(dt);
  8. invNum = invNum + 1; 
  9.  
  10. comboBox.DataSource = dt;
  11. comboBox.DisplayMember = "InvoiceNumber";
  12. comboBox.ValueMember = "InvoiceNumber";
I would like to be able to put:
Expand|Select|Wrap|Line Numbers
  1. comboBox.DataSource = invNum;
In this manner I would get the +1 increment that I want. I succesfully obtain 13 from the function but it's supposed to be 14 since there's the max(InvoiceNumb er) Invoice. 14 will be the new Invoice...any other suggestions?
When I try:
Expand|Select|Wrap|Line Numbers
  1. comboBox.DataSource = invNum;
I get this error:
Expand|Select|Wrap|Line Numbers
  1. "Complex DataBinding accepts as a data source either an IList or an IListSource."
Jan 11 '08 #1
1 1271
gggram2000
97 New Member
Well I solved it, thanks for all ur hard work.
Jan 14 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
1408
by: Hanover | last post by:
Here is a very strange problem that is difficult to explain. I am populating a datagrid with a datatable. I had to add an additional field to my data adapter/datatable which I have to reference during my update. The field should have values such as: 767 790
2
15639
by: Omavlana Omav | last post by:
Hi, I have created a datatable, dataadapter, added the table to a dataset and filling the table. Here I want to add an identity column to the above datatable and Later I will use this identity colum for printing the records using print document. How to create an identity column that increments its value when each row
4
5431
by: Jon | last post by:
i have a dataset with a few datatable inside. most of my table are have values as in integer or double. but everything i read my table out e.g. "row.Item("ItemName").ToString I always need to use the "ToString" method to read the entry out, which means i need to convert it with Integer.Parse().....then store it to another integer...then do calculation...then store it back to the datatable using the ToString method again.
2
3444
by: Oenone | last post by:
Something I've found quite useful to do in my code is to select a record from my database which may or may not exist, and then if I find that it doesn't exist to add it to the datatable before I set the field values. For example: Dim dt As DataTable dim dr As DataRow 'Does the row already exist in the table?
2
16898
by: Scott M. Lyon | last post by:
I currently am working on a VB.NET application that imports data from an Excel spreadsheet that the customer filled in. I used the following code to use ODBC to read the data from the spreadsheet, and return it in a datatable. Public Function ReadExcelDT(ByVal aFileName As String) As DataTable ' Open the Excel Spreadsheet, and using ODBC, read it into a DataTable for later processing
10
3716
by: D. Shane Fowlkes | last post by:
I have a function that is called in page_load and the purpose of this function is to look up basic data in a MSSQL table and return it in the form of a datatable. The page_load will read the data and then fill a few simple labels. **Assuming** that I wrote the function properly, how exactly can I write the page_load sub to read the data from the function? I've tried a few examples from a couple of books I have but can't seem to get a...
6
8163
Cintury
by: Cintury | last post by:
Hi all, I've developed a mobile application for windows mobile 5.0 that has been in use for a while (1 year and a couple of months). It was developed in visual studios 2005 with a back-end sql server mobile ce database. Until recently I was synching everything thru a com port serial cable. The devices would connect to the computer thru activesync and are able to acquire an internet connection. The sync for the program occurs thru a website...
2
5870
by: PulkitZery | last post by:
Hello, I am trying to create a Dataset and save it to an XML file. I have one column “JobID” for which I have set the autoincrement property to true. Here is the function that creates and save the dataset: Public Sub CreateDataSet() Dim tbMain As DataTable = New DataTable("UploadLog") 'Job ID – Auto increments Dim drJobID As New DataColumn("JobID")
4
3514
by: =?Utf-8?B?TWlrZSBE?= | last post by:
I read the CSV file into a DataTable. This is so I can fix invalid dates and other data I don't want in the database. Then I use SqlBulkCopy to insert the data into the SQL database. All the rows are being read and inserted into the table. The problem is that one of the columns in the CSV contains the value of 1 thru 6 or C, BUT only the numbers seem to be read into the DataTable not the letter. I tried single quotes and double quotes...
0
9636
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
10306
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
10139
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10075
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9931
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
8961
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...
1
7485
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5504
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3632
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.