public class aa
{
public string c1;
public string c2;
public string c3;
public string c4;
public string c5;
public string c6;
}
public static bool haha()
{
string PriceID = String.Empty;
SqlConnection con = showclass.datacon.AutoCon();
con.Open();
SqlCommand cmd = new SqlCommand("cc_cc " + PriceID,con);
aa PV=new aa();
using(SqlDataReader sdr = cmd.ExecuteReader(CommandBehavior.CloseConnection))
{
if(sdr.Read())
{
PV.c1 = sdr["auto_price"].ToString();
PV.c2 = sdr["auto_color"].ToString();
PV.c3 = sdr["user_dw"].ToString();
PV.c4 = sdr["user_tel"].ToString();
PV.c5 = sdr["AutoBrand"].ToString();
PV.c6 = sdr["AutoType"].ToString();
}
}
con.Close();
}
这个类那里写的不对!
然后在别的页面如何调用?
{
public string c1;
public string c2;
public string c3;
public string c4;
public string c5;
public string c6;
}
public static bool haha()
{
string PriceID = String.Empty;
SqlConnection con = showclass.datacon.AutoCon();
con.Open();
SqlCommand cmd = new SqlCommand("cc_cc " + PriceID,con);
aa PV=new aa();
using(SqlDataReader sdr = cmd.ExecuteReader(CommandBehavior.CloseConnection))
{
if(sdr.Read())
{
PV.c1 = sdr["auto_price"].ToString();
PV.c2 = sdr["auto_color"].ToString();
PV.c3 = sdr["user_dw"].ToString();
PV.c4 = sdr["user_tel"].ToString();
PV.c5 = sdr["AutoBrand"].ToString();
PV.c6 = sdr["AutoType"].ToString();
}
}
con.Close();
}
这个类那里写的不对!
然后在别的页面如何调用?
解决方案 »
- 数据列套用
- 急.....textbox如何自动输入
- 求js和.net事件处理流程的顺序
- ↗↗↗↗↗↗↗↗↗↗↗↗TreeView的TreeNode的ToolTip属性怎么只能显示100字符阿↗↗↗↗↗↗↗↗↗↗↗↗↗↗↗↗↗↗↗↗↗↗↗↗↗↗
- |M| 我用花生壳这类软件挂了我的一个网站,但为什么网外可以访问,而我本机和本网内的没有办法访问呢
- 如何给DateTime类型的变量赋一个空值?
- 帮忙看一下 关于字符串查找 100分
- 两个个问题会聚一起问一下。内容(接口,正则)
- 发短信 c#
- 如何判断session是否有需要的内容?
- 请教在虚拟主机上调用webservice的问题
- 求关于取字符串的问题!在线等
这个地方不对!
你的haha()方法内的所有分支都要返回一个true或false;
如:
public static bool haha()
{
string PriceID = String.Empty;
SqlConnection con = showclass.datacon.AutoCon();
con.Open();
SqlCommand cmd = new SqlCommand("cc_cc " + PriceID,con);
aa PV=new aa();
using(SqlDataReader sdr = cmd.ExecuteReader(CommandBehavior.CloseConnection))
{
if(sdr.Read())
{
PV.c1 = sdr["auto_price"].ToString();
PV.c2 = sdr["auto_color"].ToString();
PV.c3 = sdr["user_dw"].ToString();
PV.c4 = sdr["user_tel"].ToString();
PV.c5 = sdr["AutoBrand"].ToString();
PV.c6 = sdr["AutoType"].ToString();
}
}
con.Close();
return true;
}
{
public string c1;
public string c2;
public string c3;
public string c4;
public string c5;
public string c6; public static bool haha()
{
string PriceID = String.Empty;
SqlConnection con = showclass.datacon.AutoCon();
con.Open();
SqlCommand cmd = new SqlCommand("cc_cc " + PriceID,con);
aa PV = new aa();
using(SqlDataReader sdr = cmd.ExecuteReader(CommandBehavior.CloseConnection))
{
if(sdr.Read())
{
PV.c1 = sdr["auto_price"].ToString();
PV.c2 = sdr["auto_color"].ToString();
PV.c3 = sdr["user_dw"].ToString();
PV.c4 = sdr["user_tel"].ToString();
PV.c5 = sdr["AutoBrand"].ToString();
PV.c6 = sdr["AutoType"].ToString();
}
}
con.Close();
return true; //反正最后你的有返回值啊
}
}
public static void haha()
这句话有问题开始的帖子已经告诉你怎么做了
这个地方已经OK了
public static void haha()
删除void?