请问一个数据库传参数的问题 float PriceList;SqlParameter parameterPrice = new SqlParameter("@Price", SqlDbType.Money, 8);parameterPrice.Value = PriceList;(我想让PriceList传到参数中咋办)myCommand.Parameters.Add(parameterPrice); 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 public static SqlParameter MakeParam(string ParamName, SqlDbType DbType, Int32 Size, ParameterDirection Direction, object Value) { SqlParameter param; if (Size > 0) param = new SqlParameter(ParamName, DbType, Size); else param = new SqlParameter(ParamName, DbType); param.Direction = Direction; if (!(Direction == ParameterDirection.Output && Value == null)) param.Value = Value; return param; } SqlParameter mypara1 = new SqlParameter(); SqlParameter mypara2 = new SqlParameter(); SqlParameter mypara3 = new SqlParameter(); mypara1.ParameterName = "@au_lname"; mypara1.Direction = ParameterDirection.Input; mypara1.SqlDbType = SqlDbType.NVarChar; mypara1.Value = "White"; mypara2.ParameterName = "@intID"; mypara2.Direction = ParameterDirection.Input ; mypara2.SqlDbType = SqlDbType.Int; mypara2.Value = i; mypara3.ParameterName = "@intIDOut"; mypara3.Direction = ParameterDirection.Output; mypara3.SqlDbType = SqlDbType.Int; mypara3.Value = j ; mySqlDataAdapter.SelectCommand.Parameters.Add(mypara1); mySqlDataAdapter.SelectCommand.Parameters.Add(mypara2); mySqlDataAdapter.SelectCommand.Parameters.Add(mypara3); //mySqlDataAdapter.SelectCommand.Parameters.Add("@intIDOut", j);//ParameterDirection.Output myDataSet = new DataSet(); //str = ParameterDirection.Output.ToString(); mySqlConnection.Open(); mySqlDataAdapter.Fill(myDataSet, "authors"); mySqlConnection.Close(); 这样不行吗?不行的话你就这样写SqlParameter parameterPrice = new SqlParameter("@Price", SqlDbType.Money, 8);parameterPrice。Direction=ParameterDirection.Input;myCommand.Parameters.Add(parameterPrice);parameterPrice.Value = PriceList;(我想让PriceList传到参数中咋办) 那你合不用这种呢dbCommand.Parameters[":ID"].Value = obj.ID;if(Doc.PayTime == new DateTime(1,1,1))dbCommand.Parameters[":PAYTIME"].Value = DBNull.Value;elsedbCommand.Parameters[":PAYTIME"].Value = obj.PayTime;obj.PayTime这里你你就可以给PriceList不知道你是不是这个意思! C# 尝试读取或写入受保护的内存 MDI窗体哪个控件效率高 关于DataList分页的问题,拜托帮我看看!! 判断是否链接上Mssql数据库的方法错在哪里? DropDownList自动将每条记录显示两次 topmost窗体与messagebox冲突的问题 【版务帖】2009年2月C#版务帖 动态增加控件以后,如何判断增加事件. 这样的语句怎么写?身无分文的我都快哭了.吐血求救. 急!!!uniqueidentifier类型字段的问题!大家进来看看!!可以加分的哦! 请问,什么时候应该使用结构而不是类? 关于一个自定义控件的问题,大家帮我看看!
{
SqlParameter param; if (Size > 0)
param = new SqlParameter(ParamName, DbType, Size);
else
param = new SqlParameter(ParamName, DbType); param.Direction = Direction;
if (!(Direction == ParameterDirection.Output && Value == null))
param.Value = Value; return param;
}
SqlParameter mypara2 = new SqlParameter();
SqlParameter mypara3 = new SqlParameter(); mypara1.ParameterName = "@au_lname";
mypara1.Direction = ParameterDirection.Input;
mypara1.SqlDbType = SqlDbType.NVarChar;
mypara1.Value = "White";
mypara2.ParameterName = "@intID";
mypara2.Direction = ParameterDirection.Input ;
mypara2.SqlDbType = SqlDbType.Int;
mypara2.Value = i;
mypara3.ParameterName = "@intIDOut";
mypara3.Direction = ParameterDirection.Output;
mypara3.SqlDbType = SqlDbType.Int;
mypara3.Value = j ;
mySqlDataAdapter.SelectCommand.Parameters.Add(mypara1);
mySqlDataAdapter.SelectCommand.Parameters.Add(mypara2);
mySqlDataAdapter.SelectCommand.Parameters.Add(mypara3); //mySqlDataAdapter.SelectCommand.Parameters.Add("@intIDOut", j);//ParameterDirection.Output
myDataSet = new DataSet();
//str = ParameterDirection.Output.ToString();
mySqlConnection.Open();
mySqlDataAdapter.Fill(myDataSet, "authors");
mySqlConnection.Close();
SqlParameter parameterPrice = new SqlParameter("@Price", SqlDbType.Money, 8);
parameterPrice。Direction=ParameterDirection.Input;
myCommand.Parameters.Add(parameterPrice);
parameterPrice.Value = PriceList;(我想让PriceList传到参数中咋办)
dbCommand.Parameters[":ID"].Value = obj.ID;
if(Doc.PayTime == new DateTime(1,1,1))
dbCommand.Parameters[":PAYTIME"].Value = DBNull.Value;
else
dbCommand.Parameters[":PAYTIME"].Value = obj.PayTime;
obj.PayTime这里你你就可以给PriceList
不知道你是不是这个意思!