To Retrive Full columns in a DB
======================
select distinct
TBL.name as TableName,
COL.Name as ColumnName, TYP.name as Type, COL.max_length as Length,
COL.precision as Precision, CASE COL.is_nullable WHEN 1 THEN 'Null' ELSE 'Not Null' end as 'Null' from sys.columns COL
inner join sys.objects TBL on COL.object_id= TBL.object_id
inner join sys.types TYP on TYP.system_type_id= COL.system_type_id
where TBL.type ='u' and TBL.name != 'sysdiagrams'
and TYP.name !='sysname' order by
TBL.name,
COL.name
Saturday, December 13, 2008
Retrive all columns in the DB
DataTable Load()
DataTable's Load method.
===================
string sql = "Select * from MyTable";
SqlCommand cmd = new SqlCommand(sql, MyConnection);
SqlDataReader dr = cmd.ExecuteReader();
DataTable dt = new DataTable();
//Load the SqlDataReader object to the DataTable object as follows.
dt.Load(dr);
Response.Write(dt.Rows.Count.ToString());
Merge DataSet
DataSet.Merge(ds)
==============
For the merge to take place between the datasets, apart from the data type and column name, the table name should also be the same.
Dim myConnection as New SqlConnection (strConn)
Dim DS1 As DataSet
Dim DS1 As DataSet
Dim MyCommand As SqlDataAdapter
MyCommand = new SqlDataAdapter("exec s_get_table1", MyConnection)
DS1 = new DataSet()
MyCommand.Fill(DS1, "MyTable")
MyCommand = new SqlDataAdapter("exec s_get_table2", MyConnection)
DS2 = new DataSet()
MyCommand.Fill(DS2, "MyTable")
'Now the code works because the table name for both datasets are the same.
'Also the data type and column name for both tables are the same.
ds1.merge(ds2)
MyDataGrid.DataSource=DS1.tables(0).DefaultView
MyDataGrid.DataBind()
Globalization - Display currency
using System;
using System.Globalization;
public class TestClass
{
public static void Main()
{
int i = 100;
// Creates a CultureInfo for English in Belize.
CultureInfo bz = new CultureInfo("en-BZ");
// Displays i formatted as currency for the bz.
Console.WriteLine(i.ToString("c", bz));
// Creates a CultureInfo for English in the U.S.
CultureInfo us = new CultureInfo("en-US");
// Display i formatted as currency for us.
Console.WriteLine(i.ToString("c", us));
// Creates a CultureInfo for Danish in Denmark.
CultureInfo dk = new CultureInfo("da-DK");
// Displays i formatted as currency for dk.
Console.WriteLine(i.ToString("c", dk));
}
}
Subscribe to:
Posts (Atom)