I do not want to use the datagrid, datalist, etc. I want to retrieve
simply the value from the query.
I know the sql is returning data, because, if I use a grid, I can
populate it.
I have looked everywhere, but it won't work.
Dim resultsDataSet as New DataSet()
Dim myDataAdapter as odbcdataadapter
myDataAdapter = New odbcdataadapter(sqlLastID, conn)
'this works fine here
myDataAdapter.Fill(resultsDataSet)
order_id_grid.DataSource = resultsDataSet
order_id_grid.DataBind()
'this does not
temp = resultsDataSet.tables(0).rows("order_id").toString ()
it complains that:
Input string was not in a correct format.
Thank you for any help. I cannot find the answer. The returning
value from the database is an integer. I have tried it with temp as a
string and an integer. Thanks again. 3 1838
If filling the Dataset isn't really needed, you can use the ExecuteScalar()
Function of command object to return the first column of the first row.
Even if you do need the Dataset, you can still use the function, as it would
be more efficient than getting it out of the dataset.
temp = sqlLastID.ExecuteScalar()
HTH,
--Michael
"jm" <jo*************@yahoo.com> wrote in message
news:c6**************************@posting.google.c om... I do not want to use the datagrid, datalist, etc. I want to retrieve simply the value from the query.
I know the sql is returning data, because, if I use a grid, I can populate it.
I have looked everywhere, but it won't work.
Dim resultsDataSet as New DataSet() Dim myDataAdapter as odbcdataadapter myDataAdapter = New odbcdataadapter(sqlLastID, conn)
'this works fine here myDataAdapter.Fill(resultsDataSet) order_id_grid.DataSource = resultsDataSet order_id_grid.DataBind()
'this does not
temp = resultsDataSet.tables(0).rows("order_id").toString ()
it complains that:
Input string was not in a correct format.
Thank you for any help. I cannot find the answer. The returning value from the database is an integer. I have tried it with temp as a string and an integer. Thanks again.
Thanks. Was my syntax or something wrong on the other version I tried?
"Michael" <raterus@localhost> wrote in message news:<uw**************@TK2MSFTNGP09.phx.gbl>... If filling the Dataset isn't really needed, you can use the ExecuteScalar() Function of command object to return the first column of the first row. Even if you do need the Dataset, you can still use the function, as it would be more efficient than getting it out of the dataset.
temp = sqlLastID.ExecuteScalar()
HTH, --Michael
"jm" <jo*************@yahoo.com> wrote in message news:c6**************************@posting.google.c om... I do not want to use the datagrid, datalist, etc. I want to retrieve simply the value from the query.
I know the sql is returning data, because, if I use a grid, I can populate it.
I have looked everywhere, but it won't work.
Dim resultsDataSet as New DataSet() Dim myDataAdapter as odbcdataadapter myDataAdapter = New odbcdataadapter(sqlLastID, conn)
'this works fine here myDataAdapter.Fill(resultsDataSet) order_id_grid.DataSource = resultsDataSet order_id_grid.DataBind()
'this does not
temp = resultsDataSet.tables(0).rows("order_id").toString ()
it complains that:
Input string was not in a correct format.
Thank you for any help. I cannot find the answer. The returning value from the database is an integer. I have tried it with temp as a string and an integer. Thanks again.
fyi, the correct syntax would be
temp = resultsDataSet.tables(0).rows(0)("order_id")
You have to specify that you actually wanted the first row
"jm" <jo*************@yahoo.com> wrote in message
news:c6**************************@posting.google.c om... Thanks. Was my syntax or something wrong on the other version I tried?
"Michael" <raterus@localhost> wrote in message
news:<uw**************@TK2MSFTNGP09.phx.gbl>... If filling the Dataset isn't really needed, you can use the
ExecuteScalar() Function of command object to return the first column of the first row. Even if you do need the Dataset, you can still use the function, as it
would be more efficient than getting it out of the dataset.
temp = sqlLastID.ExecuteScalar()
HTH, --Michael
"jm" <jo*************@yahoo.com> wrote in message news:c6**************************@posting.google.c om... I do not want to use the datagrid, datalist, etc. I want to retrieve simply the value from the query.
I know the sql is returning data, because, if I use a grid, I can populate it.
I have looked everywhere, but it won't work.
Dim resultsDataSet as New DataSet() Dim myDataAdapter as odbcdataadapter myDataAdapter = New odbcdataadapter(sqlLastID, conn)
'this works fine here myDataAdapter.Fill(resultsDataSet) order_id_grid.DataSource = resultsDataSet order_id_grid.DataBind()
'this does not
temp = resultsDataSet.tables(0).rows("order_id").toString ()
it complains that:
Input string was not in a correct format.
Thank you for any help. I cannot find the answer. The returning value from the database is an integer. I have tried it with temp as a string and an integer. Thanks again. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Mike |
last post by:
Hi,
How to read archived system eventlog file (*.evt) in C# ?
Any code samples ?
-Mike
|
by: Paulb1us |
last post by:
I have a CSV file, like the one you can save in Excel.
I want to use C# .NET to read the file and place the data into a sql2k data
base. and then import another file that would update those same...
|
by: Dave |
last post by:
I am trying to learn .NET with the standard edition of
VC++.NET 2003 Standard edition. When I use the wizard in
the toolbox to connect to a non-microsoft ODBC data
source, I get the error message...
|
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...
|
by: Rob Dob |
last post by:
SQLDataAdapter. ODBCDataAdapter etc. Have they disappeared from .Net 2.0
Webforms?
can somone please elaborate as I cannot seem to find support for these..
|
by: Smile |
last post by:
hi
any one can tell me how can i Read Access Data base Using C#.net
windows
which refrence i hav to use , ConnectionString , reader
and all
actualy i want to append DAta from Access (Pickup.mdb)...
|
by: paul.d.mcswain |
last post by:
This has probably already been answered, but it didn't show up when I
did a search.
I need to be able to perform a batch insert using the ODBC ADO.NET
objects (OdbcCommand, OdbcDataAdapter,...
|
by: roundcrisis |
last post by:
hiL i have teh following code:
string query = "select * FROM users";
OdbcCommand command = new OdbcCommand(query,
conn);
OdbcDataAdapter da = new OdbcDataAdapter();
da.SelectCommand = command;...
|
by: monteiro |
last post by:
Hi,
I am using OdbcDataAdapter to insert data to postgreeSQL..
Everything’s seems to be fine, but nothing is inserting in the database. Andy Idea??
Thanks in advance
string selectCommand =...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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
|
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,...
|
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...
|
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,...
|
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...
|
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...
|
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,...
|
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...
| |