急求解决方法!!!请高手指教!
天蝎阿辉 2006-09-27 09:53:02 Dim con As New OleDbConnection
con.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\db1.mdb"
con.Open()
Dim com As OleDbCommand = New OleDbCommand
com.CommandText = "SELECT Sum(金额) FROM a WHERE 日期 Between DateAdd("m",-10,getdate()) and getdate()"
TextBox1.Text = com.ExecuteScalar().ToString()
com.Dispose()
con.Close()
一开始会出现提示错误com.CommandText = "SELECT Sum(金额) FROM a WHERE 日期 Between DateAdd(""m"",-10,getdate()) and getdate()" 没有结束语句
我把这句改成com.CommandText = "SELECT Sum(金额) FROM a WHERE 日期 Between DateAdd(""m"",-10,getdate()) and getdate()"
可以运行但是点击计算按钮就会出现异常:ExecuteScalar: Connection 属性尚未初始化。
请高手指教~~