DataTable dt = new DataTable();
string constr="user id=sa;Password=sa;data source=数据库IP地址;persist security info=False;initial catalog=数据库名称";
SqlConnection conn = new SqlConnection(constr);
string str="你要查询使用的SQL语句";
SqlDataAdapter da = new SqlDataAdapter(str,conn);
conn.Open();
da.Fill(dt);
conn.Close();
最简单的写文件
string path = @"文件路径";
if (!File.Exists(path))
{
// Create a file to write to.
using (StreamWriter sw = File.CreateText(path))
{
sw.WriteLine("Hello");
}
}
// This text is always added, making the file longer over time
// if it is not deleted.
using (StreamWriter sw = File.AppendText(path))
{
sw.WriteLine(DateTime.Now);
sw.WriteLine("-------------------");
sw.WriteLine(数据);
}
string constr="user id=sa;Password=sa;data source=数据库IP地址;persist security info=False;initial catalog=数据库名称";
SqlConnection conn = new SqlConnection(constr);
string str="你要查询使用的SQL语句";
SqlDataAdapter da = new SqlDataAdapter(str,conn);
conn.Open();
da.Fill(dt);
conn.Close();
最简单的写文件
string path = @"文件路径";
if (!File.Exists(path))
{
// Create a file to write to.
using (StreamWriter sw = File.CreateText(path))
{
sw.WriteLine("Hello");
}
}
// This text is always added, making the file longer over time
// if it is not deleted.
using (StreamWriter sw = File.AppendText(path))
{
sw.WriteLine(DateTime.Now);
sw.WriteLine("-------------------");
sw.WriteLine(数据);
}