sos-数据库的问题(给分)

cwj007 2002-08-12 03:16:01
//为什么插入不进去,应该没有问题的???????
[WebMethod]
public int InsertCustomer(string customerName,string customerAdd,string mailID,int classID,string xuqiou,string fadinren,string weituoren,string telephone,string chuanzhen,string bank,string zhanghao,string suihao,string addressID )
{
int retNum=0;
string insertText ="(" +customerName+","+customerAdd+","+mailID+","+classID+","+xuqiou+","+fadinren+","+weituoren+","+telephone+","+chuanzhen+","+bank+","+zhanghao+","+suihao+","+addressID+")";
string sqlInsertCustomer ="INSERT INTO 客户表 (客户名称,地址,邮编,工号,需求,法定人,委托人,电话,传真,银行,帐号,税号,地区ID) VALUES"+insertText;
try
{
dataSet11.AcceptChanges();
sqlConnection2.Open();
//插入客户语句
//sqlInsertCommand2 = new SqlCommand(sqlInsertCustomer,sqlConnection2);
//retNum =sqlInsertCommand2.ExecuteNonQuery();
sqlDataAdapter2.InsertCommand.CommandText=sqlInsertCustomer;
sqlInsertCommand2.ExecuteNonQuery();

//return retNum;
dataSet11.Clear();
}
catch
{

}
finally
{
sqlConnection2.Close();
}
return retNum;

}
...全文
59 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
cnuninet 2002-08-14
  • 打赏
  • 举报
回复
你为什么不设置一个断点来跟踪你的sql语句,然后把这条语句提取出来在数据库里直接试试呢?
cad100 2002-08-14
  • 打赏
  • 举报
回复
看看你的字段有没有问题
cwj007 2002-08-14
  • 打赏
  • 举报
回复
up
cwj007 2002-08-12
  • 打赏
  • 举报
回复
没有用,你们有办法在 web中显示数据库异常. windowsform我知道,可web下传出异常我不清楚,先谢了,我会给分的,请大家帮忙
bigrongshu 2002-08-12
  • 打赏
  • 举报
回复
sql语句中VALUES 后面加一个空格
cwj007 2002-08-12
  • 打赏
  • 举报
回复
//改了,还是没有用
[WebMethod]
public int InsertCustomer(string customerName,string customerAdd,string mailID,int classID,string xuqiou,string fadinren,string weituoren,string telephone,string chuanzhen,string bank,string zhanghao,string suihao,string addressID )
{
int retNum=0;
//string insertText ="(" +customerName+","+customerAdd+","+mailID+","+classID+","+xuqiou+","+fadinren+","+weituoren+","+telephone+","+chuanzhen+","+bank+","+zhanghao+","+suihao+","+addressID+")";
string insertText ="('" +customerName+"','"+customerAdd+"','"+mailID+"','"+classID+"','"+xuqiou+"','"+fadinren+"','"+weituoren+"','"+telephone+"','"+chuanzhen+"','"+bank+"','"+zhanghao+"','"+suihao+"','"+addressID+"')";

string sqlInsertCustomer ="INSERT INTO 客户表 (客户名称,地址,邮编,工号,需求,法定人,委托人,电话,传真,银行,帐号,税号,地区ID) VALUES"+insertText;
try
{
dataSet11.AcceptChanges();
sqlConnection2.Open();
//插入客户语句
//sqlInsertCommand2 = new SqlCommand(sqlInsertCustomer,sqlConnection2);
//retNum =sqlInsertCommand2.ExecuteNonQuery();
sqlDataAdapter2.InsertCommand.CommandText=sqlInsertCustomer;
sqlInsertCommand2.ExecuteNonQuery();

//return retNum;
dataSet11.Clear();
}
catch
{

}
finally
{
sqlConnection2.Close();
}
return retNum;

}
cwj007 2002-08-12
  • 打赏
  • 举报
回复
我改了,可是还是没有办法
hbxtx 2002-08-12
  • 打赏
  • 举报
回复
你的语句有问题,cnuninet说的是对的。
cwj007 2002-08-12
  • 打赏
  • 举报
回复
你有没有那样用过????
cnuninet 2002-08-12
  • 打赏
  • 举报
回复
试试看:
string insertText ="('" +customerName+"','"+customerAdd+"','"+mailID+"','"+classID+"','"+xuqiou+"','"+fadinren+"','"+weituoren+"','"+telephone+"','"+chuanzhen+"','"+bank+"','"+zhanghao+"','"+suihao+"','"+addressID+"')";

110,502

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧