本文介绍了如何在Asp.Net中使用存储过程在文本框中显示数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

存储过程:

Store Procedure:

ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO

Create procedure [dbo].[GetPurchaseInvNo]

as
select   max(cast(ISNULL(dbo.RemoveNonAlphaCharacters(PINo),0)+1 as bigint)) from dbo.T_PTransaction







C#代码:




C# Code:

private static void GetInvoice()
       {

try
            {
                using (SqlConnection con = new SqlConnection(Class_Connection.ETConnection))
                {
                    con.Open();
                    using (SqlCommand cmd = con.CreateCommand())
                    {
                        cmd.CommandType = CommandType.StoredProcedure;
                        cmd.CommandText = "GetPurchaseInvNo";
                      
                        cmd.ExecuteNonQuery();
                      
                    }
                }

            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
}











问题:

现在如何在TextBox中获取'PINo'的值?






Question:
Now how can i get the value of 'PINo' in TextBox?

推荐答案

private static void GetInvoice()
{
 
try
{
using (SqlConnection con = new SqlConnection(Class_Connection.ETConnection))
{
con.Open();
using (SqlCommand cmd = con.CreateCommand())
{
cmd.CommandType = CommandType.StoredProcedure;
cmd.CommandText = "GetPurchaseInvNo";
SqlDataReader dr = cmd.ExecuteReader();
            dr.Read();
            if (dr.HasRows)
            {
             TextBox1.Text= dr[0].ToString();    

            }
             dr.Close(); 

}
}
 
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
}



这篇关于如何在Asp.Net中使用存储过程在文本框中显示数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-29 04:43