--商品信息表
create table product
(productID int identity (1,1) primary key ,--商品编号
productName nvarchar(200) ,--商品名称
author nvarchar(200) ,--作者;
isRecommend bit ,--是否被推荐
startPrice decimal(8,2),--原价
salePrice decimal (8,2),--销售价
img nvarchar(200) ,--商品图片文件名
description ntext,--商品的描述
storeID int ,--所属商城编号
typeID int references typies(typeID),--所属类型编号
hits int default(0) ,--浏览的次数
addTime datetime default getdate() --商品上架时间
)
----------------------------------------------------
help类
namespace Web_项目
{ public class Help
{
public static string strCo= "server=NGUABLSUMXZ012J;database=eshop;uid=sa;password=123"; public static SqlConnection conn;
//打开数据库
public static SqlConnection sqlOpen()
{
conn = new SqlConnection();
conn.Open();
return conn;
}
//返回数据操作
public static int exeSQL(string sql)
{
using (SqlConnection conn=new SqlConnection (strCon))
{ conn.Open();
using (SqlCommand cmd=new SqlCommand (sql,conn))
{
try
{
int i = cmd.ExecuteNonQuery();
return i;
}
catch (Exception ex)
{
throw ex;
}
}
}
}
}
}----------------------------------------------------
protected void Button1_Click(object sender, EventArgs e)
{
string imgName = "";
if (this.FileUpload1.HasFile)
{
imgName = DateTime.Now.ToString("yyyMMddHHmmss") + FileUpload1.FileName;//记录文件;
string Path = Server.MapPath("~/p/" + imgName);//上传文件
this.FileUpload1.SaveAs(Path);
this.Image1.ImageUrl = "~/p/" + imgName; //显示图片
string sql = "insert into product values (" + TextBox1.Text + "," + TextBox2.Text + "," + CheckBox1.Checked + ",'" + TextBox3.Text + "','" + TextBox5.Text + "',"+imgName+ "," + TextBox6.Text + ",'" + DropDownList1.SelectedValue +"','" + DropDownList2.SelectedValue + "'," +"default"+" ,"+"default"+")";
//在调试中imgName附近有错误,不知道是什么原因,是不是类型的不同,还是其他的原因,求指教
int i = Help.exeSQL(sql);
if (i>0)
{
this.ClientScript.RegisterStartupScript(this.GetType(), "", "alert('新的商品添加成功')", true);
}
}
}SQLString
create table product
(productID int identity (1,1) primary key ,--商品编号
productName nvarchar(200) ,--商品名称
author nvarchar(200) ,--作者;
isRecommend bit ,--是否被推荐
startPrice decimal(8,2),--原价
salePrice decimal (8,2),--销售价
img nvarchar(200) ,--商品图片文件名
description ntext,--商品的描述
storeID int ,--所属商城编号
typeID int references typies(typeID),--所属类型编号
hits int default(0) ,--浏览的次数
addTime datetime default getdate() --商品上架时间
)
----------------------------------------------------
help类
namespace Web_项目
{ public class Help
{
public static string strCo= "server=NGUABLSUMXZ012J;database=eshop;uid=sa;password=123"; public static SqlConnection conn;
//打开数据库
public static SqlConnection sqlOpen()
{
conn = new SqlConnection();
conn.Open();
return conn;
}
//返回数据操作
public static int exeSQL(string sql)
{
using (SqlConnection conn=new SqlConnection (strCon))
{ conn.Open();
using (SqlCommand cmd=new SqlCommand (sql,conn))
{
try
{
int i = cmd.ExecuteNonQuery();
return i;
}
catch (Exception ex)
{
throw ex;
}
}
}
}
}
}----------------------------------------------------
protected void Button1_Click(object sender, EventArgs e)
{
string imgName = "";
if (this.FileUpload1.HasFile)
{
imgName = DateTime.Now.ToString("yyyMMddHHmmss") + FileUpload1.FileName;//记录文件;
string Path = Server.MapPath("~/p/" + imgName);//上传文件
this.FileUpload1.SaveAs(Path);
this.Image1.ImageUrl = "~/p/" + imgName; //显示图片
string sql = "insert into product values (" + TextBox1.Text + "," + TextBox2.Text + "," + CheckBox1.Checked + ",'" + TextBox3.Text + "','" + TextBox5.Text + "',"+imgName+ "," + TextBox6.Text + ",'" + DropDownList1.SelectedValue +"','" + DropDownList2.SelectedValue + "'," +"default"+" ,"+"default"+")";
//在调试中imgName附近有错误,不知道是什么原因,是不是类型的不同,还是其他的原因,求指教
int i = Help.exeSQL(sql);
if (i>0)
{
this.ClientScript.RegisterStartupScript(this.GetType(), "", "alert('新的商品添加成功')", true);
}
}
}SQLString
解决方案 »
- 菜鸟求助一个很简单的问题,麻烦说详细一点,谢谢!!!
- 请问c#了如何解析json的键值对
- 模拟器(PPC2003)中获取当前时间的问题
- 关于在window.open()的情况下用div.style.display的奇怪问题!
- duwamish的一个问题,大家共参
- 高手请进:请教asp.net2.0用Directory.GetFiles取文件列表,如何按时间排序,如果过滤多个扩展名?
- 【散分!!!!!!】
- 切换Form 10几次后出现stackoverflowerror异常~~急求解决办法
- 请哪位大哥,有93条码打印字体呀? help me ......!
- VS2010调用类库,不识别
- VS2008添加不上数据源
- C# 复制文件到window系统目录出错 学生狗求指导....
2、如果只是文件名为嘛不直接用nvarchar
3、在sql这里下个断点,将断到内容(你是SQL语句)拿到查询分析器里执行,看看是否报相同异常