| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 966 人关注过本帖
标题:又来求助了!
取消只看楼主 加入收藏
jianfeixu
Rank: 1
等 级:新手上路
帖 子:96
专家分:0
注 册:2005-1-24
收藏
 问题点数:0 回复次数:2 
又来求助了!
我想在SQL返回指定用户ID的所有信息:
2005-01-25 16:37
jianfeixu
Rank: 1
等 级:新手上路
帖 子:96
专家分:0
注 册:2005-1-24
收藏
得分:0 

private void button1_Click(object sender, System.EventArgs e) { string Givenwater = comboBox4.Text.Trim(); string givenwater=textBox6.Text.Trim(); waters waterselect=new waters(); switch(Givenwater) { case "查询全部": Fill_view(Givenwater); break; case "客户编号": Fill_view_kehu(Givenwater); break; default: break; } } 函数: //用于显示查询的内容-------客户编号----------未完成 private int Fill_view_kehu(string Givenwater) { DataSet waterall_View = new DataSet();

waters waterselectone = new waters(); int kehu=Int32.Parse(textBox6.Text.Trim() );

if(!waterselectone.Get_kehu_water(ref myConn, kehu)) return -1;

int waterCount = waterall_View.Tables["ScheduleList"].Rows.Count; // if( nScheduleCount > 0) dataGrid1.DataSource = waterall_View.Tables["ScheduleList"].DefaultView;

return 0; } //获取指定的客户资料 public bool Get_kehu_water(ref SqlConnection myConn, int Get_kehu) { SqlCommand cmd = new SqlCommand("GetwaterBykehu", myConn); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add(Get_kehu); SqlDataReader waterReader = cmd.ExecuteReader();

int kehu_c_id=0;// string kehu_address="";// string kehu_tel="";// DateTime kehu_p_time=DateTime.Now;// int kehu_out_water_num=0;// int kehu_back_barrel_num=0;//-------------- string kehu_money_metion=""; string kehu_man_out_water="";//------------- int kehu_remnant_water=0; int kehu_stock_water=0; string kehu_man_stock_water="";//------------- string kehu_back_up="";

try { if(waterReader.Read()) { kehu_c_id = Int32.Parse(waterReader["c_id"].ToString().Trim()); kehu_address = waterReader["address"].ToString().Trim(); kehu_tel = waterReader["tel"].ToString().Trim(); kehu_p_time = DateTime.Parse(waterReader["p_time"].ToString());

kehu_out_water_num = Int32.Parse(waterReader["out_water_num"].ToString().Trim()); kehu_back_barrel_num = Int32.Parse(waterReader["back_barrel_num"].ToString().Trim()); kehu_money_metion = waterReader["money_metion"].ToString().Trim(); kehu_man_out_water = waterReader["man_out_water"].ToString().Trim();

kehu_remnant_water = Int32.Parse(waterReader["remnant_water"].ToString().Trim()); kehu_stock_water = Int32.Parse(waterReader["stock_water"].ToString().Trim()); kehu_man_stock_water = waterReader["man_stock_water"].ToString().Trim(); kehu_back_up = waterReader["back_up"].ToString().Trim(); } } catch { waterReader.Close(); return false; }

c_id=kehu_c_id;// address=kehu_address;// tel=kehu_tel;// p_time=kehu_p_time;// out_water_num=kehu_out_water_num;// back_barrel_num=kehu_back_barrel_num;//-------------- money_metion=kehu_money_metion; man_out_water=kehu_man_out_water;//------------- remnant_water=kehu_remnant_water; stock_water=kehu_stock_water; man_stock_water=kehu_man_stock_water;//------------- back_up=kehu_back_up;

return true; } 存储过程 CREATE PROCEDURE GetwaterBykehu @c_id BIGINT AS SELECT * FROM water WHERE c_id = @c_id RETURN GO

2005-01-25 16:48
jianfeixu
Rank: 1
等 级:新手上路
帖 子:96
专家分:0
注 册:2005-1-24
收藏
得分:0 

我把这段和原来的函数替换了,然后就成功通过了,请大家帮我解释一下好么? public bool Get_kehu_water(ref SqlConnection myConn, ref DataSet ds,int Get_kehu) { SqlDataAdapter kehu_water = new SqlDataAdapter("GetwaterBykehu", myConn); kehu_water.SelectCommand.CommandType = CommandType.StoredProcedure; kehu_water.SelectCommand.Parameters.Add("@c_id", Get_kehu); try { kehu_water.Fill(ds, "ScheduleList"); } catch { return false; } return true; } //用于显示查询的内容-------客户编号 private int Fill_view_kehu(string Givenwater) { DataSet waterall_View = new DataSet();

waters waterselectone = new waters(); int kehu=Int32.Parse(textBox6.Text.Trim() );

if(!waterselectone.Get_kehu_water(ref myConn,ref waterall_View, kehu)) return -1;

int waterCount = waterall_View.Tables["ScheduleList"].Rows.Count; // if( nScheduleCount > 0) dataGrid1.DataSource = waterall_View.Tables["ScheduleList"].DefaultView;

return 0; }

2005-01-25 17:35
快速回复:又来求助了!
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.016628 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved