DataSource Controls :: Loading New Row To Data Table
Jan 6, 2010
I am using 2 data tables one for comparing the i.item-id=dr[datacolumn] and one for storing the result i.item_guid,i.item_description_title. But getting an error at table2.Rows.Add(itemlist) {"Input array is longer than the number of columns in this table."}
DataTable table2 = new DataTable();
foreach (DataRow dr in ds.Rows)
{
foreach (DataColumn dataColumn in ds.Columns)
{
pfDataContext pf = new pFDataContext();
var itemlist = from i in pf.item_tbls where i.item_id == dr[dataColumn].ToString() select new { i.item_guid, i.item_description_title };
table2.Rows.Add(itemlist);
}
}
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]...
May you tell me how can I transfer data from a table to another table, the condition of non-repetition rows
as a procedure in database MS QSL server 2005 ,Works in the first day of the month I use the first table in the prodation environment it is contain the employee data and the second to update first table only
I am using ajax control toolkit's hovermenuextender control. A panel is the popup control and an imageButton is the TargetControlId for this. In the panel I am using a simple table. My problem is that when I hover on the image button first time it shows the panel and table but not the table data (content in <td>). After that it's ok. but after page post back the problem again occurs.
how can I get data from more than one table using sqldatasource,,, am trying the following code but i get error "Invalid column name 'Category_tbl.CategoryI"
After i changed it, when going to SQL server express, looking at the original table, some how most of the data were changed to 0 and 1, some of them still stay the same, but most of it has been changed to 0 or 1.
Based on the scheduled meeting, read all users from table #1 and add their info in the table # 3 with the MeetingID (which I can get from the UI, because it will happen when they create the meeting).
I have been browsing about it, but so far, I couldn't find a good source of info to start with.
I have two tables cust and order_cust cust table have cust_id, name, addr, zip columns and order_cust have order_id and cust_id columns I take input from user for cust table i.e. name, addr, zip... the cust_id is an IDENTITY column so generates the value automatically Now I want to insert the last generated cust_id into order_cust (order_id is also an IDENTITY column)
I am having trouble inserting data into the table using dataset..following is my code:
[Code]....
The m_id is a primary key..I want to auto-increament it everytime a data is inserted into the table so I have configured (isIdentity) to Yes and Identity increament to "YES"..I don't know if its right or not..I already added some data manually into the table but now I want to add more data using the above code..but its not working..
i want my web page to display data from a table, but instead of the "id" fields displayed, i want to display more meaningful field names. these are stored in other tables. my select statement is as follows:
Colour(Colour ID, Colour) DogColours(ColourID, Dog ID) Dog(Dog ID, Breed)
Colour ID and Dog are primary keys.
I have three web forms, one for each table. Dog colours consists of data that is already in the system from the other two tables. It basically joins a breed to a colour. My problem is this:
When i try delete a dog which is being used in dog colours the program crashes. How can i prevent this crash?
The second problem, the data source in the dog colours web form has the insert, update and delete tick boxes greyed out in the 'configure the select statement' so i am unable to delete a colour and dog joined together. how can i delete something in the dog colours?
I have a form that has dropdown box and user can either select Store Associate or Store Manager, when they click on either, I have GetASsociate function that pulls data from sql database. What i am trying to figure out how to do, is that if they say select Store Manager I want to filter what data to pull from that sql table that has all associates in it, so I was trying use an 'expression' statement to stay if Store Manager was selected, only pull me back the store managers from that table. Then same thing for if they selected STore Assoicate, then only bring me back teh store assocites from that table. But the expression statment does not appear to be working.
asxc.vb code behind Private Sub GetDataAssociates()Dim provider As DbDataProvider' Create a collection of parameters. Dim coll As New DbParameterCollection() Dim prmCompany As New DbParameter provider = DbDataProviderFactory.GetProvider(DataAccessLayer.Enumerations.ProviderType.SqlClient, "GetAssociatesByCompany") prmCompany.ParameterName = "@Company" prmCompany.DbType = DbType.Int32 Select Case ddlCompany.SelectedItem.Text.ToStringCase "Stores" prmCompany.Value = 100 Case "Corporate" prmCompany.Value = 300 Case "Executives" prmCompany.Value = 900 Case "Union" prmCompany.Value = 200 Case Else prmCompany.Value = 0 End Select coll.Add(prmCompany.ParameterName, prmCompany) Select Case Me.ddlOrganisationStructure.SelectedValue.Trim Case "StoreManagers" Dim expression As String expression = "Pos_Group >'0900'" dsAssociates.Merge(provider.GetData(coll).Tables(0).Select(expression)) --IS ERRORING OUT ON ME HERE AT THIS LINE dsAssociates.Merge(provider.GetData(coll)) dtAssociates = dsAssociates.Tables(0) Case "StoreAssociates" Dim expression As String expression = "pos_group < '0900' dsAssociates.Merge(provider.GetData(coll).Tables(0).Select(expression)) -IS ERRORING OUT ON ME HERE AT THIS LINE dtAssociates = dsAssociates.Tables(0) End Select
I want to retrieve the data from the last record of a table. For eg: I have sorted the data in my table and want the value from the last record? How can I do that?
Is there a way to check that "saving" data to a table was successful and then do something after that?
I currently have 3 tables and return an average value for the OverallRating Column on each to get a CombinedOverall, but what if one of the tables does not have data for a particular customer? if I divide by 3 the answer will not be the same, and I could get an answer that is over the max I want (5.0)
[Code]....
It will be possible that the Customer will not have any data in one of the tables.