插入Firebird数据库C# [英] Insert Firebird Database C#

查看:131
本文介绍了插入Firebird数据库C#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

FbCommand fbCmm = 
      new FbCommand("INSERT INTO PRODUTO
                   (CODIGO,EAN,DESCRICAO,VAL_PRODUTO,VAL_CUSTO,CAT_PRECO)" 
                   + "Values (@txt_codigo.Text, @txt_ean, @txt_descricao,
                   @txt_valPro, @txt_valCus, @txt_catPre)", ConexaoFirebird.Conexao);

那句话怎么了? 我在其他课程中做过开放式连接-ConexaoFirebird.Conexao();

What's wrong with that sentence? I did a open connection in other class - ConexaoFirebird.Conexao();

推荐答案

您正在执行参数化查询,而没有提供这些参数的值.请参见文档:

You're executing a parameterized query without providing values for those parameters. See the documentation:

FbCommand cmd = new FbCommand("insert into t1(id, text) values (@id, @text);");
cmd.CommandType = CommandType.Text;

cmd.Parameters.Add("@id", 123);
cmd.Parameters.Add("@text", "my string");

cmd.ExecuteNonQuery();

在这里,它们将值123"my string"分别绑定到名为idtext的参数.

Here they bind the values 123 and "my string" to the parameters named id and text respectively.

还要注意,参数名称通常使用字母数字,所以txt_codigo.Text不太可能起作用.

Also note that parameter names are generally rescticted to alphanumeric, so txt_codigo.Text isn't likely going to work.

这篇关于插入Firebird数据库C#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆