簡體   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