Add a new (inventory sys. with C#)
public string AddScholReq(string FName,string address,string campus,string subject,string telephone,string morbidity,string PDeath,string Years,string Bcertificate,string reqLetter,string regLetter,string UniLetter,string dates,string ImagePath)
{
ConnectDB dbcon = new ConnectDB();
OdbcConnection ConnectDBToAddScholReq = dbcon.createDBCon();
string subTblID = "";
int MyID = 0;
using (OdbcCommand GetScholReqMaxIDCommand = new OdbcCommand("SELECT max(counts) FROM ScholRequest", sqlCon()))
{
using (OdbcDataReader GetScholReqMaxReader = GetScholReqMaxIDCommand.ExecuteReader())
{
while (GetScholReqMaxReader.Read())
{
MyID = GetScholReqMaxReader.GetInt32(0);
}
}
}
//int tempScholReqID = int.Parse(subTblID.Substring(1));
subTblID = "D" + (++MyID);
try
{
//string datestemp = "2011/07/23";
string addToReg= "INSERT INTO ScholRequest VALUES('" + subTblID + "','" + FName + "','" + address + "','" + campus + "','" + subject + "','" + telephone + "','" + morbidity + "','"+PDeath+"','"+Years+"','"+Bcertificate+"','"+reqLetter+"','"+regLetter+"','"+UniLetter+"','"+dates+"','"+ImagePath+"')";
OdbcCommand addToScholReqCom = new OdbcCommand(addToReg, sqlCon());
addToScholReqCom.ExecuteNonQuery();
return subTblID;
}
catch (Exception AddScholsReq)
{ return "Error !!! try again "; }
}
Comments
Post a Comment