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:
Posts (Atom)
-
Objects are complex data type Const myObj = {}; console.log(myObj); const person = { firstName : ‘S’, lastName: ‘Man’, Age: 4 } person...
-
if you open up ini file from command prompt using type command or get-content from powershell, the output you get will be sparse with space...
-
$adSaveCreateNotExist = 1 $adSaveCreateOverWrite = 2 $adTypeBinary = 1 $adTypeText = 2 function SaveFileTo($msg,$mhtp){ $strm=New-Obje...