Reputation: 34152
There is this question here: insert datetime value in sql database with c# that works perfectly but I want to do something like this:
if(IsPostBack)
{
for(int i = 0; i<100; i++)
{
commandText += string.Format( "insert into table (valuecoumn,datecolumn)" +
"values({0},{1});" ,
Request.Form["value-"+ i.ToString()],
Request.Form["date-"+ i.ToString()]);
}
cmd.CommandText = commandText;
cmd.ExecuteNonQuery();
}
Now how should I deal with this as there are multiple date values?
Upvotes: 0
Views: 384
Reputation:
Try putting single-quotes around the date-value in your format string
'{1}'
See if that helps. In fact there is actually no problem quoting up all your values that way. SQL Server will un-quote anything it doesn't like quoted.
Upvotes: 1