Dear Friends,
I am making project for my MCA. It contains a page same like
[
^]
this page contains a query text box where a user can insert his query. If am inserting a small data then it is inserted correctly. if i am inserting large amount of data in the text box then it is giving an error.
Incorrect syntax near 's'.
An expression of non-boolean type specified in a context where a condition is expected, near 'clicks'.
Unclosed quotation mark after the character string ')'.
default.aspx.cs code is:-
string str = (@"server=KANHA-PC;database=codeproject; integrated security=true;");
protected void submit_btn_Click(object sender, EventArgs e)
{
submit_btn_mtd();
}
private void submit_btn_mtd()
{
SqlConnection con = new SqlConnection(str);
string ques = (query_txtbx.Text).ToString();
SqlCommand cmd = new SqlCommand("insert into question_tbl(Asker, Sub, Lang, Question) values('" + Session["user"].ToString() + "','" + sub_txtbx.Text + "','" + tagddl.SelectedValue + "','" + ques + "')", con);
con.Open();
cmd.ExecuteNonQuery();
con.Close();
}
default.aspx
<%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="askquestion.aspx.cs" Inherits="Codeproject.askquestion" %>
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
<style type="text/css">
.style7
{
text-align: justify;
}
</style>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
<p>
<a href="allquestions.aspx">View all question</a>
<a href="askquestion.aspx">ask a question</a>
<a href="Myquest.aspx">Mine</a></p>
<p>
Subject
<asp:TextBox ID="sub_txtbx" runat="server" Width="746px"></asp:TextBox>
</p>
<p>
Tags
<asp:DropDownList ID="tagddl" runat="server">
<asp:ListItem>C#</asp:ListItem>
<asp:ListItem>ASP.NET</asp:ListItem>
<asp:ListItem>VB.NET</asp:ListItem>
<asp:ListItem>Mobile Aplication</asp:ListItem>
<asp:ListItem>Database</asp:ListItem>
<asp:ListItem>C++</asp:ListItem>
</asp:DropDownList>
</p>
<p>
<asp:TextBox ID="query_txtbx" runat="server" Height="384px" Width="748px"
TextMode="MultiLine"></asp:TextBox>
</p>
<p>
<asp:Button ID="submit_btn" runat="server" Text="Submit My Question"
onclick="submit_btn_Click" />
<input type="Reset" name="Reset" />
</p>
<p class="clear">
<asp:TextBox ID="TextBox6" runat="server" Height="307px" TextMode="MultiLine"
Width="686px" AutoCompleteType="Disabled" ReadOnly="True">A few simple rules when posting your question.A few simple rules when posting your question.
1. Have you searched or Googled for a solution?
2. Be specific! Don't ask "I need to write a booking application". Specify exactly what it is you need help with.
3. Keep the subject brief but descriptive. eg "How do I change the dialog colour?"
4. Keep the question as concise as possible. If you have to include code, include the smallest snippet of code you can - do not dump your entire codebase.
5. Tag your question appropriately.
6. Your question may be edited or retagged by others. Anything inappropriate will be removed.
7. If you have a school or university assignment, assume that your teacher or lecturer is also reading these forums.
8. Be courteous and DON'T SHOUT. Everyone here helps because they enjoy helping others, not because it's their job.
9. Do not remove or empty a message if others have replied. Keep the thread intact and available for others to search and read.
10. Do not be abusive, offensive, inappropriate,harass anyone on the boards or post ads or spam. Doing so will get you kicked off and banned. Play nice</asp:TextBox>
</p>
<p>
</p>
</asp:Content>
Database table design is:
create table question_tbl
(
asker nvarchar(100),
Sub nvarchar(1000),
lang varchar(100),
question nvarchar(MAX) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
Q_id int primary key identity(1000,1)
)