Click here to Skip to main content
15,913,339 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
here is the firebird code
public bool InsertNewCarsFees(structNewCarFees ncf)
		{
			fbConnection.Open();
			FbCommand fbCommand = ncf.CreateInsertCommand();
			fbCommand.Connection = fbConnection;
			try
			{
				fbCommand.ExecuteNonQuery();
				NewCarFees.Add(ncf);
				fbCommand.Dispose();
				fbCommand = null;
				fbConnection.Close();
				return true;
			}
			catch
			{
				fbCommand.Dispose();
				fbConnection.Close();
				return false;
			}
		}


What I have tried:

I am new to C# and MySql- still learning

public bool InsertNewCarsFees(StructNewCarFees ncf)
      {

          qmConnection.Open();
          MySqlCommand cmd = ncf.CreateInsertCommand();
          cmd.Connection = qmConnection;
          try
          {
             cmd.ExecuteNonQuery();
              newCarFees.Add(ncf);
              cmd.Dispose();
              cmd = null;
              qmConnection.Close();
              return true;
          }
          catch
          {
             cmd.Dispose();
              qmConnection.Close();
              return false;
          }
      }

This is the error message relating to ncf.CreateInsertCommand

Severity	Code	Description	Project	File	Line	Suppression State
Error	CS7036	There is no argument given that corresponds to the required formal parameter 'qmConnection' of 'StructNewCarFees.CreateInsertCommand(MySqlConnection)'	QMData	C:\Users\quote\Documents\QM Online App\QMData\ClassQM.cs	125	Active
Posted
Updated 30-Oct-19 9:37am

I think you cannot use ncf.CreateInsertCommand for MySQL, take a look at the answer here: C# how to insert data to mysql using C#? - Stack Overflow[^]
 
Share this answer
 
Your CreateInsertCommand method requires a parameter of type MySqlConnection. It looks like you have one hanging about:
C#
qmConnection.Open();
MySqlCommand cmd = ncf.CreateInsertCommand(qmConnection);
Depending on the implementation of that method, you might not need to set the cmd.Connection property on the following line.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900