问题描述
- assignment、call、increment等对象表达式可用作语句
-
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
public class DB
{
public SqlConnection con = new SqlConnection();
public SqlCommand com = new SqlCommand();
public SqlDataAdapter Da = new SqlDataAdapter();
public DataSet Ds = new DataSet();
public DB()
{ }public String GetConnectionstring() { String constr; constr = System.Configuration.ConfigurationManager.AppSettings.Get(0).ToString(); return constr; } public DataSet GetDataTableBysql(String sqlstr) { con.ConnectionString = GetConnectionstring(); com.Connection = con; com.CommandText = sqlstr; Da.SelectCommand = com; try { Ds.Clear(); con.Open(); Da.Fill(Ds); con.Close(); } catch (SqlException) { con.Close(); } return Ds; } public Boolean UpdataDatabysql(String sqlstr) { con.ConnectionString = GetConnectionstring(); com.Connection = con; com.CommandText = sqlstr; try { con.Open(); com.ExecuteNonQuery(); con.Close; return true; } catch (SqlException) { con.Close; return false; } }
}
错误 1 只有 assignment、call、increment、decrement 和 new 对象表达式可用作语句 C:UsersAdministratorDocumentsVisual Studio 2005WebSitesWebSite1App_CodeDB.cs 57 13 C:...WebSite1有两个错误,怎么解决。
解决方案
con.Close;
->
con.Close();
解决方案二:
constr = System.Configuration.ConfigurationManager.AppSettings.Get(0).ToString();
->
constr = System.Configuration.ConfigurationManager.AppSettings[0].ToString();
解决方案三:
只有 assignment、call、increment、decrement 和 new 对象表达式可用作语句
只有 assignment、call、increment、decrement 和 new 对象表达式可用作语句
只有assignment、call、increment和new对象表达式可用作语句 是怎么一回事??
时间: 2024-12-10 12:51:20