Inserts a record into the database using the supplied CommandConfig
Namespace:
DbNetLink.DataAssembly: DbNetLink.DbNetData (in DbNetLink.DbNetData.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
| C# |
|---|
public long ExecuteInsert( CommandConfig CmdConfig ) |
| Visual Basic (Declaration) |
|---|
Public Function ExecuteInsert ( _ CmdConfig As CommandConfig _ ) As Long |
| Visual C++ |
|---|
public: long long ExecuteInsert( CommandConfig^ CmdConfig ) |
Parameters
- CmdConfig
- Type: DbNetLink.Data..::.CommandConfig
The parameterised insert statement/table name and parameter values
Return Value
Returns the value assigned to the auto-incrementing (where applicable) column or -1
Examples
DbNetData Db = new DbNetData( ConfigurationManager.ConnectionStrings["nwind"] ); Db.Open(); CommandConfig CmdConfig = new CommandConfig("products"); // You only need to specify the table name. DbNetData will build the rest of // the insert statement automatically using the parameters CmdConfig.Params["productname"] = ProductName.Value; CmdConfig.Params["categoryid"] = CategoryID.Value; CmdConfig.Params["description"] = ProductName.Description; CmdConfig.Params["discontinued"] = 0; Db.ReturnAutoIncrementValue = true; long ProductID = Db.ExecuteInsert(CmdConfig) Db.Close();