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
Marvin kakuru
1.4k
359
160.8k
Error converting data type varchar to numeric
Aug 12 2011 7:19 AM
hi all. ope your allright,
i am inserting into my sql database data from a datagridview1, however some of the values are numeric and i keep on getting an error - " ERROR CONVERTING DATA TYPE VARCHAR TO NUMERIC"
funny though the data is inserted into the database table, but the error remains below is the code i am using.
foreach (DataGridViewRow row in dataGridView1.Rows)
{
string insertString = " insert into Treatmentpurchases (day,date,month,year,wkno,drugid,drugname,drugmeasure,cost,duration) values ('" + row.Cells["Day"].Value + "' , '" + row.Cells["Date"].Value + "' , '" + row.Cells["Month"].Value + "' , '" + row.Cells["Year"].Value + "' , '" + row.Cells["Wkno"].Value + "' , '" + row.Cells["Drugid"].Value + "' , '" + row.Cells["Drug"].Value + "' , '" + row.Cells["Measure"].Value + "' , '" + row.Cells["Cost"].Value + "' , '" + row.Cells["Duration"].Value + "')";
SqlCommand cmd = new SqlCommand(insertString, conn);
cmd.ExecuteNonQuery();
}
the numeric values are wkno and year. Any help???
Reply
Answers (
11
)
Two language using resource.resx in c sharp
How to animate waveform from array of values