public DataTable executeSQL(string sql)
        {
            DataTable dt = new DataTable();
            sqlcmd = new SqlCommand(sql, new SqlConnection(ConnectionString));
            if (sqlcmd.Connection.State != System.Data.ConnectionState.Open)
            {
                sqlcmd.Connection.Open();
            }
            SqlDataReader dr = sqlcmd.ExecuteReader();
            int fc = dr.FieldCount;
            Debug.WriteLine("number of columns : "+fc);
            //creating columns in the table
            for (int i = 0; i < fc; i++)
            {
                dt.Columns.Add(dr.GetName(i), dr.GetFieldType(i));
            }
            //adding rows in the table
            while (dr.Read())
            {
                DataRow drow = dt.NewRow();
                for (int i = 0; i < fc; i++)
                {
                    drow[i] = dr.GetValue(i);
                }
                dt.Rows.Add(drow);
            }
            sqlcmd.Connection.Close();
            return dt;
        }
Subscribe to:
Comments (Atom)
- 
All WMI Class Names list : - Name ...
 - 
Functions are loosely typed in javascript, we are able to pass different types of parameters, too few args, too many argos etc. Keep functio...
 - 
Hi All, Thanks for taking out time to read this post. Can someone help me with this? When I try to run this, System.TypeLoadExeception Error...