运行界面是正常的,但是一些内容提交时就出现下面这个问题,为什么呢??
请帮帮忙,谢谢了!!第 1 行: 'value' 附近有语法错误。
说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。 异常详细信息: System.Data.SqlClient.SqlException: 第 1 行: 'value' 附近有语法错误。源错误:
行 71: Conn.Open();
行 72:
行 73: addcommand.ExecuteNonQuery();
行 74:
行 75: Conn.Close();
源文件: c:\inetpub\wwwroot\views\添加视频.aspx.cs 行: 73
using System.Data.SqlClient;
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;namespace views
{
/// <summary>
/// 添加视频 的摘要说明。
/// </summary>
public class 添加视频 : System.Web.UI.Page
{
protected System.Web.UI.WebControls.Label Label1;
protected System.Web.UI.WebControls.Label Label2;
protected System.Web.UI.WebControls.Label Label3;
protected System.Web.UI.WebControls.TextBox TB1;
protected System.Web.UI.WebControls.TextBox TB2;
protected System.Web.UI.WebControls.RequiredFieldValidator RFV1;
protected System.Web.UI.WebControls.RequiredFieldValidator RFV2;
protected System.Web.UI.WebControls.Button Button1;
protected System.Web.UI.WebControls.Button Button2;
protected System.Web.UI.WebControls.Label Label4;
private void Page_Load(object sender, System.EventArgs e)
{
// 在此处放置用户代码以初始化页面
} #region Web 窗体设计器生成的代码
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.Button1.Click += new System.EventHandler(this.Button1_Click);
this.Load += new System.EventHandler(this.Page_Load); }
#endregion private void Button1_Click(object sender, System.EventArgs e)
{
string connstr="server=127.0.0.1;database=aspnet;uid=sa;pwd=123123";
string strsql="select count(*)from VideoInfo where VideoID like'"+TB1.Text+"'";
SqlConnection Conn=new SqlConnection(connstr);
SqlCommand mycommand=new SqlCommand(strsql,Conn);
Conn.Open();
int flag=(int)mycommand.ExecuteScalar();
Conn.Close();
if(flag==0)
{
string selectstr="insert into VideoInfo(VideoID,VideoAdd)value('"+TB1.Text+"','"+TB2.Text+"',getdate())";
SqlCommand addcommand=new SqlCommand(selectstr,Conn);
Conn.Open(); addcommand.ExecuteNonQuery(); Conn.Close();
Session["VideoID"]=TB1.Text;
Label4.Text="添加成功!";
}
else
{
Label4.Text="错误,请重试!";
TB1.Text="";
TB2.Text="";
}
}
}
}
请帮帮忙,谢谢了!!第 1 行: 'value' 附近有语法错误。
说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。 异常详细信息: System.Data.SqlClient.SqlException: 第 1 行: 'value' 附近有语法错误。源错误:
行 71: Conn.Open();
行 72:
行 73: addcommand.ExecuteNonQuery();
行 74:
行 75: Conn.Close();
源文件: c:\inetpub\wwwroot\views\添加视频.aspx.cs 行: 73
using System.Data.SqlClient;
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;namespace views
{
/// <summary>
/// 添加视频 的摘要说明。
/// </summary>
public class 添加视频 : System.Web.UI.Page
{
protected System.Web.UI.WebControls.Label Label1;
protected System.Web.UI.WebControls.Label Label2;
protected System.Web.UI.WebControls.Label Label3;
protected System.Web.UI.WebControls.TextBox TB1;
protected System.Web.UI.WebControls.TextBox TB2;
protected System.Web.UI.WebControls.RequiredFieldValidator RFV1;
protected System.Web.UI.WebControls.RequiredFieldValidator RFV2;
protected System.Web.UI.WebControls.Button Button1;
protected System.Web.UI.WebControls.Button Button2;
protected System.Web.UI.WebControls.Label Label4;
private void Page_Load(object sender, System.EventArgs e)
{
// 在此处放置用户代码以初始化页面
} #region Web 窗体设计器生成的代码
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.Button1.Click += new System.EventHandler(this.Button1_Click);
this.Load += new System.EventHandler(this.Page_Load); }
#endregion private void Button1_Click(object sender, System.EventArgs e)
{
string connstr="server=127.0.0.1;database=aspnet;uid=sa;pwd=123123";
string strsql="select count(*)from VideoInfo where VideoID like'"+TB1.Text+"'";
SqlConnection Conn=new SqlConnection(connstr);
SqlCommand mycommand=new SqlCommand(strsql,Conn);
Conn.Open();
int flag=(int)mycommand.ExecuteScalar();
Conn.Close();
if(flag==0)
{
string selectstr="insert into VideoInfo(VideoID,VideoAdd)value('"+TB1.Text+"','"+TB2.Text+"',getdate())";
SqlCommand addcommand=new SqlCommand(selectstr,Conn);
Conn.Open(); addcommand.ExecuteNonQuery(); Conn.Close();
Session["VideoID"]=TB1.Text;
Label4.Text="添加成功!";
}
else
{
Label4.Text="错误,请重试!";
TB1.Text="";
TB2.Text="";
}
}
}
}
解决方案 »
- 跪求:C# 如何将积秒转换为正常时间格式(年月日时分秒),有没有直接转换函数?
- 请问如何用HttpWebResponse和HttpWebRequest接收自动刷新的数据?
- VS2003使用问题
- Data Access Application Block 3.1或以上版本能否设定执行操作的超时时间?
- 菜单click问题
- WebForm的学习有没有,类似WinForm的FAQ学习网站?
- listbox 自绘问题
- 關於 Event.__inlineSubmit
- 几天没休息好,头昏脑胀,求个算法
- 求助?web中那个控件可以实现类似winform下groupBox的功能?
- 关于动态菜单
- C#中有没有 类似VB中 app.path 的东西利用??
是VALUES 还有中间要又空格