Sir, I am now in a ADO.NET Program
There are Two Forms in My Program
1) frmClass and frmDivision
I want your help in the functions of frmDivision.
here is frmClass:-
and here is the frmDivision
So these are my forms.
now My Task is :-
1) Save className and divisionName to frmDivision and tbl_Division by
btn_Save_Click event
please send me the code t
2) Update the dataGridView1 Data by cell_Double_Click event of dataGridView1 in
frmDivision
here are the task I done in this program:-
className has been passed to comboBox in the frmDivision
here is my database Stored procedure to save the data in frmDivision:-
ALTER PROCEDURE divisionAdd
@divisionName nvarchar(20),
@classId numeric(18,0)
AS
if not exists(select divisionName from tbl_Division where divisionName=@divisionName)
begin
insert into tbl_Division(divisionName,classId)
values(@divisionName,@classId)
end
RETURN
this stored procedure is been called in SpDivision.here the spDivsion function to save the data in frmDivision:-
public void divisionAdd(divisionInfo infodivision)
{
try
{
if (sqlCon.State == ConnectionState.Closed)
{
sqlCon.Open();
}
SqlCommand sqlCmd = new SqlCommand("divisionAdd", sqlCon);
sqlCmd.CommandType = CommandType.StoredProcedure;
sqlCmd.Parameters.Add("@divisionName", SqlDbType.NVarChar).Value = infodivision.divisionName;
sqlCmd.Parameters.Add("@classId", SqlDbType.Decimal).Value = infodivision.classId;
int incount = sqlCmd.ExecuteNonQuery();
if (incount > 0)
{
MessageBox.Show("Saved Successfully");
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
finally
{
sqlCon.Close();
}
}
This function is been called in frmDivision.cs.here is the code:-
private void btnSave_Click(object sender, EventArgs e)
{
divisionSp spdivision = new divisionSp();
divisionInfo info = new divisionInfo();
info.classId = decimal.Parse(cmbClassName.SelectedValue.ToString()); // here I geetinan error. see the error next to the function
info.divisionName = txtDivisionName.Text;
spdivision.divisionAdd(info);
divisionGridFill();
}
So I want your help in this error.
My tbl_Division columns are:- divisionId(pk),divisionName,classId(fk)
The code in infoDivision class is:-
class divisionInfo
{
public decimal divisionId
{
get;
set;
}
public string divisionName
{
get;
set;
}
public decimal classId
{
get;
set;
}
}
So Please help me in the following functions:-
1) save the className and divisionName to the frmDivision and to the tbl_Division
2) Update the datagridView1 data bt cellDoubleClick event

Kunal VaishyaPosted Jul 2, 2013, 12:51 AM
Bineesh ViswanathPosted Jul 2, 2013, 1:01 AM
please inspect these all and repair the forms ,database and class files and send back.
Bineesh ViswanathPosted Jul 2, 2013, 12:53 AM
Now please extract both files and you could get the error phase easily.
I successfully uploaded both my forms( uploaded in previous reply) and database(with this).
so work with these files and repair the error phase and send back
Bineesh ViswanathPosted Jul 2, 2013, 12:49 AM
Please go thru all forms.
My tasks are:-
1)Save
2)View
3)Delete
4)Update
if you could, repair my forms and send back
Bineesh ViswanathPosted Jul 1, 2013, 11:21 PM
It includes, all class files and database
Sanjeeb LenkaPosted Jul 1, 2013, 12:47 PM