Hello guys. I hope you can help me with this problem. I have created a table (office) with two fields: id and location. Id is set to autonumber. I want to fill the table through a form which displays the id and takes the location. The program works fine but it doesnt add the location I enter to the table. It just enters a new row with the incremented id but with an empty field for the location. Also the id doesnt increment when i press the button. It stays all the time one. Help me please :(.
private void button1_Click(object sender, EventArgs e)
{
try
{
this.OfficeTableAdapter.Fill(this.dobDataSet.Office);
this.OfficeTableAdapter.FillByROLocation(this.textBox2.Text.ToString());
this.Validate();
this.OfficeBindingSource.EndEdit();
this.OfficeTableAdapter.Update(this.dobDataSet.Office);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Regional Office", MessageBoxButtons.OK, MessageBoxIcon.Stop);
}
}
The sql query for FillByROLocation is
INSERT INTO [dbo].[Regional_Office] ([RO_Location]) VALUES (@RO_Location);
SELECT RO_ID, RO_Location FROM Regional_Office WHERE (RO_ID = SCOPE_IDENTITY())