'/ SaveImagesinFolderDisplayInGridview'应用程序中的服务器错误。 [英] Server Error in '/SaveImagesinFolderDisplayInGridview' Application.

查看:70
本文介绍了'/ SaveImagesinFolderDisplayInGridview'应用程序中的服务器错误。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请帮助我,我不知道如何解决这个问题





''/ SaveImagesinFolderDisplayInGridview''应用程序中的服务器错误。

''14'附近的语法不正确。

描述:在执行当前Web请求期间发生了未处理的异常。请查看堆栈跟踪以获取有关错误及其在代码中的起源的更多信息。



异常详细信息:System.Data.SqlClient.SqlException:附近的语法不正确'14''。



来源错误:





第24行:con.Open();

第25行:SqlCommand cmd = new SqlCommand(从ImagesPath中删除ID''+ t1.Text +'',con);

第26行:cmd.ExecuteNonQuery();

第27行:// GridView1();

第28行:con.Close();





源文件:e:\ visual work \SaveImagesinFolderDisplayInGridview \SaveImagesinFolderDisplayInGridview \Default2.aspx.cs Line:26

please help me i donot know how to solv this problem


Server Error in ''/SaveImagesinFolderDisplayInGridview'' Application.
Incorrect syntax near ''14''.
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 ''14''.

Source Error:


Line 24: con.Open();
Line 25: SqlCommand cmd = new SqlCommand("delete from ImagesPath where ID''" + t1.Text + "''", con);
Line 26: cmd.ExecuteNonQuery();
Line 27: //GridView1();
Line 28: con.Close();


Source File: e:\visual work\SaveImagesinFolderDisplayInGridview\SaveImagesinFolderDisplayInGridview\Default2.aspx.cs Line: 26

推荐答案

无论t1.Text是什么导致了问题。您无论如何都需要使用参数化查询,以便您不会对SQL注入开放。
Whatever was in t1.Text was causing an issue. You need to use a parameterized query anyway so that you are not open to SQL injection.


这篇关于'/ SaveImagesinFolderDisplayInGridview'应用程序中的服务器错误。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆