繁体   English   中英

我想从int64转换为字节

[英]i want to convert from int64 to byte

无法将参数值从int32转换为数据库代码的字节

数据库中的过程是:

后面的Webform代码:

client c = new client();
c.name = Textbox_Addclient_first.Text + " " + Textbox_Addclient_second.Text + 
    " " + Textbox_Addclient_third.Text;
c.address = Textbox_addclientadress.Text;
c.phone = int.Parse(Textbox_addclientphone.Text);

类代码为:

SqlCommand com = new SqlCommand("add_client", con);

com.CommandType = CommandType.StoredProcedure;
com.Parameters.Add("@name", SqlDbType.NVarChar).Value = this.name;
com.Parameters.Add("@address", SqlDbType.NVarChar).Value = this.address;
com.Parameters.Add("@name", SqlDbType.TinyInt).Value = this.phone;
com.ExecuteNonQuery();
con.Close();

b = true;

这行:

com.Parameters.Add("@name", SqlDbType.TinyInt).Value = this.phone;
  1. 您试图将电话对象传递给name参数。
  2. 您使用tinyint,则varchar(10)是一个更好的选择,但是如果您坚持使用整数,则int64就足够了。
  3. 如果使用int来确保仅传递数字,请使用“ [0-9] {10}”对字符串进行正则表达式检查

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM