Insert Firebird Database C#

前端 未结 2 569
眼角桃花
眼角桃花 2021-01-24 09:38
FbCommand fbCmm = 
      new FbCommand(\"INSERT INTO PRODUTO
                   (CODIGO,EAN,DESCRICAO,VAL_PRODUTO,VAL_CUSTO,CAT_PRECO)\" 
                   + \"Values (         


        
相关标签:
2条回答
  • 2021-01-24 10:10

    You should use quote for decimal, string field types, your statement is correct but not clear, you can create clear sql text with sql command builder or you can use Command object of your connection.

    0 讨论(0)
  • 2021-01-24 10:20

    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();
    

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

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

    0 讨论(0)
提交回复
热议问题