System.Web.UI.Page.Server 是属性,此处应为类????接口中 10
publicinterfaceiuser//创建接口,定义公共属性和方法{intadduser(stringname,stringpswd,stringage);intd...
public interface iuser//创建接口,定义公共属性和方法
{
int adduser(string name,string pswd,string age);
int deluser(int uid);
OleDbDataReader login(string logname,string loginpswd);
OleDbDataReader databind();
}
public class user:iuser//继承接口和实现接口中的方法
{
public static readonly string addstr="INSERT INTO userstb([username],[password],[userage]) values";
public static readonly string delstr="DELETE FROM userstb WHERE id=";
public static readonly string loginstr="SELECT username,password FROM userstb WHERE username=";
public static readonly string databindstr="SELECT username,password,userage FROM userstb";
public int adduser(string name,string pswd,string age)
{
OleDbConnection thisCON=new OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source="+Server.MapPath(ConfigurationSettings.AppSettings["datacon"])); //运行时提示server错误:此处应为类,不是属性
OleDbCommand addCOMD=thisCON.CreateCommand();
addCOMD.CommandText=addstr+"("+name+","+pswd+","+age+")";
int n;
try
{
thisCON.Open();
n=addCOMD.ExecuteNonQuery();
}
finally
{
thisCON.Close();
}
return n;
}
public int deluser(int uid)
{
OleDbConnection thisCON=new OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source="+Server.MapPath(ConfigurationSettings.AppSettings["datacon"]));//运行时提示server错误:此处应为类,不是属性
OleDbCommand delCOMD=thisCON.CreateCommand();
delCOMD.CommandText=delstr+uid;
int K;
try
{
thisCON.Open();
K=delCOMD.ExecuteNonQuery();
}
finally
{
thisCON.Close();
}
return K;
}
public OleDbDataReader login(string logname,string loginpswd)
{
OleDbConnection thisCON=new OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source="+Server.MapPath(ConfigurationSettings.AppSettings["datacon"]));//运行时提示server错误:此处应为类,不是属性
OleDbCommand loginCOMD=thisCON.CreateCommand();
loginCOMD.CommandText=loginstr+logname+"AND password="+loginpswd;
OleDbDataReader logindr=null;
try
{
thisCON.Open();
logindr=loginCOMD.ExecuteReader();
}
finally
{
thisCON.Close();
}
return logindr;
}
public OleDbDataReader databind()
{
OleDbConnection thisCON=new OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source="+Server.MapPath(ConfigurationSettings.AppSettings["datacon"]));//运行时提示server错误:此处应为类,不是属性
OleDbCommand bindCOMD=thisCON.CreateCommand();
bindCOMD.CommandText=databindstr;
OleDbDataReader databinddr=null;
try
{
thisCON.Open();
databinddr=bindCOMD.ExecuteReader();
}
finally
{
thisCON.Close();
}
return databinddr;
} 展开
{
int adduser(string name,string pswd,string age);
int deluser(int uid);
OleDbDataReader login(string logname,string loginpswd);
OleDbDataReader databind();
}
public class user:iuser//继承接口和实现接口中的方法
{
public static readonly string addstr="INSERT INTO userstb([username],[password],[userage]) values";
public static readonly string delstr="DELETE FROM userstb WHERE id=";
public static readonly string loginstr="SELECT username,password FROM userstb WHERE username=";
public static readonly string databindstr="SELECT username,password,userage FROM userstb";
public int adduser(string name,string pswd,string age)
{
OleDbConnection thisCON=new OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source="+Server.MapPath(ConfigurationSettings.AppSettings["datacon"])); //运行时提示server错误:此处应为类,不是属性
OleDbCommand addCOMD=thisCON.CreateCommand();
addCOMD.CommandText=addstr+"("+name+","+pswd+","+age+")";
int n;
try
{
thisCON.Open();
n=addCOMD.ExecuteNonQuery();
}
finally
{
thisCON.Close();
}
return n;
}
public int deluser(int uid)
{
OleDbConnection thisCON=new OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source="+Server.MapPath(ConfigurationSettings.AppSettings["datacon"]));//运行时提示server错误:此处应为类,不是属性
OleDbCommand delCOMD=thisCON.CreateCommand();
delCOMD.CommandText=delstr+uid;
int K;
try
{
thisCON.Open();
K=delCOMD.ExecuteNonQuery();
}
finally
{
thisCON.Close();
}
return K;
}
public OleDbDataReader login(string logname,string loginpswd)
{
OleDbConnection thisCON=new OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source="+Server.MapPath(ConfigurationSettings.AppSettings["datacon"]));//运行时提示server错误:此处应为类,不是属性
OleDbCommand loginCOMD=thisCON.CreateCommand();
loginCOMD.CommandText=loginstr+logname+"AND password="+loginpswd;
OleDbDataReader logindr=null;
try
{
thisCON.Open();
logindr=loginCOMD.ExecuteReader();
}
finally
{
thisCON.Close();
}
return logindr;
}
public OleDbDataReader databind()
{
OleDbConnection thisCON=new OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source="+Server.MapPath(ConfigurationSettings.AppSettings["datacon"]));//运行时提示server错误:此处应为类,不是属性
OleDbCommand bindCOMD=thisCON.CreateCommand();
bindCOMD.CommandText=databindstr;
OleDbDataReader databinddr=null;
try
{
thisCON.Open();
databinddr=bindCOMD.ExecuteReader();
}
finally
{
thisCON.Close();
}
return databinddr;
} 展开
1个回答
展开全部
呵呵 既然如此
却之不恭 受之无愧 :)
Server类应该这样用
System.Web.HttpContext.Current.Server.MapPath(strFilePath);
却之不恭 受之无愧 :)
Server类应该这样用
System.Web.HttpContext.Current.Server.MapPath(strFilePath);
参考资料: http://zhidao.baidu.com/question/43450200.html
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询