本文介绍了如何使用存储过程在gridview中检索数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 我正在使用存储过程从数据库中检索值我的代码如下所示 i am using stored procedure to retrive value from database my code is as belowusing System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Threading.Tasks;using System.Windows.Forms;using System.Data.SqlClient;using System.IO.Compression;namespace WindowsFormsApplication2_testbill_2{ public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { try { SqlConnection sqlcon = new SqlConnection("DataSource=SQLEXPRESS"+"InitialCatalog=esdata"+"Integrated Security=True");sqlcon.Open();SqlCommand sqlcmd = new SqlCommand("urgentbill",sqlcon);sqlcmd.CommandType = CommandType.StoredProcedure;sqlcmd.Parameters.AddWithValue("@Vno", textBox1.Text);sqlcmd.Parameters.AddWithValue("@Vdt",dateTimePicker1.Text); sqlcmd.ExecuteNonQuery();urgentbilltestTableAdapter bu = new urgentbilltestTableAdapter(sqlcmd); esdataDataSet4 ds = new esdataDataSet4();bu.Fill(ds); if (ds.Tables[0].Rows.Count > 0) { dataGridView1.Visible = true; dataGridView1.DataSource = ds.Tables[0]; } } catch (Exception ex) { MessageBox.Show(ex.Message.ToString()); } // finally // { // Sqlcon.close(); // } } private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e) { } private void textBox1_TextChanged(object sender, EventArgs e) { } private void button2_Click(object sender, EventArgs e) { textBox1.Text=""; } } } 我的存储过程是 my stored procedure is create procedure urgentbilltest(@Vno int,@Vdt smalldatetime)asbeginselect item.location, sum(salepurchase2.qty) AS QTY,sum(salepurchase2.fqty) AS FQTY, item.name, SALEPURCHASE2.MRP, item.pack, item.compname, salepurchase2.batch, salepurchase2.expiry from salepurchase2 inner join item on salepurchase2.itemc=item.code where ((salepurchase2.vdt= @Vdt+'%')) and salepurchase2.vtype in ('Sb', 's1') and (salepurchase2.vno in ( @Vno+'%')) group by salepurchase2.batch, item.location, item.name, item.pack, item.compname, SALEPURCHASE2.MRP, salepurchase2.expiry order by item.location end 请帮助获取值datagridview please help to get values in datagridview推荐答案 这篇关于如何使用存储过程在gridview中检索数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 09-27 02:46