473,976 Members | 55,414 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Insert Error:System.Da ta.NoNullAllowe dException

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.EventArg s e)
{
//Initialize Staff Physician Screen
SetupStaffPhysi cian();
menuItem2.Enabl ed = false;
}

private void menuItem3_Click (object sender, System.EventArg s e)
{
//Exit Application
Application.Exi t();
}
private void SetupStaffPhysi cian()
{
panel1.Visible = true;
this.comboBox1. DataBindings.Ad d(new
System.Windows. Forms.Binding(" SelectedIndex", this.dsStaffPhy sicians1,
"tblStaffPhysic ians.docLicense State"));
}
private void ClearStaffPhysi cians()
{
textBox1.Text = "";
textBox2.Text = "";
textBox3.Text = "";
textBox4.Text = "";
textBox5.Text = "";
comboBox1.Selec tedIndex = 0;
}

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

private void btnReset_Click( object sender, System.EventArg s e)
{
this.dsStaffPhy sicians1.Clear( );
ClearStaffPhysi cians();
}

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)
{
//Get error here
this.BindingCon text[dsStaffPhysicia ns1, "tblStaffPhysic ians"].AddNew();
ClearStaffPhysi cians();
}

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

this.BindingCon text[dsStaffPhysicia ns1,
"tblStaffPhysic ians"].EndCurrentEdit ();
sqlDataAdapter1 .Update(dsStaff Physicians1);
}
}
}

Nov 17 '05 #1
0 1261

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

Similar topics

2
4218
by: Tavish Muldoon | last post by:
What a pain trying to insert data into a table from a stored proc. My webform asks for 16 pieces of data - which then gets written to the database. I found this easier than the crap below (after the ***********). This was eaiser: get a list of all the parameters you want to pass - put them in a string:
0
1844
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 = _
9
6599
by: Hi5 | last post by:
Hi, Any Idea how, I can make an Insert statement to insert data into 6 different tables, that are all holding all data of my database? Is there any example? I would be grateful if you could let me know of the ways to view data in a query and then add data to database
1
1886
by: kudeep | last post by:
Hi everyone i m new here. I have made an web application where user enter message and clicks on the SUBMIT button. Clickin on the SUBMIT button will execute a INSERT statement. Program works fine but if a user enters data with quotation marks in the text box i.e. "welcome to joe's world.", an error is displayed since there is a single quotation mark in the text box joe's .
0
10554
by: Mamatha | last post by:
Hi When i clicked a button, i want to insert data from listview in VB.NET to Excel sheet. If you know the solution either above or below is ok for me. I know how to insert from a textfile,but all data of textfile inserted into only into a single cell.I want to insert single line of text file for each cell. I tried to insert data into Excel sheet in many ways but
6
2124
by: VitaminB | last post by:
Hi Guys, I try to insert data from a form into a mysql database, but it did not work... There is no error, but the data did not pass thru the table. This is the short script:
7
33060
by: girl | last post by:
Hi i have a problem with MS SQL server 2000 and hope to seek for some advise. i have the following samples aa|0|abcdefg| b|0|abcdefg| i used the bulk insert in the query analyser.. BULK INSERT adl_ntid from 'C:/abc.unl with
4
3276
by: gauravdua | last post by:
hello plz tell me how can i insert data into different views throgh oracle forms. actually i had made form on purchase order using po_headers_v po_distributions_v po_lines_v it execute properly, but when i try to insert new data into it it's gives error "cannot modify a column which maps to a non key-preserved table".
8
6639
by: Betikci Boris | last post by:
Can not insert data into SQLite3 database through browser however i can easily insert data into my db from konsole, in both attmpts i used php 5.2.6 on 2.6.25.* linux kernel i think there is a problem with my php setup but i could not find it... here is the code; ---------------------------------------------------------------------------------------- $db = new PDO("sqlite:bar.db");
0
2749
by: akshalika | last post by:
I am new to Biztalk. In my project we need to connect oracle database and insert data into oracle table using BizTalk project. I use WCF Adapter pack(SP2). I create biztalk project then using Consume Adapter Service Add-in create schemas to insert data into oracle database and tow-way send port binding file Then create orchestration and logical receive port send port, Request-response port then after correctly connect those port with message...
0
10349
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
10163
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
11812
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
11405
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...
0
10903
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
8454
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
7601
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
5149
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
4728
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.