mysql 数据库 asp.net/C#
//方法代码usingSystem;usingSystem.Web;usingSystem.Text;usingSystem.IO;usingSystem.Data;us...
//方法代码
using System;
using System.Web;
using System.Text;
using System.IO;
using System.Data;
using System.Data.SqlClient;
using gcom.Utility;
using gcom.Utility.SqlClient;
using MySql.Data.MySqlClient;
using gcom.Business.DataModel;
public static AddResult Add(DataModel.manage_user Item)
{
StringBuilder strSQL = new StringBuilder();
strSQL.Append("INSERT INTO manage_user (xuli,UserName,Purview,PassWord) VALUES (@xuli,@UserName,@Purview,@PassWord)");
DBParaCommon[] para ={
new DBParaCommon("@xuli", Item.xuli),
new DBParaCommon("@UserName", Item.UserName),
new DBParaCommon("@Purview", Item.Purview),
new DBParaCommon("@PassWord", Item.PassWord)};
int nRows = sqlProvider.ExecuteNonQuery(strSQL.ToString(), para);
AddResult ret = (nRows == 1 ? AddResult.Success : AddResult.Failed);
return ret;
}
--------------------------------
//c#代码
manage_user mu = new manage_user();
mu.Purview = int.Parse(Label2.Text.ToString());
mu.PassWord = Label3.Text.ToString();
mu.UserName = Label4.Text.ToString();
mu.xuli = Label1.Text.ToString();
if(manage_userFactory.Add(mu) == AddResult.Success)
{
Label1.Text ="chenggong"; //运行结果这个确实显示
}
我打断点 return 结果都是1....但是数据库里结果是添加改行所有的项都是null..天地良心...有些还是int型的. datamodel里还设置了初始值.
一切都顺利的进行..就是结果很让人沮丧 展开
using System;
using System.Web;
using System.Text;
using System.IO;
using System.Data;
using System.Data.SqlClient;
using gcom.Utility;
using gcom.Utility.SqlClient;
using MySql.Data.MySqlClient;
using gcom.Business.DataModel;
public static AddResult Add(DataModel.manage_user Item)
{
StringBuilder strSQL = new StringBuilder();
strSQL.Append("INSERT INTO manage_user (xuli,UserName,Purview,PassWord) VALUES (@xuli,@UserName,@Purview,@PassWord)");
DBParaCommon[] para ={
new DBParaCommon("@xuli", Item.xuli),
new DBParaCommon("@UserName", Item.UserName),
new DBParaCommon("@Purview", Item.Purview),
new DBParaCommon("@PassWord", Item.PassWord)};
int nRows = sqlProvider.ExecuteNonQuery(strSQL.ToString(), para);
AddResult ret = (nRows == 1 ? AddResult.Success : AddResult.Failed);
return ret;
}
--------------------------------
//c#代码
manage_user mu = new manage_user();
mu.Purview = int.Parse(Label2.Text.ToString());
mu.PassWord = Label3.Text.ToString();
mu.UserName = Label4.Text.ToString();
mu.xuli = Label1.Text.ToString();
if(manage_userFactory.Add(mu) == AddResult.Success)
{
Label1.Text ="chenggong"; //运行结果这个确实显示
}
我打断点 return 结果都是1....但是数据库里结果是添加改行所有的项都是null..天地良心...有些还是int型的. datamodel里还设置了初始值.
一切都顺利的进行..就是结果很让人沮丧 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询