2 hy123hy123hy123 hy123hy123hy123 于 2016.04.23 18:58 提问

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:\Users\Administrator\Documents\Visual Studio 2005\WebSites\WebSite1\App_Code\DB.cs 57 13 C:...\WebSite1\

有两个错误,怎么解决。

3个回答

caozhy
caozhy   Ds   Rxr 2016.04.24 03:55

con.Close;
->
con.Close();

caozhy
caozhy   Ds   Rxr 2016.04.24 03:56

constr = System.Configuration.ConfigurationManager.AppSettings.Get(0).ToString();
->
constr = System.Configuration.ConfigurationManager.AppSettings[0].ToString();

CSDNXIAOD
CSDNXIAOD   2016.04.26 08:21
Csdn user default icon
上传中...
上传图片
插入图片
准确详细的回答,更有利于被提问者采纳,从而获得C币。复制、灌水、广告等回答会被删除,是时候展现真正的技术了!