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();
}
}