2014-01-17 34 views

回答

0

如果您正在使用MS SQL尝试使用::

using System.Data.SQLClient; 

Class DataExtract 
{ 

Public DataTable Extract() 
    { 
    SqlConnection con = new SqlConnection("Data Source = .; 
             Initial Catalog = domain; 
             Integrated Security = True"); 
    con.Open(); 
    SqlCommand cmd = new SqlCommand("Select * from tablename", con); 

    Return new DataTable().load(cmd.ExecuteReader()); 

    } 
} 
+0

我只是用文本框来显示数据,而不是在表格中。 – Subhan

+0

仅将所需列的值分配给文本框,如:: TextBox1.Text = Extract()。行[RowNumber] [“ColumnNameORIndex”]。ToString(); – Pritam