1

i have put the following code in .aspx

<asp:TextBox ID="txtyourwords" runat="server" Rows="1" TextMode="MultiLine">
</asp:TextBox>


SqlCommand cmd = new SqlCommand("Insert INTO planning_t (date,course,planning) values("+Calendar1.SelectedDate.ToShortDateString()+","+DropDownList2.SelectedIt‌​‌​em.Text+","+txtyourwords.Text.ToString()+" )", con);

now i want to insert the contents of textbox--(txtyourwords) into a table... what will be code in C# for .cs file. and datatype for this column is varchar(MAX).

3
  • You havent posted the code. Commented Feb 17, 2015 at 15:53
  • error is: Error getting data. Incorrect syntax near 'Engineering'. 'Engineering' is dropdownlist.selecteditem.text Commented Feb 17, 2015 at 17:16
  • {SqlCommand cmd = new SqlCommand("Insert INTO planning_t (date,course,planning) values("+Calendar1.SelectedDate.ToShortDateString()+","+DropDownList2.SelectedIt‌​em.Text+","+txtyourwords.Text.ToString()+" )", con);} Commented Apr 14, 2015 at 7:08

1 Answer 1

1
SqlCommand cmd = new SqlCommand("Insert INTO planning_t (date,course,planning) values('"+Calendar1.SelectedDate.ToShortDateString()+"','"+DropDownList2.SelectedIt‌​em.Text+"','"+txtyourwords.Text.ToString()+"' )", con);
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.