zoukankan      html  css  js  c++  java
  • .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;
                }
  • 相关阅读:
    如何利用好chrome控制台这个神器好好调试javascript代码
    关于前端学习和笔试面试的总结
    当推荐算法开源包多如牛毛,为什么我们还要专门的推荐算法工程师
    关键词匹配项目深入研究(二)- 分表思想的引入
    PHP如何快速读取大文件
    整理了一些有用的网址,不喜勿喷
    Chrome控制台 JS调试的一些小技巧
    安装最新版本的PHPUnit后,不能使用
    PHP API接口测试小工具
    PHP Log时时查看小工具
  • 原文地址:https://www.cnblogs.com/kevinge/p/1214544.html
Copyright © 2011-2022 走看看