Forms Data Controls :: Trying To Use Sqldatasource To Insert Into A Table?
May 7, 2010
Am trying to use sqldatasource to insert into a table and it comes up with the error message" Could not find control 'txtLast' in ControlParameter 'LastName'.
View 2 Replies
Similar Messages:
Oct 12, 2010
I've added a simple SqlDataSource to my site with insert properties. I've also created some code behind to capture the insert command (oninserting="SqlDataSource_NewsLetterSubscription_Inserting").
Thing is how do I actually trigger the command to 'insert' from a standard button?
<asp:SqlDataSource ID="SqlDataSource_NewsLetterSubscription" runat="server"
View 2 Replies
Aug 11, 2010
I am working on a web app for an online photo album. It is the last project in Scott Mitchell's book: "ASP.Net 2.0 in 24 hours".
I am creating a page where users can enter new photo images. The functionality for uploading an image will come later. I am working on just inserting a new row into the Pictures table with an optional category, a required title and a required description.
I am getting an error when I try to insert a new row.
Here is a screenshot of the page with a shot of the dropdown list.
The Categories are user-specific. I am getting the correct values retrieved.
[URL]
There are two pretty simple database tables involved here.
NOTE: The CategoryID and PIctureID are both autoincrement integer columns.
[URL]
The page uses a DetailsView that uses a SqlDataSource that uses the Pictures table. (The DetailsView's Default Mode property is set to "Insert". The "Enable Inserting" checkbox is also checked.)
The dropdown list uses a dropdown control that uses a SqlDataSource that uses the Categories table.
When the "Insert" button is clicked the CategoryID value associated with selected (Category) Name on the dropdown list will be used along with the Title and Description values to insert a row in to the Pictures table. (If no Category value is selected, then a null value will be used for the CategoryID. This is OK because the CategoryID column in the Pictures table allows nulls.)
My problem is that I am getting this error:
Cannot insert explicit value for identity column in table 'Pictures' when IDENTITY_INSERT is set to OFF.
(FYI: I have the full version of both Visual Studio and SQL Server.)
Here is my source code for the page:
[Code]....
View 3 Replies
Jun 13, 2010
Basically i deal with two tables.i have a table T1 of the following format:id company_name i need to read this data and create a table T2 as followsi wrote the following code. it worked fine for retrieving data and modification but fails to insert the modified data into the 2nd table.the error is, it does not recognise the value for @token
ArrayList dynarr=new ArrayList(); // global variable
protected void Button2_Click(object sender, EventArgs e)
{
int row = 1; int i;
string strcmd = null;
string Connection = "Data Source=....";
SqlConnection conn = new SqlConnection(Connection);
string str = "select company_name from T1 where ID=@ID";
[code]...
View 2 Replies
Aug 4, 2010
I know this sounds odd. I have a SQL DB that I am pulling data from. I have to some math functions to get a percentage. So I am pulling all the data in my code and building a data table with the results. I am then trying to pass this into a chart control that I have, but it fails because the data source is not correct for the chart control. I know that the chart control will accept a SQLDataSource control as a data source because a built a example with it before using it in my project.So my question is how can I use the Data Table as a data source for a SQLDataSource Control? Or is there a way I can pull the data from my DB andapply the math needed in a stored procedure or something similar that I could create the procedure on my SQL server then add a SQLDataSource control to my page and use the stored procedure as the source for the SQLDataSource Control.
View 5 Replies
May 3, 2010
I am using two tables if one table is master table that is list of products and their Id's.I bind all list of products in dropdownlist.If i select Product means i want to insert their Id in table's.How to done this in easy form.Any one can send easiest form of inserting.
View 3 Replies
Mar 4, 2011
I have a formview with insert function into "table1". In that formview i also have a dropdownlist listed with records from "table2". (This dropdown is of course instead of a textbox). get "table1" inserted when one of the field is from a different table?
View 1 Replies
Aug 9, 2010
I am having datagrid in that I have one column that should have table. Now I want to know that how can I include table in datagrid. My table values may differ from each rows in datagrid. So that also should be accomplished.
View 3 Replies
Jan 11, 2010
How to display empty GridView to insert new record if no data retreived for some record on the result from data table?Actually i am trying to give a user an option to add recrod from Gridview. On result of some query it is perfectly displaying data and a footer row with the insertion textbox but when there is no data in the gridview it is not displaying. It should display with footer having insert textbox.
View 5 Replies
Jun 1, 2010
in my button4 click event, i want to insert checboxlist items to data table. first i want to delete all of the exisiting and then insert again.
my code is below but it is not working if you could explain anyone ?
in page load I have written code so that existing checkbox items are selected.
[code]...
View 5 Replies
Aug 20, 2010
how can i insert data into dyanamically created table from database
View 2 Replies
Oct 16, 2010
I want to insert data in grid or table form in sql server2005. Which control is better to use?
gridview or repeater
View 3 Replies
Aug 20, 2010
how can i dynamically insert datas from database into Table and display the table
View 1 Replies
May 7, 2010
I am passing a query string into a new page and want a detailsview to insert whatever comments a user enters
I am getting an error AlbumUID does not accept nulls error.
I thought I passed the query string value to the insert statement but I must have missed something
Here's what I have:
<asp:SqlDataSource ID="SqlDSAddComment" runat="server"
ConnectionString="<%$ ConnectionStrings:MyCDsConnectionStringHome %>"
InsertCommand="INSERT INTO [Comments] ([Comments], [Rating], [AlbumUID]) VALUES (@Comments, @Rating, @AlbumUID)"
[Code]....
View 6 Replies
Jul 22, 2010
I have a gridview that I load with data from an Excel spreadsheet when the user pushes a button. I then want another button that would insert all the data from the gridview into a sql table when the button is pressed. I'm using vb.
View 4 Replies
Oct 21, 2010
I have a tricky situation that I just cannot seem to figure out. I'm using ASP.NET 4.0. I have two databases (let's call them Northwind and MyDatabase for simplicity). I cannot modify the data in Northwind, but once I save a copy to MyDatabase, I can change it.
I have a GridView that shows all the tests associated with a patient. I first populate the GridView, retrieving all the tests in Northwind.Test that are associated to a PatientID. On a button click event, I need to: Create a new Patient record in MyDatabase.Patient (I've got this part done already).Use that newly created PatientID and INSERT all of the rows from the GridView intoMyDatabase.Test.
I have the PatientID available, I just don't know how to retrieve the data from the GridView.(Ideally) I would like to then be able to load that patient record in the future from MyDatabase and be able to UPDATE the tests in the GridView to MyDatabase.Test. I can load the tests into the GridView no problem. But I have no idea how I would save that data to a different datasource. Should I even be using a GridView, or something else?
View 1 Replies
Jan 31, 2011
inserting data from 1 table in 1 database to another database using web service to retrieve the data in a gridview in vb.net, 3-tier
View 6 Replies
Jan 31, 2010
how can i insert data in gridview from 2 table?
how can i bind the data?
View 1 Replies
Sep 16, 2010
I want to add controls (or simply texts) to a ListView inside the ItemTemplate at run time.
The reason is that in my application I don't know in advance how many controls (or texts) I should insert.
For example I have to read the fields from a database table and insert in the ItemTemplate controls according to those fields:
<ItemTemplate>
<%# Eval("fieldname1")%> - <%# Eval("fieldname2")%> - <%# Eval("fieldname3")%> - .....
Afterwards I have to bind the ListView to the table content, so I need to preserve the <%# ... %> structure for the binding
View 3 Replies
Feb 25, 2010
i have two sqldatasource controls. one i use to display data in textbox's ,filter'd by a select parameter in page behind code. Once checked, i want to copy this data to the other datasource ,by selecting checkbox.Then display this data in detailsview control.
At present the two datasource controls declared , render data to the page simultaneously during pageload. I want to first check data in textbox's from first source, before second datasource is rendered to screen. note, both are filtered by a page variable. i wish to leave the textbox datasource control in situ, as other controls and code depend on it.The other detailsview datasource is my problem?
View 1 Replies
Feb 6, 2011
It sounds pretty simple, but I can't find a way to make it work. I have a FormView with a InsertTemplate where it inserts the current logged in user's UserId and content from a HTMLeditor, and a EditTemplate where it retreives the current logged in UserId and shows content from database in the HTMLeditor.
How can I get it to show EditTemplate if the userId exist in the table, and InsertTemplate if the UserId does not exist in the table?
View 4 Replies
Mar 3, 2011
I have error:
Cannot insert explicit value for identity column in table 'UserDetails' when IDENTITY_INSERT is set to OFF.
I'm trying to insert a record through a BLL (Business Logic Layer) class with an 'Insert' button attached to the FooterTemplate of a GridView2. My code:
[Code]....
[Code]....
BLL layer code:
[Code]....
The field 'idUser' is autoincremented. When I use SqlDataSource with a DetailsView, add option it adds a record and autoincrements the 'isUser'.
View 7 Replies
Feb 7, 2011
i have a form with several checkboxes....i want to insert the selected checkbox values in to a single column in the sql database..
View 4 Replies
May 24, 2010
In following SQL query: SELECT DISTINCT CodeID, CodeDesc FROM Faults.TblFltClearCodes AS TblFltClearCodes
I am getting a list but there is no null value.Within this query I would like to get only one NULL value at the top and then the list.How to do this? Explicitly I am not allowed to give a null value in the table in DB.
View 5 Replies
Mar 12, 2010
I dragged and dropped a sqldatasource and want to do an insert statement, taking the new values from a textbox. I did this already however when i do my insert statement eg. INSERT INTO Development_Programme(MHID) VALUES (@m) HOWEVER when to select the insert parameters the 'Next' button and the 'Finish' button is shaded off, I added a Select statement and the 'Next' was unshaded HOWEVER the screen to select the insert parameters is not appearing it goes straight to the Test Query.
View 3 Replies