static void Main(string[] args)
{
int j = sqlQueryTable("Data Source=ZHANGL;Initial Catalog=db_GVM;Integrated Security=True", "2012/11/4 12:41:16", "2012/11/4 12:41:56"); Console.WriteLine(j);
Console.ReadKey();
}
public static int sqlQueryTable(string specConnection, String startdatetime, String enddatetime)
{
int i = 0;
try { using (SqlConnection conn = new SqlConnection(specConnection)) { string strCmd = "select count(*) from tb_PDU where datetime >= 'startdatetime' and datetime <= 'enddatetime' "; conn.Open(); SqlCommand sqlCmd = new SqlCommand(strCmd, conn); i = Convert.ToInt32(sqlCmd.ExecuteScalar()); conn.Close(); } } catch (Exception ex) { Console.WriteLine(ex.Message + ex.Source); } return i; }
{
int j = sqlQueryTable("Data Source=ZHANGL;Initial Catalog=db_GVM;Integrated Security=True", "2012/11/4 12:41:16", "2012/11/4 12:41:56"); Console.WriteLine(j);
Console.ReadKey();
}
public static int sqlQueryTable(string specConnection, String startdatetime, String enddatetime)
{
int i = 0;
try { using (SqlConnection conn = new SqlConnection(specConnection)) { string strCmd = "select count(*) from tb_PDU where datetime >= 'startdatetime' and datetime <= 'enddatetime' "; conn.Open(); SqlCommand sqlCmd = new SqlCommand(strCmd, conn); i = Convert.ToInt32(sqlCmd.ExecuteScalar()); conn.Close(); } } catch (Exception ex) { Console.WriteLine(ex.Message + ex.Source); } return i; }
解决方案 »
- P/Invoke调用dll时,碰到如下错误,如何解决
- vs2010为什么好多命名空间不能引用,而msdn上查是有的?
- 我在桌面编程时想实现多线程解决窗体假死状态
- 关于Mutex的问题
- 这个SQL怎么写?解决立即给分!帮帮菜鸟吧
- 根据字符串创建类实例后的问题????(急,在线等)!!!!
- 请高手进,关于C#数据库备份的问题,急急急
- 下了SharpDevelop的源代码,想看看他们怎么做界面的。没想到。。。。
- 新手问题,大神介绍一下接口强制转换吧?
- C#病毒。C#病毒。C#病毒。C#病毒。C#病毒。C#病毒。C#病毒。C#病毒。C#病毒。C#病毒。C#病毒。C#病毒。C#病毒。C#病毒。C#病毒。C#病毒。
- SQL 中IMAGE类型的图片太大了,怎样可以压缩呢?
- C# Winfrom 怎么把换行的数据保存到数据中
C#里能这样解析吗?
string strCmd = "select count(*) from tb_PDU where datetime >= '"+startdatetime+"' and datetime <= '"+enddatetime+"' ";