こんにちは私はデータベースにデータを挿入しようとしました。クラスファイルを利用します。私には2つのクラスがあり、そのうちの1つはMaterial.csとDataAccessLayer.csです。しかし、私のコードを実行すると、プロシージャや関数sp_insert_componetに指定された引数が多すぎるなどのエラーが発生しました。 ""
//Material.csから
private string strCREATEDBY;
private string strCREATEDDATE;
private string strUPDATEDBY;
private string strUPDATEDDATE;
private string strSTATUS;
public string Createdby
{
get
{
return strCREATEDBY;
}
set
{
strCREATEDBY = value;
}
}
public string Createddate
{
get
{
return strCREATEDDATE;
}
set
{
strCREATEDDATE = value;
}
}
public string Updateddate
{
get
{
return strUPDATEDDATE;
}
set
{
strUPDATEDDATE = value;
}
}
public string Updatedby
{
get
{
return strUPDATEDBY;
}
set
{
strUPDATEDBY = value;
}
}
public string Status
{
get
{
return strSTATUS;
}
set
{
strSTATUS = value;
}
}
//Maingroup
//created by : ramya
//created date:15.2.2012
private string strIDENTIFY;
private string strNO;
private string strNAME;
private string strMAINIDENTIFICATION;
public string Identification
{
get
{
return strIDENTIFY;
}
set
{
strIDENTIFY = value;
}
}
public string NO
{
get
{
return strNO;
}
set
{
strNO = value;
}
}
public string NAME
{
get
{
return strNAME;
}
set
{
strNAME = value;
}
}
public string Mainidentify
{
get
{
return strMAINIDENTIFICATION;
}
set
{
strMAINIDENTIFICATION = value;
}
}
private string strItemtype;
public string Itemtype
{
get
{
return strItemtype;
}
set
{
strItemtype = value;
}
}
private string strSitename;
public string Sitename
{
get
{
return strSitename;
}
set
{
strSitename = value;
}
}
public int Savecomponent()
{
objDL.Addparam("@Createdby", Createdby);
objDL.Addparam("@Createddate", Createddate);
objDL.Addparam("@Sitecode", NO);
objDL.Addparam("@Itemtype", Itemtype);
objDL.Addparam("@Status", Status);
objDL.Addparam("@Maingroupsno", Mainidentify);
objDL.Addparam("@Subgroupsno", Identification);
objDL.Addparam("@Componetcode",NAME);
objDL.Addparam("@Sitename", Sitename);
int save = objDL.insert("sp_insert_componet");
if (save > 0)
{
return 1;
}
else
{
return 0;
}
}
//DataAccessLayer.csから
public int insert(string strInsert)
{
try
{
Con.Open();
cmd.Connection = Con;
cmd.CommandType = CommandType.StoredProcedure;
cmd.CommandText = strInsert;
int RetInsert = cmd.ExecuteNonQuery();
return RetInsert;
}
catch (Exception ex)
{
throw ex;
}
//got error in this finally block
finally
{
Con.Close();
}
}