G
Guest
I am using sql server, Visual Studio .NET and C#. My application uses windows
forms. The form that I am having a problem with has some text boxes and a
data grid. There are two sql tables (i.e task and task-details) each table
has the same primary key (service-order-number). The problem is I get a sql
message "Column "service-order-number" does not allow nulls". To the bust of
my knowledge I have not tried to write to the database yet. I am new at this
and need some help please!!!!
PS: there is a demo in the ADO.NET Visual.NET C# Chapter13, WinApps (09 -
Chield Form) that does what I am trying to do. This might help. Thanks
***** The code that crashes is:
public void EditDetail(CurrencyManager cm)
{
drvDetail = (DataRowView) cm.Current;
vueDetail = drvDetail.DataView;
this.BindingContext[vueDetail].Position = cm.Position;
***** This code setup the datagrid:
private void FormatTaskGrid()
{
DataGridTableStyle tbl = new DataGridTableStyle();
tbl.MappingName = "task-details";
DataGridTextBoxColumn col;
col = new DataGridTextBoxColumn();
col.MappingName = "taskid";
col.HeaderText = "Task ID";
col.Alignment = HorizontalAlignment.Center;
col.Width = 60;
tbl.GridColumnStyles.Add(col);
col = new DataGridTextBoxColumn();
col.MappingName = "task-desc";
col.HeaderText = "Service Description";
col.Alignment = HorizontalAlignment.Center;
col.Width = 70;
tbl.GridColumnStyles.Add(col);
col = new DataGridTextBoxColumn();
col.MappingName = "complete-date";
col.HeaderText = "Completion Date";
col.Alignment = HorizontalAlignment.Center;
col.Width = 80;
tbl.GridColumnStyles.Add(col);
col = new DataGridTextBoxColumn();
col.MappingName = "task-cost";
col.HeaderText = "Service Cost";
col.Alignment = HorizontalAlignment.Right;
col.Width = 90;
tbl.GridColumnStyles.Add(col);
grdTasks.TableStyles.Add(tbl);
}
***** and this is the code that calls the program that crashes *****
cmDetails.AddNew();
TaskDetail TaskDetail = new TaskDetail(snum, tnum, asize);
TaskDetail.EditDetail(cmDetails);
TaskDetail.Dispose();
forms. The form that I am having a problem with has some text boxes and a
data grid. There are two sql tables (i.e task and task-details) each table
has the same primary key (service-order-number). The problem is I get a sql
message "Column "service-order-number" does not allow nulls". To the bust of
my knowledge I have not tried to write to the database yet. I am new at this
and need some help please!!!!
PS: there is a demo in the ADO.NET Visual.NET C# Chapter13, WinApps (09 -
Chield Form) that does what I am trying to do. This might help. Thanks
***** The code that crashes is:
public void EditDetail(CurrencyManager cm)
{
drvDetail = (DataRowView) cm.Current;
vueDetail = drvDetail.DataView;
this.BindingContext[vueDetail].Position = cm.Position;
***** This code setup the datagrid:
private void FormatTaskGrid()
{
DataGridTableStyle tbl = new DataGridTableStyle();
tbl.MappingName = "task-details";
DataGridTextBoxColumn col;
col = new DataGridTextBoxColumn();
col.MappingName = "taskid";
col.HeaderText = "Task ID";
col.Alignment = HorizontalAlignment.Center;
col.Width = 60;
tbl.GridColumnStyles.Add(col);
col = new DataGridTextBoxColumn();
col.MappingName = "task-desc";
col.HeaderText = "Service Description";
col.Alignment = HorizontalAlignment.Center;
col.Width = 70;
tbl.GridColumnStyles.Add(col);
col = new DataGridTextBoxColumn();
col.MappingName = "complete-date";
col.HeaderText = "Completion Date";
col.Alignment = HorizontalAlignment.Center;
col.Width = 80;
tbl.GridColumnStyles.Add(col);
col = new DataGridTextBoxColumn();
col.MappingName = "task-cost";
col.HeaderText = "Service Cost";
col.Alignment = HorizontalAlignment.Right;
col.Width = 90;
tbl.GridColumnStyles.Add(col);
grdTasks.TableStyles.Add(tbl);
}
***** and this is the code that calls the program that crashes *****
cmDetails.AddNew();
TaskDetail TaskDetail = new TaskDetail(snum, tnum, asize);
TaskDetail.EditDetail(cmDetails);
TaskDetail.Dispose();