getting the error: Cannot insert the value NULL into column 'name', table 'InterGlobe.dbo.IG_Admin'; column does not allow nulls. INSERT fails. The statement has been terminated.


<%

@ Page Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>

<

script runat="server">

 

private void CrLogin_Click(object source, EventArgs e)

{

 

try

{

//Response.Write("hello");

SqlDataSource2.Insert();

// Response.Redirect("logincreated.aspx");

}

catch(Exception ex)

{

Response.Write(ex.Message);

}

 

}

</

script>

 

 

 

<

asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">

 

 

 

&nbsp;<asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:InterGlobeConnectionString %>"

SelectCommand="SELECT * FROM [IG_Admin]"

insertcommand="INSERT INTO [IG_Admin] ([name], [buId_Fk], [userType], [alias], [pass]) VALUES (@name, @buId_Fk, @userType, @alias, @pass)" ConflictDetection="CompareAllValues" DeleteCommand="DELETE FROM [IG_Admin] WHERE [uid_Pk] = @original_uid_Pk AND [name] = @original_name AND [buId_Fk] = @original_buId_Fk AND [userType] = @original_userType AND [alias] = @original_alias AND [pass] = @original_pass" OldValuesParameterFormatString="original_{0}" UpdateCommand="UPDATE [IG_Admin] SET [name] = @name, [buId_Fk] = @buId_Fk, [userType] = @userType, [alias] = @alias, [pass] = @pass WHERE [uid_Pk] = @original_uid_Pk AND [name] = @original_name AND [buId_Fk] = @original_buId_Fk AND [userType] = @original_userType AND [alias] = @original_alias AND [pass] = @original_pass">

 

<InsertParameters>

<asp:FormParameter Name="name" FormField="txtUserName1" />

 

 

<asp:FormParameter Name="buId_Fk" FormField="DropDownList1" />

<asp:FormParameter Name="userType" FormField="txtUserType" />

<asp:FormParameter Name="alias" FormField="txtAlias" />

<asp:FormParameter Name="pass" FormField="txtPassword" />

</InsertParameters>

<DeleteParameters>

<asp:Parameter Name="original_uid_Pk" Type="Int32" />

<asp:Parameter Name="original_name" Type="String" />

<asp:Parameter Name="original_buId_Fk" Type="Int32" />

<asp:Parameter Name="original_userType" Type="String" />

<asp:Parameter Name="original_alias" Type="String" />

<asp:Parameter Name="original_pass" Type="String" />

</DeleteParameters>

<UpdateParameters>

<asp:Parameter Name="name" Type="String" />

<asp:Parameter Name="buId_Fk" Type="Int32" />

<asp:Parameter Name="userType" Type="String" />

<asp:Parameter Name="alias" Type="String" />

<asp:Parameter Name="pass" Type="String" />

<asp:Parameter Name="original_uid_Pk" Type="Int32" />

<asp:Parameter Name="original_name" Type="String" />

<asp:Parameter Name="original_buId_Fk" Type="Int32" />

<asp:Parameter Name="original_userType" Type="String" />

<asp:Parameter Name="original_alias" Type="String" />

<asp:Parameter Name="original_pass" Type="String" />

</UpdateParameters>

 

</asp:SqlDataSource>

<div>

 

<table style="width:600px">

<tr>

<td colspan="2" align="center" style="height: 21px">

<asp:Label ID="Label6" runat="server" Text="Login"></asp:Label></td>

 

</tr>

<tr>

<td style="height: 18px; width: 191px;">

<asp:Label ID="Label1" runat="server" Text="Name"></asp:Label></td>

<td style="height: 18px; width: 260px;">

<asp:TextBox ID="txtUserName1" runat="server" ></asp:TextBox>

<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="txtUserName1"

ErrorMessage="Please Enter Name"></asp:RequiredFieldValidator>

<asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" ControlToValidate="txtUserName1"

ErrorMessage="Please Enter Alphabets Only" ValidationExpression="^[a-zA-Z]+$"></asp:RegularExpressionValidator>

&nbsp;&nbsp;

</td>

</tr>

<tr>

<td style="width: 191px">

<asp:Label ID="Label2" runat="server" Text="Business Unit"></asp:Label></td>

<td style="width: 260px">

<asp:DropDownList ID="DropDownList1" runat="server" DataSourceID="SqlDataSource1"

DataTextField="buName" DataValueField="buId_PK">

</asp:DropDownList><asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:InterGlobeConnectionString %>"

SelectCommand="SELECT * FROM [IG_BU]"></asp:SqlDataSource>

</td>

</tr>

<tr>

<td style="width: 191px; height: 59px;">

<asp:Label ID="Label3" runat="server" Text="User Type"></asp:Label></td>

<td style="width: 260px; height: 59px;">

<asp:DropDownList ID="txtUserType" runat="server">

<asp:ListItem>Super Admin</asp:ListItem>

<asp:ListItem>Admin</asp:ListItem>

<asp:ListItem>Site Executive</asp:ListItem>

</asp:DropDownList>&nbsp;

</td>

</tr>

<tr>

<td style="width: 191px; height: 72px;">

<asp:Label ID="Label4" runat="server" Text="Alias"></asp:Label></td>

<td style="width: 260px; height: 72px">

<asp:TextBox ID="txtAlias" runat="server"></asp:TextBox>

<asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server" ControlToValidate="txtAlias"

ErrorMessage="Please Enter An Alias"></asp:RequiredFieldValidator>

<asp:RegularExpressionValidator ID="RegularExpressionValidator2" runat="server" ControlToValidate="txtAlias"

ErrorMessage="Please Enter A Valid Alias" ValidationExpression="^[a-zA-Z0-9]+$"></asp:RegularExpressionValidator></td>

</tr>

<tr>

<td style="width: 191px; height: 40px;">

<asp:Label ID="Label5" runat="server" Text="Password"></asp:Label></td>

<td style="height: 40px; width: 260px;">

<asp:TextBox ID="txtPassword" runat="server" OnTextChanged="txtPassword_TextChanged"></asp:TextBox>

<asp:RegularExpressionValidator ID="RegularExpressionValidator3" runat="server" ControlToValidate="txtPassword"

ErrorMessage="Please Enter A valid Password" ValidationExpression="^[a-zA-Z0-9]+$"></asp:RegularExpressionValidator>

<asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="server" ControlToValidate="txtPassword"

ErrorMessage="Please Enter A Password"></asp:RequiredFieldValidator></td>

</tr>

<tr>

<td colspan="2" align="center" style="height: 26px">

<asp:Button ID="CrLogin" runat="server" Text="Create Login" OnClick="CrLogin_Click" Visible="true" />

<asp:Button ID="UpdateLogin" runat="server" Text="Update" OnClick="UpdateLogin_Click" Visible="false" />

 

</td>

</tr>

 

<asp:TextBox ID="TxtHidden" runat="server" Visible="false"></asp:TextBox></table>

</div>

 

 

</

asp:Content>

 

0
tandon
5/16/2007 6:11:41 AM
asp.net.object-datasource 16182 articles. 0 followers. Follow

4 Replies
2986 Views

Similar Articles

[PageSpeed] 7

When you use Master Pages, your form fields get renamed. In this case, txtUserName1 would change to ctl00$ContentPlaceholder1$txtUserName1.  Apparently the SqlDataSource uses Request.Form[] to get the values instead of txtUserName1.Text.  So, you just need to change your FormParameters to read something like this:

 

<asp:FormParameter Name="name" FormField="ctl00$ContentPlaceHolder1$txtUserName1" />

 
Jimmy Trio
JimmyTrio.com
Try the Wickedater DAL Generator
0
JimmyTrio
5/17/2007 2:20:36 AM

it is not working i tried putting "ctl00$ContentPlaceHolder1$txtUserName1"

still giving the same error.

 

Should I put "ctl00" or something else???

please help

 

0
tandon
5/17/2007 1:16:46 PM

Open the page and View Source to see what the field names are.  They could be ctl01 or something.  It just depends on the controls you're using on your master page.


Jimmy Trio
JimmyTrio.com
Try the Wickedater DAL Generator
0
JimmyTrio
5/17/2007 10:12:57 PM

 

working now.thanks
0
tandon
5/18/2007 5:35:54 AM
Reply:

Similar Artilces:

Error in Tutorial DetailsView"Cannot insert the value NULL into column 'contract', table 'pubs.dbo.authors'; column does not allow nulls. INSERT fails.
Hi,I am trying to do the insert part of detail's view Tutorial (the last one) and I received this error: "Cannot insert the value NULL into column 'contract', table 'pubs.dbo.authors'; column does not allow nulls. INSERT fails.Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.Data.SqlClient.SqlException: Cannot insert the value NULL into column 'contract', table 'pubs.dbo.authors'; column does not allow nulls. INSER...

DetailsView Insert Error: Cannot insert the value NULL into column 'customer', table 'DEMO
Using VWD Express edition creates a page(Default.aspx) with a Dropdownlist for selecting a customer and a GridView to show the details of the selected customer and to edit and delect a customer's detail. I add a button to link to page Add.aspx for add a new record. I add a DetailsView and the following code so it goes to New record mode when page loads:        Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)               DetailsView1.ChangeMode(Det...

The server method 'SaveData' failed with the following error: System.Data.NoNullAllowedException: Column 'COLUMN' does not allow nulls.
Hello all, I am dabbling in client side atlas at the moment, and I'm attempting to use a strongly typed dataset with a dataservice to update and insert items into it.  Editing is working flawlessly.  I made a button that can save the data if it's changed.  My problem is in the insert.  I've been using the 1_ListOfTask.aspx example as my starting point, where I created the following:  function onCreateCourse()    {        // Get each control        var newSID = S...

Cannot insert the value NULL into column 'OrderID' -- BUT IT IS NOT NULL!
I am getting this error: "Cannot insert the value NULL into column 'OrderID', table 'outman.outman.Contact'; column does not allow nulls. INSERT fails." -- But my value is not null. I did a response.write on it and it show the value. Of course, it would be nice if I could do a breakpoint but that doesn't seem to be working. I'll attach a couple of images below of my code, the error, and the breakpoint error.       Server Error in '/' Application. Cannot insert the value NULL into column 'OrderID', table 'outman.outman.Contact'; column does not allow nulls. INSERT...

ASA Error -195: Column 'script' in the table 'ml_script' cannot be NULL
Hi, I am using SQL Anywhere/UltraLite 8.0.2.4285 When I try to execute the following script in InteractiveSQL, I get this error message. ASA Error -195: Column 'script' in the table 'ml_script' cannot be NULL Before adding a new table script, I want to first check and see if the script exists, and if it does, delete the script. That's why I used "NULL". call ml_add_table_script ( 'Version1.0', 'PRODUCT', 'download_cursor', NULL ); call ml_add_table_script ( 'Version1.0', 'PRODUCT', '...

''Null' is null or not an object' error when Button submit
  I am getting an error "null is null or not an object' When I press RegenerateButton the event will not fire. If anybody have the solution for this. Please share with me.  Please see the code.  <%@ page language="C#" masterpagefile="~/Public/Treasury.master" autoeventwireup="true" codefile="TreasuryDivisionReportB.aspx.cs" inherits="Protected_Taxes_Reports_TreasuryDivisionReportB" title="Treasury Division Report -B" %> <asp:content id="Content1" contentplaceholderid="Con...

''Null' is null or not an object' error when Button submit
I am getting an error "null is null or not an object' When I press RegenerateButton the event will not fire. If anybody have the solution for this. Please share with me.  Please see the code.  <%@ page language="C#" masterpagefile="~/Public/Treasury.master" autoeventwireup="true" codefile="TreasuryDivisionReportB.aspx.cs" inherits="Protected_Taxes_Reports_TreasuryDivisionReportB" title="Treasury Division Report -B" %> <asp:content id="Content1" contentplaceholderid="ContentPl...

'Cannot insert the value NULL into column' error when updating in GridView
now it works but when I click "ok" to update into the db the application answer is: Cannot insert the value NULL into column 'livello', table 'c:\asp.net\app_data\database.mdf.dbo.Utenti; column does not allow null. Update fails. The statement has been terminated. Here the gridview:1 <asp:GridView ID="GridView1" runat="server" AllowPaging="True" Width="95%" 2 DataKeyNames="id" AllowSorting="True" AutoGenerateColumns="False" 3 DataSourceID="SqlDataSource1...

SqlBulkCopy: the locale id '0' of the source column '<column name> ' and the locale id '1033' of the destination column '<column name>' do not match.
Hi, I am using the sqlbulkcopy object to transfer large amount of data from one SQL server to Other. The code look like this.. SqlDataReader readerSrc = null;SqlBulkCopy bulkCopy = new SqlBulkCopy(connDest);//Prepare Destination Table.SqlCommand cmdDelete = new SqlCommand("DELETE FROM " + destTableName, connDest);//Set the sqlcommand textSqlCommand cmdGet = new SqlCommand("SELECT * FROM " + srcTableName, connSrc);//Open source connection.connSrc.Open();//Open destination connection.connDest.Open();int delete = cmdDelete.ExecuteNonQuery();//Get the data.readerSrc = cmdGet.ExecuteRead...

How to solve error : Column 'Column' does not belong to table 'Table' ? Code attached
Hello    I have a dataset which is successfully being filled. However whenever i try    to access a givewn row of one of the tables in the dataset i get the error    "Column 'ContactId' does not belong to table 'SalesAgent'"    Except that it does and if i use an ordinal reference i can access the value    of the column. If i print the schema sure enough the column is called    ContactId. I have also noticed that if i hover the cursor over the    contactrow i can ac...

Can anyone see why I'm getting this error The column prefix 'dbo.PropertyForRentLocalized' does not match with a table name or alias name used in the query.
 Could someone please explain the likely root cause of this error.Thanks, andy. Server: Msg 107, Level 16, State 3, Line 16The column prefix 'dbo.PropertyForRentLocalized' does not match with a table name or alias name used in the query.Server: Msg 107, Level 16, State 1, Line 16The column prefix 'dbo.PropertyForRentLocalized' does not match with a table name or alias name used in the query.Server: Msg 107, Level 16, State 1, Line 16The column prefix 'dbo.PropertyForRentLocalized' does not match with a table name or alias name used in the query. CREATE ...

''''''''''''''''''''
Name: haznen Email: haznenatyahoodotcom Product: Gran Paradiso Alpha 8 Summary: '''''''''''''''''''' Comments: '''''''''''''''''''''''''''''''''''' Browser Details: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9a1) Gecko/20061204 UGES/1.7.2.0 GranParadiso/3.0a1 From URL: http://www.mozilla.org/projects/granparadiso/ Note to readers: Hendrix gives...

Sql 2005 Bogus error?!?!?! 'Column does not allow insert of NULLS'...(Duh!)
I have been battling this for 2 days! I could write a book on what does not work. I have even tried entering the data manually through the 'Open Table' SSMS function from the Object Explorer. I only have 5 records in the table. The first 4 I added a week or so ago during dev from the ASP.Net 2.0 (w VB) website that is the front end for this DB. I use a DAL between the site and DB.I added two new fields the other day and everything seemed to work fine. Now I get 'Siteid CANNOT BE NULL'. I abandoned attempts to Insert from the Website. The following was done directly th...

Cannot insert the value NULL into column 'RoleId'
When I try to start the application, I get the following error: Cannot insert the value NULL into column 'RoleId', table 'IssueTrackerStarterKit.dbo.IssueTracker_Users'; column does not allow nulls. INSERT fails. During setup, I chose to use Windows security and I'm connecting to the database with the SQL Server sa account (which I typed in to the connection string in the web.config file). I could not finish the install, however, because I got the error: Could not add ASPNET account to database............................... So I ran the CreateDatabaseObjects.sql script using Qu...

Web resources about - getting the error: Cannot insert the value NULL into column 'name', table 'InterGlobe.dbo.IG_Admin'; column does not allow nulls. INSERT fails. The statement has been terminated. - asp.net.object-datasource

Resources last updated: 1/20/2016 4:19:14 AM