how do you add data to sql database using c# variables and an sql command? I have a class of employes that i use which has values identical to my sql database tables
here is the basic code of what i want to do...
SDC.DbCommand dbCmd; //database command string sql = string.Format(INSERT INTO employeeTable(EmployeeName, Salary) VALUES ('James Peter', 42000); //works but i need to convert and use the employee class values like i did below employee newEmployee = new Employee("James Peter", 4200); string sql = string.Format(INSERT INTO employeeTable(EmployeeName, Salary) VALUES ('newEmployee.EmployeeName', newEmployee.Salary); dbCmd.CommandText = sql;
How should i go about doing this? should i use a substring or is there a SQl command
i could use to make things much easier.
i keep getting an error saying my index is invalid but shouldnt my id number be automatically assigned?