Click here to Skip to main content
15,906,816 members
Home / Discussions / C#
   

C#

 
QuestionDLL or Component for RFID KITS Pin
Tyler4526-Oct-05 1:57
Tyler4526-Oct-05 1:57 
AnswerRe: DLL or Component for RFID KITS Pin
Dave Kreskowiak26-Oct-05 3:27
mveDave Kreskowiak26-Oct-05 3:27 
GeneralRe: DLL or Component for RFID KITS Pin
Tyler4510-Nov-05 13:46
Tyler4510-Nov-05 13:46 
QuestionThrad problem Pin
hg270526-Oct-05 1:04
hg270526-Oct-05 1:04 
AnswerRe: Thrad problem Pin
S. Senthil Kumar26-Oct-05 5:27
S. Senthil Kumar26-Oct-05 5:27 
GeneralRe: Thrad problem Pin
hg270527-Oct-05 20:13
hg270527-Oct-05 20:13 
GeneralRe: Thrad problem Pin
S. Senthil Kumar27-Oct-05 21:11
S. Senthil Kumar27-Oct-05 21:11 
QuestionSlow Query on 2nd query of the same command Pin
AesopTurtle26-Oct-05 0:06
AesopTurtle26-Oct-05 0:06 
I've created a class containing a method to make a connection with a database and do SELECT, INSERT, UPDATE, DELETE. The class works just fine... only for the first query. The problem occurs when the second query is made. The result of the second query is just fine but at VERY VERY slow rate (almost not responding). Here's my class:

class MyClass
{
public string SQL2KConnStr = "..(my connection string)..";
public object ExecuteSql(string sql)
 {
   SqlConnection conn = new SqlConnection(this.SQLExpressConnStr);
   if (conn.State == ConnectionState.Open)
   {
      conn.Close();
   }
   conn.Open();
   switch(sql.Trim().Substring(0,6).ToLower()){
   case "select":
      SqlDataAdapter adapter = new SqlDataAdapter(sql, conn);
      DataSet ds = new DataSet();
      adapter.Fill(ds, "QueriedTab");
      return ds.Tables["QueriedTab"]; //Return a data table.
      break;
   default:
      SqlCommand cmd = new SqlCommand();
      //cmd.CommandType = CommandType.Text;
      cmd.Connection = conn;
      cmd.CommandText = sql;
      return cmd.ExecuteNonQuery(); //Return a number of affected rows.
 }
}


And this's another class that makes use of the class above:

string SqlSelect = "select * from ...";
MyClass mc = new MyClass();
DataTable tab = (DataTable)mc.ExecuteSql(SqlSelect);
myDataGrid.DataSource = tab;
tab.Dispose();


I display the resultin a datagrid. The correctness of the result is fine. But the speed of the second and after is SO SO slow even though i've disposed the returned table every time. Anybody help me please...

KiT
AnswerRe: Slow Query on 2nd query of the same command Pin
leppie26-Oct-05 4:12
leppie26-Oct-05 4:12 
AnswerRe: Slow Query on 2nd query of the same command Pin
Rob Graham26-Oct-05 6:20
Rob Graham26-Oct-05 6:20 
GeneralRe: Slow Query on 2nd query of the same command Pin
AesopTurtle26-Oct-05 15:18
AesopTurtle26-Oct-05 15:18 
QuestionPlease help - How to un-install a Windows Service? Pin
Tigger9925-Oct-05 23:53
Tigger9925-Oct-05 23:53 
AnswerRe: Please help - How to un-install a Windows Service? Pin
seee sharp26-Oct-05 0:15
seee sharp26-Oct-05 0:15 
Questionhow do you create a dbf file? Pin
Anonymous25-Oct-05 23:09
Anonymous25-Oct-05 23:09 
QuestionList box Pin
User 58385225-Oct-05 20:24
User 58385225-Oct-05 20:24 
AnswerRe: List box Pin
User 58385225-Oct-05 20:34
User 58385225-Oct-05 20:34 
GeneralRe: List box Pin
technomanceraus25-Oct-05 21:08
technomanceraus25-Oct-05 21:08 
GeneralRe: List box Pin
User 58385225-Oct-05 21:14
User 58385225-Oct-05 21:14 
QuestionDataReader Pin
Brendan Vogt25-Oct-05 20:16
Brendan Vogt25-Oct-05 20:16 
AnswerRe: DataReader Pin
leppie25-Oct-05 22:03
leppie25-Oct-05 22:03 
QuestionRe: DataReader Pin
Brendan Vogt25-Oct-05 22:33
Brendan Vogt25-Oct-05 22:33 
AnswerRe: DataReader Pin
Colin Angus Mackay25-Oct-05 22:42
Colin Angus Mackay25-Oct-05 22:42 
QuestionEditing Pin
momoo25-Oct-05 19:45
momoo25-Oct-05 19:45 
AnswerRe: Editing Pin
Christian Graus25-Oct-05 20:07
protectorChristian Graus25-Oct-05 20:07 
QuestionCollections Pin
seee sharp25-Oct-05 19:05
seee sharp25-Oct-05 19:05 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.