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;
                }
  • 相关阅读:
    《数据结构》2.2顺序表(sequence list)
    《算法竞赛入门经典》6.3.1二叉树-小球下落
    java_时间戳与Date_相互转化
    java事物
    Mysql如何向存在外键的数据表中插入数据
    git基本配置
    mysql时间属性之时间戳和datetime之间的转换
    【转】变量命名(简短且无歧义)
    【转】mybatis实战教程(mybatis in action),mybatis入门到精通
    [转]DAO层,Service层,Controller层、View层
  • 原文地址:https://www.cnblogs.com/kevinge/p/1214544.html
Copyright © 2011-2022 走看看