How can i read the return value from 'Select Where' statement , every time i run no return value appear in the label, and no syntax error.
May 31, 2013 - Then define following table in your database CREATE TABLE. ExecuteScalar; insCmd = new MySqlCommand('INSERT. Journalkey to be fetched every time the accounting legs are identified for insert.
Robaticus20.4k44 gold badges5050 silver badges6565 bronze badges
A.RA.R10811 gold badge66 silver badges1414 bronze badges
3 Answers
If the
product_price
column is not of type TEXT
in MySQL, the Reader.GetString(0)
will (depending on how the reader was implemented by Oracle) throw an Exception or return an empty string. I would think the latter is happening.![Accounting with c sharp and sql or mysql download Accounting with c sharp and sql or mysql download](https://codecanyon.img.customer.envatousercontent.com/files/227766462/inline_preview_image.jpg?auto=compress%2Cformat&fit=crop&crop=top&w=590&h=300&s=dd913098f780e343929ad1e7294308b0)
Retrieving the value through a
DataReader
requires you to know the data type. You can not simply read a string for every type of field. For example, if the field in the database is an Integer, you need to use GetInt32(...)
. If it is a DateTime
use GetDateTime(...)
. Using GetString
on a DateTime
field won't work.![Accounting with c sharp and sql or mysql server Accounting with c sharp and sql or mysql server](https://cloud.google.com/compute/docs/tutorials/images/visual-studio-publish-app.png)
EDIT
This is how I'd write this query:
Thorsten DittmarThorsten DittmarThis is how I'd write this query:
48k44 gold badges7373 silver badges121121 bronze badges
To append to my comment, your approach has three problems which are not part of your problem:
- SQL-Injection, always use parameterized queries.
- Leaking resources, IDisposable-Objects need to be treated properly.
- Bad habits,
' + string
for casting is...uhhh...not good and not necessary.
So, a more correct version for your code would look like this:
1,64677 gold badges3434 silver badges5353 bronze badges