(MSSQL)
CREATE PROCEDURE [dbo].[test] --新增預存程序test並給一輸入參數
@tool_no varchar(50)
AS
SELECT [Tool_No],[Serial_No],[Tool_Revision]
FROM [ACF_Tooling].[dbo].[Main]
WHERE Tool_No = @tool_no
GO
--exec test 'AAA'; --執行預存程式並給定輸入值
(ASP.NET)
Dim ToolingConnectionString As New ConnectionString
Dim conn As New SqlConnection(ToolingConnectionString.ToolingConnectionString)
Dim sqlcmd As New SqlCommand("test", conn)
Dim dt As New DataTable
sqlcmd.CommandType = CommandType.StoredProcedure
sqlcmd.Parameters.AddWithValue("@tool_no", TextBox1.Text)
conn.Open()
dt.Load(sqlcmd.ExecuteReader)
conn.Close()
If dt.Rows.Count > 0 Then
GridView1.DataSource = dt
GridView1.DataBind()
End If
沒有留言:
張貼留言