.Close()这个关闭链接的方法 应该写在return前面还是后面 这样写总是提示有错误说fildcount什么的 应该怎么写?
mycon = cf.conn();
if (mycon.State == ConnectionState.Closed)
mycon.Open();
myds = new DataSet();
myda = new SqlDataAdapter();
mycmd = new SqlCommand(sel_letak, mycon);
mycmd.CommandType = CommandType.StoredProcedure;
myda.SelectCommand = mycmd;
myda.Fill(myds);
mycon.Close();
mycmd.Dispose();
return myds;
mycon = cf.conn();
if (mycon.State == ConnectionState.Closed)
mycon.Open();
myds = new DataSet();
myda = new SqlDataAdapter();
mycmd = new SqlCommand(sel_letak, mycon);
mycmd.CommandType = CommandType.StoredProcedure;
myda.SelectCommand = mycmd;
myda.Fill(myds);
mycon.Close();
mycmd.Dispose();
return myds;
if(mycon!=null)
{
myds = new DataSet();
myda = new SqlDataAdapter();
mycmd = new SqlCommand(sel_letak, mycon);
mycmd.CommandType = CommandType.StoredProcedure;
myda.SelectCommand = mycmd;
myda.Fill(myds);
return myds;
}//这样试试.close(),关闭连接将连接扔进连接池,等待下次被调用,
.Dispose(),销毁连接
if (mycon.State == ConnectionState.Closed)
mycon.Open();
myds = new DataSet();
myda = new SqlDataAdapter();
mycmd = new SqlCommand(sel_letak, mycon);
mycmd.CommandType = CommandType.StoredProcedure;
myda.SelectCommand = mycmd;
myda.Fill(myds); mycmd.Dispose();
mycon.Close();
return myds;