我正在关注https://msdn.microsoft.com/en-us/library/jj943772.aspx的教程 有没有人完成这个项目?
当我这样做时,导航中的按钮似乎没有响应......任何帮助都将非常受欢迎。
另一个问题如下: -
我很抱歉Fran Tan,我应该包含代码。我以为有人做过,可以告诉我正确的课程。确实发生了这种情况,谢谢Alex W.双击按钮创建按钮点击方法的问题。我想问一下:该应用程序已经构建并发布,当我尝试进入新客户时,它会返回消息:'未返回客户ID。无法创建帐户'。:// NC-10 try-catch-finally
try
{
//NC-11 Open the connection.
conn.Open();
//NC-12 Run the stored procedure.
cmdNewCustomer.ExecuteNonQuery();
//NC-13 Customer ID is an IDENTITY value from the database.
this.parsedCustomerID = (int)cmdNewCustomer.Parameters["@CustomerID"].Value;
this.txtCustomerID.Text = Convert.ToString(parsedCustomerID);
}
catch
{
//NC-14 A simple catch.
MessageBox.Show("Customer ID was not returned. Account could not be created.");
}
finally
{
//NC-15 Close the connection.
conn.Close();
}
这是存储过程:
CREATE PROCEDURE [Sales].[uspNewCustomer]
@CustomerName NVARCHAR (40),
@CustomerID INT OUTPUT
AS
BEGIN
INSERT INTO [Sales].[Customer] (CustomerName)
VALUES (@CustomerName);
SET @CustomerID = SCOPE_IDENTITY();
RETURN @@ERROR
END
GO