Question: I am currently trying to complete a transaction for a web based app, however;

```
Procedure or function 'completeTransaction' expects parameter '@dateTime', which was not supplied.

```

Here is copy of the function.

```
public static void completeTransaction(string storeCode, string employeeId, DateTime Date, string itemListNoId)
{
    using (SqlConnection conn = new SqlConnection("Data Source = ; Initial Catalog =Business ; Integrated Security = true;"))
    {
        using (SqlCommand command = new SqlCommand("dbo.completeTransaction", conn))
        {
            command.CommandType = CommandType.StoredProcedure;
            command.Parameters.Add("@storeCode", SqlDbType.Int).Value = storeCode;
            command.Parameters.Add("@employeeId", SqlDbType.Int).Value = employeeId;
            **command.Parameters.Add("@Date", SqlDbType.DateTime).Value = Date;**
            command.Parameters.Add("@itemListNoId", SqlDbType.Int).Value = itemListNoId;
            conn.Open();

            command.ExecuteNonQuery();
            conn.Close();
        }
    }
}

```

My sql table contains the following tables and types (storeCode, INT, employee, INT, Date, DATETIME, itemListNoId, INT)

Answer: 
If you are getting this and you have passed in the correctly named parameter, check that the CommandType is set to Stored procedure 

```
cmd.CommandType = CommandType.StoredProcedure;  

```

I was seeing these same symptoms spent an embarrassingly long time tracking down how each parameter was getting to the stored proc.
As previous answers have correctly mentioned, most probable reasons for this error are either forgetting to add parameter(s) to the `SqlCommand` or forgetting to set command's type to `CommandType.StoredProcedure`

In case you have already set above correctly and still pulling your hair, then this might be the reason.

If you set parameters value to `null` (e.g. `mySQLParam1.Value = valuePassedToMe` and if `valuePassedToMe` is `null`) then you will get the same error (i.e. *Procedure or function '...' expects parameter '...', which was not supplied*).

This can be solved by assigning `DBNull.Value` when the value needs to be `null`

i.e.

```
mySQLParam1.Value = valuePassedToMe ?? (object)DBNull.Value;

```

---

When you assign `null` to a parameter ADO.Net converts it to `default`. Below is an example from SQL Server Profiler.

```
exec dbo.MyStoredProcedure @mySQLParam1=default,@mySQLParam2=default,@mySQLParam3=default,...

```

When you assign DBNull.Value the generated SQL becomes:

```
exec dbo.MyStoredProcedure @mySQLParam1=NULL,@mySQLParam2=NULL,@mySQLParam3=NULL,...

```