You must Sign In to post a response.
  • Category: ASP.NET

    After Hosting My Appliction geting this Type Of Error

    Hi,

    Am Developing small application with using image uploading in my local system running successfully but after hosting my application in CPanel(server) getting this type of error what to do..

    In DB :

    image data type default size is 16 ,which size is correct to running


    Error Is:
    Server Error in '/' Application.
    Incorrect syntax near '*'.
    Incorrect syntax near '*'.
    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

    Exception Details: System.Data.SqlClient.SqlException: Incorrect syntax near '*'.
    Incorrect syntax near '*'.

    Source Error:


    Line 107: Comm.Parameters.Add("@img", SqlDbType.Image, myimage.Length).Value = myimage;
    Line 108:
    Line 109: Comm.ExecuteNonQuery();
    Line 110: con.Close();
    Line 111: Page.ClientScript.RegisterStartupScript(this.GetType(), "alert", "<script>alert('Services Added Successfully!');</script>");


    Source File: c:\inetpub\vhosts\nrstex.com\httpdocs\admin\ImportGallery.aspx.cs Line: 109

    Stack Trace:

    [SqlException (0x80131904): Incorrect syntax near '*'.
    Incorrect syntax near '*'.]
    System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction) +1789270

    My Original Code:
    if (Session["UserName"] != null)
    {
    if (imgupload.PostedFile != null && imgupload.PostedFile.FileName != "")
    {

    // SqlConnection conn = new SqlConnection("data source=vps1;initial catalog=schoolAdmin;Integrated Security=SSPI");
    connection();
    con = new SqlConnection(con_str);
    con.Open();
    byte[] myimage = new byte[imgupload.PostedFile.ContentLength];
    HttpPostedFile Image = imgupload.PostedFile;
    Image.InputStream.Read(myimage, 0, (int)imgupload.PostedFile.ContentLength);

    SqlCommand Comm = new SqlCommand("insert into GallaryfoMyProduct values(" + txtimgcount.Text + ",'" + drpservices.Text + "'," + lblCategoryId.Text + "," + txtproid.Text + ",@img)", con);
    Comm.Parameters.Add("@img", SqlDbType.Image, myimage.Length).Value = myimage;

    Comm.ExecuteNonQuery();
    con.Close();
    Page.ClientScript.RegisterStartupScript(this.GetType(), "alert", "<script>alert('Services Added Successfully!');</script>");
    ImageCount();
    ClearAll();
    }
    }
  • #765842
    Hi,

    In which line are you getting this error exactly? Please highlight that line and as per error there is some syntax problem while wrote sql query. Please check the query which returns through your debugger and execute the same in sql server management and check whether it throws any error in management or not, for sure it throws the same error which you got in screen, while execute any query in sql you have to follow the specific syntax for each and every statement but in your case you may missed that syntax, because of that only you got this error.

    --------------------------------------------------------------------------------
    Give respect to your work, Instead of trying to impress your boss.

    N@veen
    Blog : http://naveens-dotnet.blogspot.in/

  • #765853
    Incorrect syntax near '*'. indicates there is a sql query error while executing. Please checkout for your sql query and try to find out why this giving you error
    Thanks
    Koolprasd2003
    Editor, DotNetSpider MVM
    Microsoft MVP 2014 [ASP.NET/IIS]

  • #765854
    I hope the issue may be in the following line

    ("insert into GallaryfoMyProduct values(" + txtimgcount.Text + ",'" + drpservices.Text + "'," + lblCategoryId.Text + "," + txtproid.Text + ",@img)", con);

    specifically check the the part ",@img)"

    By Nathan
    Direction is important than speed


Sign In to post your comments