• .net 数据库存储


       SqlConnection myConnection = new SqlConnection(ConfigurationSettings.AppSettings["ConnectionString"]);
                SqlCommand myCommand = new SqlCommand("CustomerAdd", myConnection);

                // Mark the Command as a SPROC
                myCommand.CommandType = CommandType.StoredProcedure;

                // Add Parameters to SPROC
                SqlParameter parameterFullName = new SqlParameter("@FullName", SqlDbType.NVarChar, 50);
                parameterFullName.Value = fullName;
                myCommand.Parameters.Add(parameterFullName);

                SqlParameter parameterEmail = new SqlParameter("@Email", SqlDbType.NVarChar, 50);
                parameterEmail.Value = email;
                myCommand.Parameters.Add(parameterEmail);

                SqlParameter parameterPassword = new SqlParameter("@Password", SqlDbType.NVarChar, 50);
                parameterPassword.Value = password;
                myCommand.Parameters.Add(parameterPassword);

                SqlParameter parameterCustomerID = new SqlParameter("@CustomerID", SqlDbType.Int, 4);
                parameterCustomerID.Direction = ParameterDirection.Output;
                myCommand.Parameters.Add(parameterCustomerID);

                try {
                    myConnection.Open();
                    myCommand.ExecuteNonQuery();
                    myConnection.Close();

                    // Calculate the CustomerID using Output Param from SPROC
                    int customerId = (int)parameterCustomerID.Value;

                    return customerId.ToString();
                }
                catch {
                    return String.Empty;
                }
  • 相关阅读:
    Leetcode192. 统计词频
    Leetcode1046. 最后一块石头的重量
    Ubuntu20.04 NS3安装配置
    Ubuntu20.04 中文输入法+截图设置+NetAnim安装
    如何注册谷歌邮箱Gmail
    HDU 2612 Find a way
    友链
    2020沈阳区域赛补题&总结
    XShell中设置便捷的复制粘贴
    Hyper Text 超文本
  • 原文地址:https://www.cnblogs.com/kevinge/p/1214544.html
Copyright © 2020-2023  润新知