I have a decimal amount in c#:
decimal amounT = 62.75;
and I need INSERT it into a SQL record as a money value.
string strSQL2 = "INSERT INTO trvlDetail(amountfield) ""VALUES ('" +
amounT + "') ";
Should I use a CONVERT in SQL (if so, how?) or what would be the
equivelent in c#?
Thanks,
Trint 10 21130
Hi Trint,
Use an SqlParameter, it will convert for you
decimal amounT = 62.75;
SqlParameter param = new SqlParameter(@amounT, amounT);
string strSQL2 = "INSERT INTO trvlDetail(amountfield) VALUES (@amounT)";
SqlCommand insertCommand = new SqlCommand(strSQL2, SqlConnection1);
insertCommand.Parameters.Add(param);
SqlConnection1.Open();
insertCommand.ExecuteNonQuery();
SqlConnection1.Close();
On Wed, 20 Apr 2005 14:22:49 +0200, trint <tr***********@gmail.com> wrote: decimal amounT = 62.75;
--
Happy coding!
Morten Wennevik [C# MVP]
Hi Trint,
Use an SqlParameter, it will convert for you
decimal amounT = 62.75;
SqlParameter param = new SqlParameter(@amounT, amounT);
string strSQL2 = "INSERT INTO trvlDetail(amountfield) VALUES (@amounT)";
SqlCommand insertCommand = new SqlCommand(strSQL2, SqlConnection1);
insertCommand.Parameters.Add(param);
SqlConnection1.Open();
insertCommand.ExecuteNonQuery();
SqlConnection1.Close();
On Wed, 20 Apr 2005 14:22:49 +0200, trint <tr***********@gmail.com> wrote: decimal amounT = 62.75;
--
Happy coding!
Morten Wennevik [C# MVP]
Ok, I did as you said and got this error:
"Disallowed implicit conversion from data type varchar to data type
money, table 'tsNess.dbo.trvlDetail', column 'amount'. Use the CONVERT
function to run this query."
..Net programmer tr***********@gmail.com
*** Sent via Developersdex http://www.developersdex.com ***
Ok, I did as you said and got this error:
"Disallowed implicit conversion from data type varchar to data type
money, table 'tsNess.dbo.trvlDetail', column 'amount'. Use the CONVERT
function to run this query."
..Net programmer tr***********@gmail.com
*** Sent via Developersdex http://www.developersdex.com ***
Did you remove the ''?
VALUE(@amounT) without ''
On Wed, 20 Apr 2005 15:44:20 +0200, Trint Smith <tr***********@gmail.com> wrote: Ok, I did as you said and got this error:
"Disallowed implicit conversion from data type varchar to data type money, table 'tsNess.dbo.trvlDetail', column 'amount'. Use the CONVERT function to run this query."
.Net programmer tr***********@gmail.com
*** Sent via Developersdex http://www.developersdex.com ***
--
Happy coding!
Morten Wennevik [C# MVP]
Did you remove the ''?
VALUE(@amounT) without ''
On Wed, 20 Apr 2005 15:44:20 +0200, Trint Smith <tr***********@gmail.com> wrote: Ok, I did as you said and got this error:
"Disallowed implicit conversion from data type varchar to data type money, table 'tsNess.dbo.trvlDetail', column 'amount'. Use the CONVERT function to run this query."
.Net programmer tr***********@gmail.com
*** Sent via Developersdex http://www.developersdex.com ***
--
Happy coding!
Morten Wennevik [C# MVP]
Sorry, forgot to remove that. It works now.
Morten Wennevik wrote: Did you remove the ''?
VALUE(@amounT) without ''
On Wed, 20 Apr 2005 15:44:20 +0200, Trint Smith
<tr***********@gmail.com> wrote: Ok, I did as you said and got this error:
"Disallowed implicit conversion from data type varchar to data type money, table 'tsNess.dbo.trvlDetail', column 'amount'. Use the
CONVERT function to run this query."
.Net programmer tr***********@gmail.com
*** Sent via Developersdex http://www.developersdex.com *** -- Happy coding! Morten Wennevik [C# MVP]
Sorry, forgot to remove that. It works now.
Morten Wennevik wrote: Did you remove the ''?
VALUE(@amounT) without ''
On Wed, 20 Apr 2005 15:44:20 +0200, Trint Smith
<tr***********@gmail.com> wrote: Ok, I did as you said and got this error:
"Disallowed implicit conversion from data type varchar to data type money, table 'tsNess.dbo.trvlDetail', column 'amount'. Use the
CONVERT function to run this query."
.Net programmer tr***********@gmail.com
*** Sent via Developersdex http://www.developersdex.com *** -- Happy coding! Morten Wennevik [C# MVP] This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Jason |
last post by:
Could someone here show me how I would write a vb program to convert decimal
ip address to binary?
For example a small form with a convert button and a label for the result
and a textbox for the...
|
by: Ray |
last post by:
I have a table with some audit date and time columns. Problem is the
developer who stored the data left them as DECIMAL type instead of DATE
and TIME. Is there a way I can convert the DECIMAL type...
|
by: muss |
last post by:
how to convert decimal number in a hexadecimal number using C?
Please help me.
Thanks.
|
by: lathasree |
last post by:
Hi, this is sreelatha give a c progrm to convert decimal to binary....
thank u....
|
by: sweeet_addiction16 |
last post by:
hello
Im writin a code in c...
can sum1 pls help me out in writing a c code to convert decimalnumber
to hexadecimal number.The hexadecimal number generated has to be an
unsigned long.
|
by: karanbikash |
last post by:
Hi ,
I have a requirement where in I need to display the decimal value of
0.00 as '######.00'
SELECT case when DECIMAL(AMT_CHEQUE,31,2) = 0.00 THEN
9999999999999.9999999
ELSE ...
|
by: nirmalsingh |
last post by:
Hai all,
i want to convert decimal to time. for example
if i have decimal number 09.6 then i need it as 10.00 and also decimal 10.118 as 11.58. How to convert this?
Thanx in advance
with Cheers...
|
by: Vitaliy |
last post by:
Hi
I got this wired exception periodically (Python 2.5, Django based
application)
what does it mean ?
|
by: Rolandas |
last post by:
Hi,
Can anyone help me?
I need a code in VBA which would convert decimal numbers to the other system bases on number 36.
e.g. in this page...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
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: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
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...
| |