I have a groupbox and inside I have a few dropdown menus. I have 2 radio buttons (one is to add an entry to the gridview and the other is to update an existing entry to the gridview). I have a save button that commits the changes to the sqlexpress database.
I am not sure base on what i have selected from the drop down menus how to commit the changes to the database. NOTE: I am new doing this.
Any ideas or code that has been done?
Loading
David MontesPosted Mar 5, 2010, 7:55 PM
David
theLizardPosted Mar 5, 2010, 7:39 PM
I have had a look at your code, unfortunately, I have not and will not use third party data bound controls in any of my sql work (Except those that I have written my self) I have always found them to be lacking in functionality with my requirements.
I generally do things manually with a framework I have developed which allows me to maintain SQL databases just as easily as having data bound controls but with full control over all aspects of record handling.
Simplistically, in my case I would do this (within my frame work class)
System.Data.SqlClient.SqlConnection objCon;
objCon = new System.Data.SqlClient.SqlConnection();
objCon.ConnectionString = @"Data Source=.\SQLEXPRESS;Initial Catalog = EmployeeProjects; Integrated Security=True;";
objCon.Open();
then depending on editmode
switch(editmode)
{
case 1:
string sql = "INSERT INTO table (field,field,field) values(@a, @b, @c)"
break;
case 2:
string sql = "UPDATE table SET field1=@a,field2=@b,field3=@c WHERE id = id of record being edited"
break;
}
try
{
objCon.Parameters.AddWithValueS("a", value);
objCon.Parameters.AddWithValueS("b", value);
objCon.Parameters.AddWithValueS("c", value);
objCon.CommandText = sql;
objCon.ExecuteNonQuery();
}
catch(Exception e)
{
}
This is my preferred way of SQL management, there are people on this forum who would be able to assist you with the data bound controls way of doing the same.
Sorry I cant help you any further than this,
Good luck.
David MontesPosted Mar 5, 2010, 6:42 PM
theLizardPosted Mar 5, 2010, 5:34 PM