Hi guys,
1. In my application,to Connect to DB, i used to write direct string queries in any function, assigning them appropriate variables using '+' sign. Then I had separate Data Access class to which I used to pass this query where it used to get executed.Code was like this:
Now, I have changed my way, I have written a stored procedure with parameters. I call a function of Data Access class which calls this stored procedure. I pass parameters to function which are assigned to strored procedure parameters.
Both approches work, but i want to know which one is good & faster.
2. Second Thing I want to know is, In one of my classes, I m making object of ClsDatabase in static method. I think its gonna use same objects again & again, creating problems for concurrency.Plz , clarify.
Thanks in advance.
1. In my application,to Connect to DB, i used to write direct string queries in any function, assigning them appropriate variables using '+' sign. Then I had separate Data Access class to which I used to pass this query where it used to get executed.Code was like this:
Code:
void someFunction() { clsDatabase objDB = new clsDatabase(); strSQL = "INSERT INTO QUERY"+param1; objDB.ProcessQuery(strSQL); }
Code:
void someFunction() { clsDatabase objDB = new clsDatabase(); objDB.functionWhichCallsStoredParameters(param1); }
2. Second Thing I want to know is, In one of my classes, I m making object of ClsDatabase in static method. I think its gonna use same objects again & again, creating problems for concurrency.Plz , clarify.
Code:
static void someFunction() { clsDatabase objDB = new clsDatabase(); objDB.functionWhichCallsStoredParameters(param1); }
Thanks in advance.
Comment