今天来结贴,谢谢csdn的朋友,也带来一个问题 :)

feeling_vb feeling_vb 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区


private void method_1 ()
{
string aa = "";

string bb = "";

SqlConnection aa = new SqlConnection ( connstr );

aa.open();

SqlCommand cmd = new SqlCommand ( " select col_a from tab_a " ,aa );

SqlDataReader rec = cmd.ExecuteReader ( );

while ( rec.read() )
{

aa =rec[0].tostring();

bb = method_2 ( aa );

}

rec.close();
aa.close();

}



private string method_2 ( string TheCode )
{

string strName = "";

SqlConnection conb = new SqlConnection ( connstr );

conb.open();

SqlCommand cmd = new SqlCommand ( " select col_b from tab_b where code = '"+TheCode+"' " ,conb );

SqlDataReader rec = cmd.ExecuteReader ( );

if ( rec.read() )
{
strName = rec[0].tostring();
rec.close();
conb.close();
return strName;
}

rec.close();
conb.close();

return strName;

}


可是不让同时打开俩个记录集,这种情况怎么办????
...全文

相关推荐

评论 4
收藏 已收藏
分享
返回顶部
feeling_vb
C# 111,128 成员 642,536 内容