asp.net 向oracle中添加数据
publicstaticBooleanAddUserInfo(CustomerInfoBeancustmBean){//将对象custmBean中的值取出stringus...
public static Boolean AddUserInfo(CustomerInfoBean custmBean)
{
//将对象custmBean中的值取出
string username = custmBean.Username;
string password = custmBean.Password;
string custmName = custmBean.CustmName;
string custmSex = custmBean.CustmSex;
Int32 custmAge = custmBean.CustmAge;
string custmEmail = custmBean.CustmEmail;
Int64 custmTel = custmBean.CustmTel;
string custmAddr = custmBean.CustmAddr;
Int32 postalCode = custmBean.PostalCode;
OracleConnection con = DBConn.CreateOrclConn();
try
{
con.Open();
string addSql = "insert into TBCUSTOMERINFO values ('" + username + "','" + password + "','" + custmName + "','" + custmSex + "'," + custmAge + ","
+ " '" + custmEmail + "'," + custmTel + ",'" + custmAddr + "'," + postalCode + ")";
OracleCommand ocmd = new OracleCommand(addSql, con);
ocmd.ExecuteNonQuery();
return true;
}
catch (OracleException oex)
{
HttpContext.Current.Response.Write("<script>alert('" + oex.Message + "')</script>");
return false;
}
finally
{
if (con != null)
{
con.Close();
}
}
}
为什么到了ocmd.ExecuteNonQuery();这一步时就不执行了呢……求高手指点 展开
{
//将对象custmBean中的值取出
string username = custmBean.Username;
string password = custmBean.Password;
string custmName = custmBean.CustmName;
string custmSex = custmBean.CustmSex;
Int32 custmAge = custmBean.CustmAge;
string custmEmail = custmBean.CustmEmail;
Int64 custmTel = custmBean.CustmTel;
string custmAddr = custmBean.CustmAddr;
Int32 postalCode = custmBean.PostalCode;
OracleConnection con = DBConn.CreateOrclConn();
try
{
con.Open();
string addSql = "insert into TBCUSTOMERINFO values ('" + username + "','" + password + "','" + custmName + "','" + custmSex + "'," + custmAge + ","
+ " '" + custmEmail + "'," + custmTel + ",'" + custmAddr + "'," + postalCode + ")";
OracleCommand ocmd = new OracleCommand(addSql, con);
ocmd.ExecuteNonQuery();
return true;
}
catch (OracleException oex)
{
HttpContext.Current.Response.Write("<script>alert('" + oex.Message + "')</script>");
return false;
}
finally
{
if (con != null)
{
con.Close();
}
}
}
为什么到了ocmd.ExecuteNonQuery();这一步时就不执行了呢……求高手指点 展开
3个回答
展开全部
sql语句有小问题
insert into TBCUSTOMERINFO values ('" + username + "','" + password + "','" + custmName + "','" + custmSex + "'," + custmAge + "," + " '" + custmEmail + "'," + custmTel + ",'" + custmAddr + "'," + postalCode + ")";
在custmAge后面多了"+"
insert into TBCUSTOMERINFO values ('" + username + "','" + password + "','" + custmName + "','" + custmSex + "'," + custmAge + "," + " '" + custmEmail + "'," + custmTel + ",'" + custmAddr + "'," + postalCode + ")";
在custmAge后面多了"+"
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
可能是数据库访问或插入语句有问题,建议取得输出的SQL语句后,拷贝到ORACLE数据库工具(如PL/SQL)中去分析下语句有问题没。
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
SQL语句有问题吧,可能某一个字段类型不一致导致的.
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询