By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
458,001 Members | 1,222 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 458,001 IT Pros & Developers. It's quick & easy.

Insert Error:System.Data.NoNullAllowedException

P: n/a
I've used VS2003 Wizard to create sqlDataAdapter, stored procedures, and
dataset on my application. I can search and update fine but Insert has error
unless I perform a search or update prior to my insert. Any ideas on how to
work around this without rewriting the database?

Code Snippet ================================================== ===

static void Main()
{
Application.Run(new Form1());
}

private void menuItem2_Click(object sender, System.EventArgs e)
{
//Initialize Staff Physician Screen
SetupStaffPhysician();
menuItem2.Enabled = false;
}

private void menuItem3_Click(object sender, System.EventArgs e)
{
//Exit Application
Application.Exit();
}
private void SetupStaffPhysician()
{
panel1.Visible = true;
this.comboBox1.DataBindings.Add(new
System.Windows.Forms.Binding("SelectedIndex", this.dsStaffPhysicians1,
"tblStaffPhysicians.docLicenseState"));
}
private void ClearStaffPhysicians()
{
textBox1.Text = "";
textBox2.Text = "";
textBox3.Text = "";
textBox4.Text = "";
textBox5.Text = "";
comboBox1.SelectedIndex = 0;
}

private void btnSearch_Click(object sender, System.EventArgs e)
{
sqlDataAdapter1.SelectCommand.Parameters["@Param2"].Value = textBox3.Text;
dsStaffPhysicians1.Clear();
sqlDataAdapter1.Fill(dsStaffPhysicians1);
}

private void btnReset_Click(object sender, System.EventArgs e)
{
this.dsStaffPhysicians1.Clear();
ClearStaffPhysicians();
}

private void btnUpdate_Click(object sender, System.EventArgs e)
{
this.BindingContext[dsStaffPhysicians1,
"tblStaffPhysicians"].EndCurrentEdit();
sqlDataAdapter1.Update(dsStaffPhysicians1);
sqlDataAdapter1.Fill(dsStaffPhysicians1);
}

private void btnInsert_Click(object sender, System.EventArgs e)
{
//Get error here
this.BindingContext[dsStaffPhysicians1, "tblStaffPhysicians"].AddNew();
ClearStaffPhysicians();
}

private void btnCommit_Click(object sender, System.EventArgs e)
{

this.BindingContext[dsStaffPhysicians1,
"tblStaffPhysicians"].EndCurrentEdit();
sqlDataAdapter1.Update(dsStaffPhysicians1);
}
}
}

Nov 17 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.