how to add class in asp.net code
-
hi all, i am creating a page in asp.net using c#.To insert the data,i just wrote the sql command for inserting and followed the same for edit and update. for example..
string myinsertQuery = "insert into DriveUnits(SerialNumber,CorporationID,CorporationDivisionID,HWVersion,DateManufactured) values('" + SrNumber_TBox.Text + "','" + Session["corporationid"] + "','" + CorporationDivisionID + "','" + Hwversion_Tbox.Text + "','" + DateMFD_TBox.Text + "')"; SqlCommand myCommand_insert = new SqlCommand(myinsertQuery); myCommand_insert.Connection = myConnection; myCommand_insert.ExecuteNonQuery(); myCommand_insert.Connection.Close();
but instead of writing code in cs file,i just want to call a class so that wherever we need to insert data,we can just call the class and the functions defined. i created a class and a function and pass parameters.but it is showin invalid arguments.. plz give ur suggestions on creating a class and its functions. Thanks in advance,cheers sangeet
-
hi all, i am creating a page in asp.net using c#.To insert the data,i just wrote the sql command for inserting and followed the same for edit and update. for example..
string myinsertQuery = "insert into DriveUnits(SerialNumber,CorporationID,CorporationDivisionID,HWVersion,DateManufactured) values('" + SrNumber_TBox.Text + "','" + Session["corporationid"] + "','" + CorporationDivisionID + "','" + Hwversion_Tbox.Text + "','" + DateMFD_TBox.Text + "')"; SqlCommand myCommand_insert = new SqlCommand(myinsertQuery); myCommand_insert.Connection = myConnection; myCommand_insert.ExecuteNonQuery(); myCommand_insert.Connection.Close();
but instead of writing code in cs file,i just want to call a class so that wherever we need to insert data,we can just call the class and the functions defined. i created a class and a function and pass parameters.but it is showin invalid arguments.. plz give ur suggestions on creating a class and its functions. Thanks in advance,cheers sangeet
not sure i got you.. maybe this is what you want.. Using static method.
public class MyDBMgmt{
public static bool ExecuteSQL(string cmdText)
{
return true;
}
}Thanks and Regards, Michael Sync ( Blog: http://michaelsync.net) If you want to thank me for my help, please vote my message by clicking one of numbers beside "Rate this message". Why vote? Plz Read here. Thank you. :)
-
hi all, i am creating a page in asp.net using c#.To insert the data,i just wrote the sql command for inserting and followed the same for edit and update. for example..
string myinsertQuery = "insert into DriveUnits(SerialNumber,CorporationID,CorporationDivisionID,HWVersion,DateManufactured) values('" + SrNumber_TBox.Text + "','" + Session["corporationid"] + "','" + CorporationDivisionID + "','" + Hwversion_Tbox.Text + "','" + DateMFD_TBox.Text + "')"; SqlCommand myCommand_insert = new SqlCommand(myinsertQuery); myCommand_insert.Connection = myConnection; myCommand_insert.ExecuteNonQuery(); myCommand_insert.Connection.Close();
but instead of writing code in cs file,i just want to call a class so that wherever we need to insert data,we can just call the class and the functions defined. i created a class and a function and pass parameters.but it is showin invalid arguments.. plz give ur suggestions on creating a class and its functions. Thanks in advance,cheers sangeet
Is this ASP.NET 1.0, 1.1, or 2.0 ? What errors are you getting ? You should certainly put all your SQL in a class, so that it's in a seperate layer to the rest of your app, and can be reused as needed.
Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )