C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Reviews   Communities   Interview   Jobs   Projects   Training   Your Ad Here    
Silverlight Games | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Polls | Revenue Sharing | Lobby | Gift Shop |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...






View Message



Sender diyaa

Recipient(s) Syed Shakeer Hussain

Date 02 Oct 2009


sallam




i m working in layered architecture in C# 2008 connection ms-access 2003 with (oledb) with two tables n i want to insert , update , n delete from two tables in one form which is in c#2008 bt it gives me error in this code
at form;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using buisnesslayer;
using System.Windows.Forms;

namespace tahira
{
public partial class Form1 : Form
{
buiss objbuiss = new buiss();
public Form1()
{
InitializeComponent();
}

private void btn1_Click(object sender, EventArgs e)
{
objbuiss.getstud_record(regtxt.Text);
if(objbuiss.dset.Tables["table"].Rows.Count!=0)
dataGrid.DataSource=objbuiss.dset.Tables["table"];

dataGrid.Visible=true;

}

private void btn6_Click(object sender, EventArgs e)
{
this.Close();
}

private void btn5_Click(object sender, EventArgs e)
{
regtxt.Clear();
}

private void btn4_Click(object sender, EventArgs e)
{
objbuiss.getdelete_record(regtxt.Text);
//if (objbuiss.dset.Tables["table"].Rows.Count != 0)
dataGrid.DataSource = objbuiss.dset.Tables["stuent_info"];
dataGrid.DataSource = objbuiss.dset.Tables["stuent_info2"];
dataGrid.Visible = true;
}

private void btn2_Click(object sender, EventArgs e)
{
//objbuiss.getinsert_record(strquery);
//objbuiss.getinsert_record(strquery1);


objbuiss.getinsert_record(regtxt.Text, txtname.Text, txtdis.Text, txtadd.Text);
objbuiss.getinsert_record(regtxt.Text, txtcourse.Text, txttotal.Text, txtobt.Text);
//if (objbuiss.dset.Tables["table"].Rows.Count != 0)
dataGrid.DataSource = objbuiss.dset.Tables["stuent_info"];
dataGrid.DataSource = objbuiss.dset.Tables["stuent_info2"];

dataGrid.Visible = true;

}

private void btn3_Click(object sender, EventArgs e)
{
objbuiss.getupdate_record(regtxt.Text);
// objbuiss.getupdate_record(regtxt.Text, txtcourse.Text, txttotal.Text, txtobt.Text);
dataGrid.DataSource = objbuiss.dset.Tables["stuent_info"];
dataGrid.DataSource = objbuiss.dset.Tables["stuent_info2"];

dataGrid.Visible = true;

}
}
}

AT BUISSNESS LAYER;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using dataaccesslayer;

namespace buisnesslayer
{
public class buiss
{
int Regno, Total_Marks, Marks_Obtained;
string Name, Discipline, Address,Course;
private DataSet _dset = new DataSet();
private access acc = new access();
public DataSet dset
{
get { return _dset; }
set { dset = value; }
}

public void getstud_record(string Regno)
{
//string strquery = "SELECT * FROM stuent_info WHERE Reg_no="+Regno+"";
//string strquery = "SELECT stuent_info.Reg_no,stuent_info2.* FROM stuent_info INNER JOIN stuent_info2 ON stuent_info.Reg_no=stuent_info2.Reg_no";
string strquery ="SELECT * FROM stuent_info INNER JOIN stuent_info2 ON stuent_info.Reg_no= stuent_info2.Reg_no WHERE stuent_info.Reg_no="+Regno+"";
if (_dset.Tables.Contains("table"))
_dset.Tables.Remove("table");
acc.selectquery(_dset, strquery, "table");

}

public void getinsert_record(string Regno,string Name, string Discipline, string Address, string Course, string Total_Marks, string Marks_Obtained)
{
string strquery = "insert into stuent_info values('" + Regno + "','" + Name + "','" + Discipline + "','" + Address + "'); //'" + Course + "','" + Total_Marks + "','" + Marks_Obtained + "')";

string strquery1= "insert into stuent_info2 values('"+Regno+"','"+Course+"','"+Total_Marks+"','"+Marks_Obtained+"')";




//string strquery = "SELECT s1.Reg_no,s2.Reg_no FROM stuent_info s1 INNER JOIN stuent_info2 s2 ON s1.Reg_no=s2.Reg_no";

//tuent_info.Name,stuent_info2.* FROM stuent_info,stuent_info2 INNER JOIN stuent_info2 ON stuent_info.Name=stuent_info2.Name";
//acc.selectquery(dset, strquery, "table");
if (_dset.Tables.Contains("table"))
_dset.Tables.Remove("table");
acc.executequery( strquery);
acc.executequery( strquery1);
}
public void getupdate_record(string Regno) //,string Name, string Discipline, string Address, string Course, string Total_Marks, string Marks_Obtained)
{
string strquery2 = "update stuent_info set stuent_info.Reg_no=stuent_info2.Reg_no from stuent_info join stuent_info2 on stuent_info2.Reg_no=stuent_info.Reg_no and stuent_info2.Course=stuent_info.Name where exists ( select * from stuent_info where stuent_info2.Reg_no=stuent_info.Reg_no and stuent_info2.Course=stuent_info1.Name)";
//string strquery3="Delete from student_info where reg_no = 'Enter Reg_No'And Delete from student_info2 where reg_no = 'Enter Reg_No'";



if (_dset.Tables.Contains("table"))
_dset.Tables.Remove("table");
acc.executequery(strquery2);}
public void getdelete_record(string Regno) //,string Name, string Discipline, string Address, string Course, string Total_Marks, string Marks_Obtained)
{
string strquery="DELETE a b FROM stuent_info a join stuent_info2 b on a.Reg_no=b.Reg_no and b.choice = 'NO'";

//string strquery3 = "delete from stuent_info,stuent_info2 where stuent_info.Reg_no=stuent_info2.Reg_no";
if (_dset.Tables.Contains("table"))
_dset.Tables.Remove("table");
acc.executequery(strquery3);
}
}
}



public int regproperty
{
get { return Regno; }
set { Regno = value; }
}
public string nameproperty
{
get { return Name; }
set { Name = value; }
}
public string disciplineproperty
{
get { return Discipline; }
set { Discipline= value; }
}
public string addproperty
{
get { return Address; }
set { Address = value; }
}
public string Courseproperty
{
get { return Course; }
set { Course = value; }
}
public int Total_Marksproperty
{
get { return Total_Marks; }
set { Total_Marks = value; }
}
public int Marks_Obtainedproperty
{
get { return Marks_Obtained; }
set { Marks_Obtained = value; }
}






}
AT ACCESS Layer;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.OleDb;


namespace dataaccesslayer
{
public class access
{
private OleDbConnection conn = new OleDbConnection();
private OleDbCommand cmd = new OleDbCommand();
private OleDbDataAdapter dbadapter = new OleDbDataAdapter();
//private OleDbTransaction Trans;
private static string strconstring;
public static void connstring(string strconn)
{
try { strconstring = strconn; }
catch (Exception ex)
{ throw ex; }
}
private void createconn()
{
try
{
conn.ConnectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Documents and Settings\tahiramalik\Desktop\student.mdb;Persist Security Info=False";
conn.Open();
}
catch (Exception ex)
{ throw ex; }
}
public void closeconn()
{
try
{
if(conn.State!=0)
conn.Close();
}

catch(Exception ex)
{
throw ex;
}
}

public void selectquery(DataSet _dset, string query, string tblname)
{
try
{
if (conn.State == 0)
{ createconn(); }
cmd.CommandTimeout = 500;
cmd.Connection = conn;
cmd.CommandType = CommandType.Text;
cmd.CommandText = query;
dbadapter = new OleDbDataAdapter(cmd);
dbadapter.Fill(_dset, tblname);
}
catch (Exception ex)
{ throw ex; }
}
public void executequery( string query){
try
{
if (conn.State==0)
{
createconn();
}
cmd.Connection = conn;
cmd.CommandType = CommandType.Text;
cmd.CommandText = query;
cmd.ExecuteNonQuery();

}
catch (Exception ex)
{throw ex;}

}



}
}




errors are
Error 9 'buisnesslayer.buiss' does not contain a definition for 'getdelete_record' and no extension method 'getdelete_record' accepting a first argument of type 'buisnesslayer.buiss' could be found (are you missing a using directive or an assembly reference?) C:\Documents and Settings\tahiramalik\My Documents\Visual Studio 2008\Projects\tahira\tahira\Form1.cs 43 22 tahira
Error 1 Expected class, delegate, enum, interface, or struct C:\Documents and Settings\tahiramalik\My Documents\Visual Studio 2008\Projects\tahira\buisnesslayer\buiss.cs 76 16 buisnesslayer
Error 2 Expected class, delegate, enum, interface, or struct C:\Documents and Settings\tahiramalik\My Documents\Visual Studio 2008\Projects\tahira\buisnesslayer\buiss.cs 81 16 buisnesslayer
Error 3 Expected class, delegate, enum, interface, or struct C:\Documents and Settings\tahiramalik\My Documents\Visual Studio 2008\Projects\tahira\buisnesslayer\buiss.cs 86 16 buisnesslayer
Error 4 Expected class, delegate, enum, interface, or struct C:\Documents and Settings\tahiramalik\My Documents\Visual Studio 2008\Projects\tahira\buisnesslayer\buiss.cs 91 16 buisnesslayer
Error 5 Expected class, delegate, enum, interface, or struct C:\Documents and Settings\tahiramalik\My Documents\Visual Studio 2008\Projects\tahira\buisnesslayer\buiss.cs 96 16 buisnesslayer
Error 6 Expected class, delegate, enum, interface, or struct C:\Documents and Settings\tahiramalik\My Documents\Visual Studio 2008\Projects\tahira\buisnesslayer\buiss.cs 101 16 buisnesslayer
Error 7 Expected class, delegate, enum, interface, or struct C:\Documents and Settings\tahiramalik\My Documents\Visual Studio 2008\Projects\tahira\buisnesslayer\buiss.cs 106 16 buisnesslayer
Error 10 No overload for method 'getinsert_record' takes '4' arguments C:\Documents and Settings\tahiramalik\My Documents\Visual Studio 2008\Projects\tahira\tahira\Form1.cs 56 13 tahira
Error 11 No overload for method 'getinsert_record' takes '4' arguments C:\Documents and Settings\tahiramalik\My Documents\Visual Studio 2008\Projects\tahira\tahira\Form1.cs 57 13 tahira
Error 12 No overload for method 'getupdate_record' takes '1' arguments C:\Documents and Settings\tahiramalik\My Documents\Visual Studio 2008\Projects\tahira\tahira\Form1.cs 68 14 tahira
Error 8 Type or namespace definition, or end-of-file expected C:\Documents and Settings\tahiramalik\My Documents\Visual Studio 2008\Projects\tahira\buisnesslayer\buiss.cs 117 5 buisnesslayer




plz help me n also tall me where i chng the code or provide me correct code










dotNet Slackers

About Us    Contact Us    Privacy Policy    Terms Of Use