本文介绍了我在存储过程中声明create_date作为插入到注册(create_date)值(getdate())并且其创建成功。然后我想在C#中声明如何声明的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

存储过程sql server编码



插入dbo.Registration(Cust_Name,Address,EmailID,Contact_No,Username,Password,Pincode,Create_Date)值

(@ CustomerName,@ CustomerAddress,@ CustomerEmailID,@ CustomerPhoneNo,@ Username,@ Password,@ Pincode,GETDATE())

c #coding

public class shopping

$



public string CustomerName;

public string CustomerEmailID;

公共字符串CustomerPhoneNo;

公共字符串CustomerAddress;

公共字符串用户名;

公共字符串密码;

public string ConfirmPassword;

public int Pincode;

public DateTime CreateDate;



public void Registration()

{

SqlParameter [] parameters = new SqlParameter [8];

参数[0] = DataLayer。 DataAccess.AddParameter(@ CustomerName,CustomerName,System.Data.SqlDbType.NVarChar,50);

parameters [1] = DataLayer.DataAccess.AddParameter(@ CustomerEmailID,CustomerEmailID,System。 Data.SqlDbType.NVarChar,50);

parameters [2] = DataLayer.DataAccess.AddParameter(@ CustomerPhoneNo,CustomerPhoneNo,System.Data.SqlDbType.VarChar,50);

parameters [3] = DataLayer.DataAccess.AddParameter(@ CustomerAddress,CustomerAddress,System.Data.SqlDbType.NVarChar,50);

parameters [4] = DataLayer.DataAccess。 AddParameter(@ Username,Username,System.Data.SqlDbType.NVarChar,50);

parameters [5] = DataLayer.DataAccess.AddParameter(@ Password,Password,System.Data。 SqlDbType.NVarChar,50);

parameters [6] = DataLayer.DataAccess.AddParameter(@ Pincode,Pincode,System.Data.SqlDbType.Int,10);

参数[7] = DataLayer.DataAccess.AddParameter(@ Cre ateDate,CreateDate,System.DateTime.Now.ToShortDateString());





DataTable dt = DataLayer.DataAccess.ExecutedByProcedure( Sp_AddCustomers,参数);

}



我尝试过:

$ / $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ Now.ToShortDateString());

store procedure sql server coding

insert into dbo.Registration(Cust_Name,Address,EmailID,Contact_No,Username,Password,Pincode,Create_Date) values
(@CustomerName,@CustomerAddress,@CustomerEmailID,@CustomerPhoneNo,@Username,@Password,@Pincode,GETDATE())
c# coding
public class shopping
{

public string CustomerName;
public string CustomerEmailID;
public string CustomerPhoneNo;
public string CustomerAddress;
public string Username;
public string Password;
public string ConfirmPassword;
public int Pincode;
public DateTime CreateDate;

public void Registration()
{
SqlParameter[] parameters = new SqlParameter[8];
parameters[0] = DataLayer.DataAccess.AddParameter("@CustomerName", CustomerName, System.Data.SqlDbType.NVarChar, 50);
parameters[1] = DataLayer.DataAccess.AddParameter("@CustomerEmailID", CustomerEmailID, System.Data.SqlDbType.NVarChar, 50);
parameters[2] = DataLayer.DataAccess.AddParameter("@CustomerPhoneNo", CustomerPhoneNo, System.Data.SqlDbType.VarChar, 50);
parameters[3] = DataLayer.DataAccess.AddParameter("@CustomerAddress", CustomerAddress, System.Data.SqlDbType.NVarChar, 50);
parameters[4] = DataLayer.DataAccess.AddParameter("@Username", Username, System.Data.SqlDbType.NVarChar, 50);
parameters[5] = DataLayer.DataAccess.AddParameter("@Password", Password, System.Data.SqlDbType.NVarChar, 50);
parameters[6] = DataLayer.DataAccess.AddParameter("@Pincode",Pincode, System.Data.SqlDbType.Int,10);
parameters[7] = DataLayer.DataAccess.AddParameter("@CreateDate",CreateDate, System.DateTime.Now.ToShortDateString());


DataTable dt = DataLayer.DataAccess.ExecutedByProcedure("Sp_AddCustomers", parameters);
}

What I have tried:

System.Data.SqlDbType.Int,10);
parameters[7] = DataLayer.DataAccess.AddParameter("@CreateDate",CreateDate, System.DateTime.Now.ToShortDateString());

推荐答案

parameters[7] = new SqlParameter("@CreateDate", System.Data.SqlDbType.DateTime);
            parameters[7].Value=System.DateTime.Now;


这篇关于我在存储过程中声明create_date作为插入到注册(create_date)值(getdate())并且其创建成功。然后我想在C#中声明如何声明的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-14 05:44