TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Israel
698
1.3k
217.7k
Convert string to decimal number
Nov 21 2020 5:06 AM
Hi,
I do try many time to save decimal number into my database but there is erro saying that its cannot save string number. My database has two column (debit and credit) with number type. But when click to save its doesnt and stuck on line I coulored in red.
if
(conn.State != ConnectionState.Open)
conn.Open();
SqlCommand comm =
new
SqlCommand();
comm.Connection = conn;
SqlParameter debit =
new
SqlParameter(
"@debit"
, SqlDbType.Decimal);
SqlParameter credit =
new
SqlParameter(
"@credit"
, SqlDbType.Decimal);
comm.Parameters.Add(debit);
comm.Parameters.Add(credit);
debit.Value = Convert.ToDecimal(txtDebit.Text, CultureInfo.InvariantCulture); //its stucks here
credit.Value = Convert.ToDecimal(txtCredit.Text, CultureInfo.InvariantCulture);
//its stucks here
comm.Connection = conn;
comm.CommandText =
"insert into pay ([debit],[credit])values(@debit,@credit)"
;
{
if
(MessageBox.Show(
"Are you sure to save?"
,
"Save"
, MessageBoxButtons.YesNo) == DialogResult.Yes)
{
try
{
comm.ExecuteNonQuery();
}
finally
{
conn.Close();
}
Reply
Answers (
10
)
change MVC Layout at run time?
how to use ajax correctly in web forms?