我正在尝试将系统日期插入到数据库中但是有一个错误"不可调用的成员' tostring'不能像方法一样使用"。这是我的代码
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
using System.IO;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Web.UI.WebControls;
public partial class code : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
[WebMethod]
public static bool register(string rusrid, string rname, string raddress,
string rcity,string rdistrict,string rstate,int rpin,string rlanph,string
rmob,string rgen, string remail,string rpass)
{
bool msg = false;
string constr =
ConfigurationManager.ConnectionStrings["constr"].ConnectionString;
using (SqlConnection con = new SqlConnection(constr))
{
con.Open();
SqlCommand cmd = new SqlCommand("user_reg", con);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add("@Jdate", SqlDbType.Date).Value =
DateTime.Now.ToString("dd/MM/yyyy");
cmd.Parameters.AddWithValue("@cstatus", '1');
cmd.ExecuteNonQuery();
msg = true;
}
return msg;
}
}
在我的数据库中,日期列的数据类型设置为日期