I am newbie in asp and sql, and I am using VS & SQL express
when I try to submit I get following error
"Conversion failed when converting character string to smalldatetime data type"
Following is my insert statement
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:oncallConnectionString %>"
SelectCommand="SELECT data.* FROM data" InsertCommand="INSERT INTO data(Apps, Location, Impact, System, Date, Start_Time, End_Time, Duration, Problem, Cause, Solution, Case, Comments) VALUES ('@.DropDownList1','@.DropDownList2','@.DropDownList3','@.TextBox6','@.DropDownCalendar1','@.DropDownCalendar2','@.DropDownCalendar3','@.TextBox1','@.TextBox2','@.TextBox3','@.TextBox4','@.TextBox5','@.TextBox7')">
</asp:SqlDataSource>
These are @.DropDownCalendar1','@.DropDownCalendar2','@.DropDownCalendar3' defined as datetime in database.
I would appriciate if somebody could help.
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:oncallConnectionString %>"
SelectCommand="SELECT data.* FROM data" InsertCommand="INSERT INTO data(Apps, Location, Impact, System, Date, Start_Time, End_Time, Duration, Problem, Cause, Solution, Case, Comments) VALUES (@.DropDownList1,@.DropDownList2,@.DropDownList3,@.TextBox6,@.DropDownCalendar1,@.DropDownCalendar2,@.DropDownCalendar3,@.TextBox1,@.TextBox2,@.TextBox3,@.TextBox4,@.TextBox5,@.TextBox7)">
</asp:SqlDataSource>
|||
Now I am getting following error
Must declare the scalar variable "@.DropDownList1".
How do I do it in asp, I found the syntax for declare statement but don't know how put it in asp?
Thanks
|||Go to the design view, right click the sqldatasource, choose properties, then choose the selectcommand. A dialog should open, in there you can add all your parameters for the select.|||I did that and still getting same error
after changes it looks like this
<asp:SqlDataSourceID="SqlDataSource1"runat="server"ConnectionString="<%$ ConnectionStrings:oncallConnectionString %>"
SelectCommand="SELECT data.* FROM data"InsertCommand="INSERT INTO data(Apps, Location, Impact, System, tDate, Start_Time, End_Time, Duration, Problem, Cause, Solution, DW_Case, Comments) VALUES (@.DropDownList1,@.DropDownList2,@.DropDownList3,@.TextBox6,@.DropDownCalendar1,@.DropDownCalendar2,@.DropDownCalendar3,@.TextBox1,@.TextBox2,@.TextBox3,@.TextBox4,@.TextBox5,@.TextBox7)">
<SelectParameters>
<asp:FormParameterFormField="DropDownList1"Name="@.Apps"/>
<asp:FormParameterFormField="DropDownList2"Name="@.Location"/>
<asp:FormParameterFormField="DropDownList3"Name="@.Impact"/>
<asp:FormParameterFormField="TextBox6"Name="@.System"/>
<asp:FormParameterFormField="DropDownCalendar1"Name="@.tdate"/>
<asp:FormParameterFormField="DropDownCalendar2"Name="@.Start_time"/>
<asp:FormParameterFormField="DropDownCalendar3"Name="@.End_time"/>
<asp:FormParameterFormField="TextBox1"Name="@.Duration"/>
<asp:FormParameterFormField="TextBox2"Name="@.Problem"/>
<asp:FormParameterFormField="TextBox3"Name="@.Cause"/>
<asp:FormParameterFormField="TextBox4"Name="@.Solution"/>
<asp:FormParameterFormField="TextBox5"Name="@.DW_case"/>
<asp:FormParameterFormField="TextBox7"Name="@.Comments"/>
</SelectParameters>
</asp:SqlDataSource>
I really appreciate your.
Thanks
|||I also tried doing samething with insert parameter and still no luck|||You have to call them the same thing. @.DropDownList1=@.Apps. Change one to the other and repeat for all parameters. Either change the insert statement, replacing @.DropDownList1 with @.Apps, *OR* change the parameter "@.Apps" to use the name "@.DropDownList1".|||Motley
I really appreciate your help,
And a BIG Thanks to you.
No comments:
Post a Comment