Hi all!
I'm a newbie to C# and .NET and I'm playing around in Visual C# 2005
Express Edition. I tried to use the wizards to create a table in SQL
2005 Express Ed. and displaying that data in a grid in a form I created
in C#. I have got almost everything correct, except I have two issues.
The first one is that I'm not able to store the data I add in my grid
to the SQL database. When I close the application and open it again,
the data is gone. I have a save button in my form that I would like to
use in order for the data to be inserted/updated in SQL. I can see that
the INSERT/UPDATE/DELETE scripts are created automatically, and the
clicked-method on my save button looks like this:
---------------------------------------------------------------------------------------------------------------------------------------
private void custBindingNavigatorSaveItem_Click(object sender,
EventArgs e)
{
this.Validate();
this.custBindingSource.EndEdit();
this.custTableAdapter.Update(this.customerDataSet. Cust);
}
---------------------------------------------------------------------------------------------------------------------------------------
So it looks like it should update the data I put in the grid, but it
doesn't.
My next problem is that I would like to have a unique identifier for
all the records in this table and I would like that to be created in
the database. I tried to create an Id-field and use the
uniqueidentifier-datatype. I set it to not allow null-values and I set
it to be a GUID (the field is even using a function called newid(), but
when I create a record, it does't create this id. Maybe it's just
because I'm unable to store the data in my SQL database....
Any ideas solving my problems are rewarded with my "Hero of the day"
award. :)