that is classic SQL inject attack, either you have to filter the text or use a paramterized query string insertStr = "Insert into Gbook (Title,Username,Sex,Email,Oicq,Homepage,HeartPic,HeadPic,Content,Uptime) Values (?,?,?,?,?,?,?,?,?,?)";OleDbConnection conn = new OleDbConnection(conStr);
conn.Open();
OleDbCommand comm = new OleDbCommand(insertStr,conn);
comm.Paramters.Add("@Title",title.Text);
comm.Paramters.Add("@User",Username.Text);
comm.Paramters.Add("@Sex",Sex.SelectedItem.Text);
comm.Paramters.Add("@Email",mail.Text);
comm.Paramters.Add("@Oicq",OICQ.Text);
comm.Paramters.Add("@Homepage",homepage.Text );
comm.Paramters.Add("@HeartPic",Pic.SelectedItem.Value);
comm.Paramters.Add("@HeadPic",Head.SelectedItem.Value);
comm.Paramters.Add("@Content",content.Text);
comm.Paramters.Add("@Uptime",DateTime.Now.ToString());//comm.Paramters.Add("@Uptime",DateTime.Now); //>>comm.ExecuteNonQuery();
conn.Close();
Response.Redirect("Default.aspx");
conn.Open();
OleDbCommand comm = new OleDbCommand(insertStr,conn);
comm.Paramters.Add("@Title",title.Text);
comm.Paramters.Add("@User",Username.Text);
comm.Paramters.Add("@Sex",Sex.SelectedItem.Text);
comm.Paramters.Add("@Email",mail.Text);
comm.Paramters.Add("@Oicq",OICQ.Text);
comm.Paramters.Add("@Homepage",homepage.Text );
comm.Paramters.Add("@HeartPic",Pic.SelectedItem.Value);
comm.Paramters.Add("@HeadPic",Head.SelectedItem.Value);
comm.Paramters.Add("@Content",content.Text);
comm.Paramters.Add("@Uptime",DateTime.Now.ToString());//comm.Paramters.Add("@Uptime",DateTime.Now); //>>comm.ExecuteNonQuery();
conn.Close();
Response.Redirect("Default.aspx");
解决方案 »
- 求救求救,gridview+commandfeild,编辑的问题,请来看一下
- 求助 无法导入windows media player控件
- 紧急求助图片控件运行时不显示图片的问题
- 求助,动态改变DataList中的Panel的显示与隐藏!!!
- 如何动态增加DataGrid的模板列,并能在数据库表中增加该模板列字段,数据类型?
- 问一个最常用、最简单的正则表达式 非常急 谢谢
- C#中,自己写了一个类,但是无法运行,各位大侠帮帮忙吧。
- 在线结贴-自定义config文件的配置信息怎么读取?
- Treeview怪问题
- 安装部署中遇到的几个问题!
- 安装.net的菜鸟问题,帮忙```````急````
- 关于ASP.net的学习
string insertStr = "Insert into Gbook (Title,Username,Sex,Email,Oicq,Homepage,HeartPic,HeadPic,Content,Uptime) Values ('"
+ title.Text + "','"
+ Username.Text + "','"
+ Sex.SelectedItem.Text + "','"
+ mail.Text + "','"
+ OICQ.Text + "','"
+ homepage.Text + "','"
+ Pic.SelectedItem.Value + "','"
+ Head.SelectedItem.Value + "','"
+ content.Text.Replace("'","''") + "','"
+ DateTime.Now.ToString() + "')";
OleDbConnection conn = new OleDbConnection(conStr);
conn.Open();
OleDbCommand comm = new OleDbCommand(insertStr,conn);
comm.ExecuteNonQuery();
conn.Close();
Response.Redirect("Default.aspx");
}
问题解决了。谢谢