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 21121
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: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
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...
|
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...
|
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...
|
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)...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
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....
|
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...
| |