本文介绍了C#/SQL:输入字符串的格式不正确的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我尝试了所有可能性,我写了'comm .Parameters.Add("@ facultate",C1.Text); ',并给我相同的错误 ..我不明白为什么..以及如果我尝试调试并确切查看它具有什么值并停在行"
comm.Parameters.Add(new SqlParameter("@ numar",SqlDbType .Int){值= int.Parse(T9.Text)});他在这里停下来给我:1.盖弦时 到datetime,在将每个变量放入datetime对象之前解析要采取的字符串... 2.确保方法参数的格式正确. "我可以将所有内容发送给整个项目.
PS. :我从FORM DataTimePiker获取日期..
comm.Parameters.Add(新SqlParameter("@ facultate",SqlDbType.VarChar){值= C1.Text}); comm.Parameters.Add(new SqlParameter("@ domeniul",SqlDbType.VarChar){值= T1.Text}); comm.Parameters.Add(new SqlParameter("@ specializare",SqlDbType.VarChar){值= T2.Text}); comm.Parameters.Add(new SqlParameter("@ forma_invatamant",SqlDbType.VarChar){值= C2.Text}); comm.Parameters.Add(new SqlParameter("@ d_inscriere",SqlDbType.DateTime){Value = DTP1.Value.ToString("MM/dd/yyyy")});; comm.Parameters.Add(new SqlParameter("@ nume_prenume",SqlDbType.VarChar){值= T3.Text}); comm.Parameters.Add(new SqlParameter("@ cod",SqlDbType.VarChar){Value = T4.Text}); comm.Parameters.Add(new SqlParameter("@ localitate",SqlDbType.VarChar){值= T5.Text}); comm.Parameters.Add(new SqlParameter("@ judet",SqlDbType.VarChar){值= T6.Text}); comm.Parameters.Add(new SqlParameter("@ tara",SqlDbType.VarChar){值= T7.Text}); comm.Parameters.Add(new SqlParameter("@ strada",SqlDbType.VarChar){值= T8.Text}); comm.Parameters.Add(new SqlParameter("@ numar",SqlDbType.Int){值= int.Parse(T9.Text)}); comm.Parameters.Add(new SqlParameter("@ bloc",SqlDbType.VarChar){值= T10.Text}); comm.Parameters.Add(new SqlParameter("@ scara",SqlDbType.VarChar){值= int.Parse(T11.Text)}); comm.Parameters.Add(new SqlParameter("@ etaj",SqlDbType.Int){值= int.Parse(T12.Text)}); comm.Parameters.Add(new SqlParameter("@ apartament",SqlDbType.Int){Value = int.Parse(T3.Text)}); comm.Parameters.Add(new SqlParameter("@ sector",SqlDbType.VarChar){Value = T14.Text}); comm.Parameters.Add(new SqlParameter("@ cod_p",SqlDbType.Int){Value = int.Parse(T15.Text)}); comm.Parameters.Add(new SqlParameter("@ data_nasterii",SqlDbType.DateTime){Value = DTP2.Value.ToString("MM/dd/yyyy")});; comm.Parameters.Add(new SqlParameter("@ locul_nasterii",SqlDbType.VarChar){值= T16.Text}); comm.Parameters.Add(new SqlParameter("@ judet_n",SqlDbType.VarChar){值= T17.Text}); comm.Parameters.Add(new SqlParameter("@ tara_n",SqlDbType.VarChar){值= T18.Text}); comm.Parameters.Add(new SqlParameter("@ sex",SqlDbType.VarChar){值= C3.Text}); comm.Parameters.Add(new SqlParameter("@ stare_civila",SqlDbType.VarChar){值= C4.Text}); comm.Parameters.Add(new SqlParameter("@ cetatenie",SqlDbType.VarChar){值= C5.Text}); comm.Parameters.Add(new SqlParameter("@ cetatenie_op",SqlDbType.Int){Value = int.Parse(T19.Text)}); comm.Parameters.Add(new SqlParameter("@ etnie",SqlDbType.VarChar){值= T20.Text}); comm.Parameters.Add(new SqlParameter("@ incadrare",SqlDbType.VarChar){值= C6.Text}); comm.Parameters.Add(new SqlParameter("@ cnp",SqlDbType.Int){值= int.Parse(T21.Text)}); comm.Parameters.Add(new SqlParameter("@ serie",SqlDbType.VarChar){值= T22.Text}); comm.Parameters.Add(new SqlParameter("@ numar_cnp",SqlDbType.Int){值= T23.Text}); comm.Parameters.Add(new SqlParameter("@ eliberat",SqlDbType.VarChar){值= T24.Text}); comm.Parameters.Add(new SqlParameter("@ e_data",SqlDbType.DateTime){Value = DTP3.Value.ToString("MM/dd/yyyy")});; comm.Parameters.Add(new SqlParameter("@ studii_preuni",SqlDbType.VarChar){值= C7.Text}); comm.Parameters.Add(new SqlParameter("@ nume_unitate",SqlDbType.VarChar){值= T25.Text}); comm.Parameters.Add(new SqlParameter("@ spec_fili_profil",SqlDbType.VarChar){值= T26.Text}); comm.Parameters.Add(new SqlParameter("@ oras_s",SqlDbType.VarChar){值= T27.Text}); comm.Parameters.Add(new SqlParameter("@ judet_s",SqlDbType.VarChar){值= T28.Text}); comm.Parameters.Add(new SqlParameter("@ tara_s",SqlDbType.VarChar){值= T29.Text}); comm.Parameters.Add(new SqlParameter("@ forma_de_invatamant",SqlDbType.VarChar){值= C8.Text}); comm.Parameters.Add(new SqlParameter("@ medie_bac",SqlDbType.Decimal){值= decimal.Parse(T30.Text)}); comm.Parameters.Add(new SqlParameter("@ durata_studii",SqlDbType.Int){Value = int.Parse(C9.Text)}); comm.Parameters.Add(new SqlParameter("@ data_absolvirii",SqlDbType.DateTime){Value = DTP4.Value.ToString("MM/dd/yyyy")});; comm.Parameters.Add(new SqlParameter("@ tipul_diploma",SqlDbType.VarChar){值= C10.Text}); comm.Parameters.Add(new SqlParameter("@ serie_diploma",SqlDbType.VarChar){值= T31.Text}); comm.Parameters.Add(new SqlParameter("@ numar_diploma",SqlDbType.Int){值= int.Parse(T32.Text)}); comm.Parameters.Add(new SqlParameter("@ emis_de_catre",SqlDbType.VarChar){值= T33.Text}); comm.Parameters.Add(new SqlParameter("@ data_emiterii",SqlDbType.DateTime){Value = DTP5.Value.ToString("MM/dd/yyyy")});; comm.Parameters.Add(new SqlParameter("@ nr_foi_matricole",SqlDbType.Int){值= int.Parse(T34.Text)}); comm.Parameters.Add(new SqlParameter("@ introducere_date",SqlDbType.VarChar){值= T35.Text}); comm.Parameters.Add(new SqlParameter("@ semnatura",SqlDbType.VarChar){值= T36.Text});
解决方案
这篇关于C#/SQL:输入字符串的格式不正确的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!