简体   繁体   English

插入错误 system.format.exception vb.net

[英]insert error system.format.exception vb.net

At my software, a error just surfaced, it was working, but I get the following error when running the insert command.在我的软件中,一个错误刚刚出现,它正在工作,但在运行插入命令时出现以下错误。 I'm using VB.NET with MySQL.我在 MySQL 中使用 VB.NET。

Error message:错误信息:

{System.FormatException: Cadeia de caracteres de entrada com formato incorrecto.
   em System.Number.StringToNumber(String str, NumberStyles options, NumberBuffer& number, NumberFormatInfo info, Boolean parseDecimal)
   em System.Number.ParseUInt64(String value, NumberStyles options, NumberFormatInfo numfmt)
   em System.String.System.IConvertible.ToUInt64(IFormatProvider provider)
   em MySql.Data.Types.MySqlBit.WriteValue(MySqlPacket packet, Boolean binary, Object value, Int32 length)
   em MySql.Data.MySqlClient.MySqlParameter.Serialize(MySqlPacket packet, Boolean binary, MySqlConnectionStringBuilder settings)
   em MySql.Data.MySqlClient.Statement.SerializeParameter(MySqlParameterCollection parameters, MySqlPacket packet, String parmName, Int32 parameterIndex)
   em MySql.Data.MySqlClient.Statement.InternalBindParameters(String sql, MySqlParameterCollection parameters, MySqlPacket packet)
   em MySql.Data.MySqlClient.Statement.BindParameters()
   em MySql.Data.MySqlClient.Statement.Execute()
   em MySql.Data.MySqlClient.PreparableStatement.Execute()
   em MySql.Data.MySqlClient.MySqlCommand.ExecuteReader(CommandBehavior behavior)
   em MySql.Data.MySqlClient.MySqlCommand.ExecuteReader()
   em MySql.Data.MySqlClient.MySqlCommand.ExecuteNonQuery()
   em BARCOSEGUR.uccbarcosegurDataSetTableAdapters.suspeitaTableAdapter.Insert(String p1, Nullable`1 p2, String p3, Object p4, Object p5, Object p6, Object p7) em C:\Users\g1960931\Documents\Visual Studio 2012\Projects\BARCOSEGUR\BARCOSEGUR\uccbarcosegurDataSet.Designer.vb:line 25533
   em BARCOSEGUR.Vigilância.Button1_Click(Object sender, EventArgs e) em C:\Users\g1960931\Documents\Visual Studio 2012\Projects\BARCOSEGUR\BARCOSEGUR\Vigilância.vb:line 104}

When I run the insert query directly from the data designer, it works fine, so I think the problem is not at insert query当我直接从数据设计器运行插入查询时,它工作正常,所以我认为问题不在于插入查询

This is my insert query:这是我的插入查询:

INSERT INTO suspeita (idembarcacao, suspeita_desde, colocada_por, opcao1, opcao2, opcao3, opcao4) VALUES (@p1, @p2, @p3, @p4, @p5, @p6, @p7)

If run from dataset it inserts without a problem.如果从数据集运行它插入没有问题。

This is my code:这是我的代码:

Dim dt As Date
dt = System.DateTime.Today
dt.ToString("yyyy'-'MM'-'dd")
Me.SuspeitaTableAdapter.Insert(tst, dt, util, op1, op2, op3, op4) 
Me.SuspeitaTableAdapter.Update(Me.UccbarcosegurDataSet.suspeita) 

Variable Types变量类型

 1. tst = string
 2. dt = date
 3. util = string
 4. op1,op2,op3 = integer
 5. op4 = string

Table is created as follows表创建如下

 1. idembarcacao = varchar(11)
 2. suspeita_desde = date
 3. colocada_por = varchar(45)
 4. opcao1 = int(11)
 5. opcao2 = int(11)
 6. opcao3 = int(11)
 7. opcao4 = varchar(85)

Can someone please help me.有人可以帮帮我吗。 I'm lost.我迷路了。

Sometimes ago, I had the same problem.有时,我也遇到了同样的问题。 In my case, the solution was, to add Convert Zero Datetime=True to the connection string.就我而言,解决方案是将Convert Zero Datetime=True添加到连接字符串中。

I thanks to all of you for your help.我感谢你们所有人的帮助。 Solved the problem, with a simple action, deleted the insert query at the dataset and recreated the same.通过一个简单的操作解决了问题,删除了数据集中的插入查询并重新创建了相同的查询。 The problem that i mencioned above with the object, disapeared and everything is working like a charm.我在上面提到的对象的问题消失了,一切都像魅力一样工作。 THANK YOU ALL, you're all the best.谢谢大家,你们都是最棒的。

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

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