473,324 Members | 2,257 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,324 software developers and data experts.

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

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(InvoiceNumber) 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 1250
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
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...
2
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...
4
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...
2
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...
2
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...
10
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...
6
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...
2
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...
4
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...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.