473,835 Members | 1,813 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Error:System.Da ta.NoNullAllowe dException on non-null column

Getting error on insert when I try to add a new row to a dataset; used Visual
Studio IDE to generate stored procedures, data adapter, and dataset. Table
on SQL server has a column marked non-null. The code that I wrote is
included below.
static void Main()
{
Application.Run (new Form1());
}

private void btnSearch_Click (object sender, System.EventArg s e)
{
sqlDataAdapter1 .SelectCommand. Parameters["@Param2"].Value =
txtBoxSPSearch. Text;
dsStaffPhysicia ns1.Clear();
sqlDataAdapter1 .Fill(dsStaffPh ysicians1);
}

private void btnReset_Click( object sender, System.EventArg s e)
{
this.dsStaffPhy sicians1.Clear( );
ClearStaffPhysi cian();
}
private void SetupStaffPhysi cian()
{ //Initialize Staff Physician Page
panel1.Visible = true;
this.cBoxSPLice nseState.DataBi ndings.Add(new
System.Windows. Forms.Binding(" SelectedIndex", this.dsStaffPhy sicians1,
"tblStaffPhysic ians.docLicense State"));
}

private void ClearStaffPhysi cian()
{ //Clears textboxes and dropdowns
txtBoxSPFirstNa me.Text = "";
txtBoxSPMiddleN ame.Text = "";
txtBoxSPLastNam e.Text = "";
txtBoxSPUpin.Te xt = "";
txtBoxSPLicense Number.Text = "";
txtBoxSPSearch. Text = "";
cBoxSPLicenseSt ate.SelectedInd ex = 0;
}

private void menuItem2_Click (object sender, System.EventArg s e)
{ //Main menu -- Staff Physicians
SetupStaffPhysi cian();
menuItem2.Enabl ed = false;
}

private void btnUpdate_Click (object sender, System.EventArg s e)
{
this.BindingCon text[dsStaffPhysicia ns1,
"tblStaffPhysic ians"].EndCurrentEdit ();
sqlDataAdapter1 .Update(dsStaff Physicians1);
sqlDataAdapter1 .Fill(dsStaffPh ysicians1);
}

private void btnInsert_Click (object sender, System.EventArg s e)
{
//Generates Error:System.Da ta.NoNullAllowe dException
//Column 'docLName' does not allow nulls.
this.BindingCon text[dsStaffPhysicia ns1, "tblStaffPhysic ians"].AddNew();
ClearStaffPhysi cian();
this.btnInsert. Text = "Inserted";
}

private void menuItem3_Click (object sender, System.EventArg s e)
{
Application.Exi t();
}

private void btnCommit_Click (object sender, System.EventArg s e)
{
//Need to do something here
}
}
}

Nov 17 '05 #1
0 1434

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
3564
by: Vincento Harris | last post by:
Anyone knows what would cause this?When Enterprise Manager is used to open a table Runtime error data provider or other service provided an efail status
0
1833
by: Martyn Wynne | last post by:
Hi, Can anyone please tell me if there is any reason why when i am streaming from a webrequest (decompressing on route) to a file on the hard drive, i would be getting an exception of Filestream error System.StackOverflowException every time the file gets to 8580Kbs. Code is basically a modified Microsoft example, it errors on the line Dim ar As IAsyncResult = _
0
1248
by: Rich | last post by:
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());
5
1601
by: Patrick.O.Ige | last post by:
What could cause the error:- System.NullReferenceException: Object reference not set to an instance of an object. Any ideas?
2
10918
by: Simon Harris | last post by:
I have created a web service, which when I call in my browser presents the text form etc. When I click the button, I get this error: System.ArgumentException: Cannot convert to System.Int32. Parameter name: type ---> System.FormatException: Input string was not in a correct format. at System.Number.ParseInt32(String s, NumberStyles style, NumberFormatInfo info) at System.String.System.IConvertible.ToInt32(IFormatProvider provider)
0
1239
by: Etienne | last post by:
I'm using DotNetNuke 3.1 and it works well. I try to use Ajax with it. But if I add the Ajax specification in web.config : <add verb="GET,POST" path="vbwrapper/*.ashx" type="Ajax.PageHandlerFactory, Ajax" /> I receive the error : System.Security.SecurityException: Request for the permission of type System.Security.Permissions.ReflectionPermission, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 failed. If...
3
5269
by: Dan | last post by:
Hi, I'm learning asp.net 2.0 and i get this error: "Data source is an invalid type. It must be either an IListSource, IEnumerable, or IDataSource" My code: Dim a As GridView Dim oConnection As OleDbConnection oConnection = New OleDbConnection()
3
2040
by: vishwaskothari | last post by:
What is wrong in the following Statement? Dim mydate As Date Format(mydate, "m/d/yy") rs.Open "SELECT * from accounts where date='" & mydate & "';", con, adOpenStatic, adLockOptimistic
0
1576
by: amuven | last post by:
Hi All, I have created xls using pyExcelerator. when i tried to open that xls sheet i'm getting this error message "File error: data may have been lost " , Please some one help me how to rectify the above. my code is : def fnwrite(Dictionary): font0 = Font() font0.name = 'Verdana' font0.bold = True font0.colour_index = 2
10
10513
by: muby | last post by:
Hi Everybody the compiler throws an error when it runs this function in my code, I couldn't figure out what is wrong with my code, please assist me, thanks :). void SMAC::IncreaseCW() { init rI=2; DATA_CW=DATA_CW*rI; double cw = (Random::random() % DATA_CW) * slotTime_sec_; mhCS_.sched(CLKTICK2SEC(difs_) + cw);
0
9810
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9653
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10815
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10526
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10563
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
5640
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4435
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3999
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3094
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.