日期:2014-05-18  浏览次数:20665 次

各位大虾,请问如何从sql提取数据从字符界面输出啊.应该加那一句??
using   System;
using   System.Data   ;
using   System.Data   .SqlClient   ;

namespace   ConsoleApplication7
{
///   <summary>
///   Class1   的摘要说明。
///   </summary>
class   Class1
{
///   <summary>
///   应用程序的主入口点。
///   </summary>
[STAThread]
static   void   Main(string[]   args)
{
try
{
SqlConnection   conn=new   SqlConnection   ( "server=localhost;database=下行_短信;uid=sa;pwd=sa ");
conn.Open   ();
string   sql= "select   *   from   下行_短信   where   发送状态=1 ";
SqlCommand   com=new   SqlCommand   (sql,conn);

//Console.WriteLine   (com);
conn.Close   ();
}
catch   (Exception   ex)
{
Console.WriteLine   ( " "+ex.ToString   ());
}

//   TODO:   在此处添加代码以启动应用程序
//
}
}
}

------解决方案--------------------
JF啊