DataSource Controls :: Adding The Same Data Values Into 2 Tables

Apr 23, 2010

i have an insert statement, and what i would like to do iswhen the value of table1 is entered, that value enters into table 2, so for example, heres my insert statement

INSERT INTO Cards (Name, Desc, id) VALUES ( @Name, @Desc, @id) INSERT INTO CardTP (NameSet, Desc, id)

Now, what i would like to do is that, i will specify all those individual values myself, BUT, when it now comes to the "id" field, when an id is entered for the "Cards" table, the SAME id should also be entered in the id column of the "CardTP" table. how i could enter the value of one table, into another tables row (having the same value) as i want the Cards and CardsTP table to be related in the id fields.

View 3 Replies


Similar Messages:

DataSource Controls :: Adding Columns To The Tables In The DB Dynamically?

Jun 30, 2010

Dim AlterTable As String = "alter table [Upload] add [Country] nvarchar (50) default 0 NOT NULL,[Address] int default 0 NOT NULL"

Dim connection As Data.SqlClient.SqlConnection
connection = New Data.SqlClient.SqlConnection()
connection.ConnectionString = ConfigurationManager.ConnectionStrings("ASPNETDBconnectionString1").ConnectionString
Dim cmdUpdating1 As New Data.SqlClient.SqlCommand(AlterTable, connection)
cmdUpdating1.CommandType = CommandType.Text
connection.Open()
cmdUpdating1.ExecuteNonQuery()
connection.Close()

This is the code which I am using for altering the number of columns in a table in the DB. so with this code i am able to add new coulmns dynamically. Now my major requirement in this is to obtain the headercount from the user( say "telephone number" and "language") and based on it generate the columns dynamically in the table in the DB.

View 12 Replies

DataSource Controls :: Adding Multiple Tables To The Array?

Feb 4, 2010

I am using ASP.NET 2.0, C# and Sql Server 2005.I have 2 tables retruned by the stored procedure to the application. I am returning an Array from my datalayer to my bussiness layer and then to my UI layer.I have added the first table into the array and passing it to the UI layer. This is my current code:

[Code]....

How to pass the second table details to the same array, NameArrayKeyEntity .

View 3 Replies

DataSource Controls :: Adding Rows And Updating Tables From Datatable

Mar 7, 2010

Maybe this could be a simple questino, but for me it's difficult to do this action: I have a table in sql server 2005 with some records stored, for example 10 records. The primary key of this table, let's call it "Employee", it's a number field with an autoincrement constraint. I want to store more data into the table by using a OdbcDataTable object and OdbcDataAdapter and adding new rows to the datatable and afeter that use the "Update" method from the OdbcDataAdapter object.

The big deal is this: let's suppose that I want a add a new record to the datatable object, using any method or code sequence that you want. if I have 10 records stored on the data base table, when I retrieve this table schema by using the OdbcDataAdapter "Fill" method, I have a copy of the data base table schema in the DataTable object, right?. if I add a new row on the datatable object, it's suppose that the primary key column of that table must AUTO-INCREMENT the value of the key, I mean if the last value that I store on the table was the number 10 on the PK field, when I add a new row on the datatable object, the PK value on the datatable object must be the number 11 if the autoincrement constraint is present into the DataTable object, but in my case, it doesn't work

So, How can I define the conditions or set the c# data objects properties to wor in that way???. In this moment the PK column on the odbcDataTable doesn't auto-increment its value when I add a new row on it.

Please helpe with this.

PD: I have another question about the DataTable object, how many records can store this object?? I have some problems with this because sometimes when I use the Fill() method to get data into the DataTable or a DataSet object there's no problem if the Fill() method retrieves about 142000 records, but when I retrieve over the 145000 records, when I inspect the DataSet or DataTable object by using the debuging mode, they have null value. Any of you can tell me why this situation ocurrs??

View 1 Replies

DataSource Controls :: Save Values In GridView With 2 Tables

May 29, 2010

I have a form with several DropDownlists and TextBoxes, Each dropdownlist depends on the selection of the previouse one.. and there is a submit button. Once the user clicks on it, information entered by the user is displayed in a GridView and saved as well in the database. The GridView holdes information from two tables I used joining) , but once I click on the Submit button I receive this error: Arithmetic overflow error converting varchar to data type numeric. The statement has been terminated. 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: Arithmetic overflow error converting varchar to data type numeric. The statement has been terminated. Source Error:

[Code]....

Imports System.Data.SqlClient
Imports System.Web.Configuration
Partial
Class Members_MembersCalculator
Inherits System.Web.UI.Page
Protected Sub CalculateButton_Click(ByVal sender
As Object,
ByVal e As System.EventArgs)
Handles CalculateButton.Click
Dim objConnection As SqlConnection
Dim objDataCommand As SqlCommand
Dim c_manu, c_model, c_date
As String
Dim sSQL As
String
Dim ConnectionString As
String
Dim c_factor As
Double
Dim c_result
As Double
Dim c_milage As
Double
Dim c_id As
Integer
Dim c_year As
Integer
c_manu = ManDropDownList.Text
c_year = YearDropDownList.Text
c_model = ModelDropDownList.Text
c_milage = MilageTextBox.Text
c_factor = FactorDropDownList.Text
c_id = CarIDDropDownList.Text
c_date = CarDateTextBox.Text
c_result = c_factor * c_milage
ConnectionString = WebConfigurationManager.ConnectionStrings("Carbon_free_ConnectionString").ConnectionString
objConnection = New SqlConnection(ConnectionString)
objConnection.Open()
sSQL = "Insert into car (Manufacture, year, Model, car_factor)" & _
"values('" & c_manu &
" ', ' " & c_year & " ',' " & c_model &
" ', ' " & c_factor &
" ')"
objDataCommand = New SqlCommand(sSQL, objConnection)
objDataCommand.ExecuteNonQuery()
objConnection.Close()
objConnection = New SqlConnection(ConnectionString)
objConnection.Open()
sSQL = "Insert into car_Result (car_id, car_Result_Date, Car_result)" & _
"values('" & c_id &
" ', ' " & c_date & " ',' " & c_result &
" ')"
objDataCommand = New SqlCommand(sSQL, objConnection)
objDataCommand.ExecuteNonQuery()
objConnection.Close()
msgLabel.Text = "Your records have been calculated successfuly, Thank you."
'CarDateTextBox.Text = ""
'MilageTextBox.Text = ""
CarGridSqlDataSource.DataBind()
CarGridView.DataBind()
End Sub
End
Class

View 3 Replies

Forms Data Controls :: How To Draw Bar Charts Dynamically Retrieving Values From Values Of Different Tables

Feb 1, 2011

I am using VS 2005.I have 5 tables depending on their values ,I need to draw a bar chart.

View 1 Replies

DataSource Controls :: Adding Values To A Table In A Form?

May 17, 2010

I guess the code is totally right and doesn't require any change in it,, however am getting an error which says "Conversion failed when converting the varchar value '11/11/2010' to data type int."check the attached file ..

[Code]....

View 7 Replies

Data Controls :: Adding Records To Two Database Tables In Single Form Page?

Jan 25, 2014

I a problem defining the variable @Bestilling in the codeBehind for adding the record to the database using a single form page. The database design with corresponding form are as below:

My ASPX.CS:
 
private void GridView1_BindData()
{
SqlConnection conn = new SqlConnection(connStr);
SqlDataAdapter dAd = new SqlDataAdapter("SELECT kart_DemoOrder.OrderID,

[Code]....

I get error in the method: "GridView1_AddNewRecord".

Must declare the scalar variable "@BestillingID". Is there a way to use only one Add Method and not two as I did?

View 1 Replies

DataSource Controls :: How To Get Data From Two Tables In Linq

Apr 28, 2010

How to get data from two tables through linq .1 ) productsDetails 2) productsImages to bind further listview.

View 1 Replies

DataSource Controls :: Tables For Particular Presentation Of Data

Jun 29, 2010

Apologies if this is in the incorrect forum.. just a question about how to best structure some tables for a particular presentation of data. In the following table (2nd column) you'll see that each motorcycle product applies to a range of years. What is the best way to store this range of years in a relational db? At the moment I have a datefrom and a dateto field for the two ranges, but that may complicate things when I want to filter the table by a particular year. E.G. datefrom is 2006 & dateto is 2010 and I would like to filter by products for a 2008 model.

View 4 Replies

DataSource Controls :: Insert Data Into Two Tables With Sql?

Feb 17, 2010

I have a details view form inserting data into one table successfully with no problems and picking up the ID parameter from a session.

What i would like to do is one insert SOME of the fields NOT ALL get inserted into another table.

Table 1 = course

table 2 = matrixoneantwo

I tried creating a datasource which inserted data into Matrixoneanttwo and called it from the detailsview_inserting event (sqldatasource.insert() but then i realised that this data source is seperate to my current one and therefore cannot use its parameters.

View 11 Replies

DataSource Controls :: Combine Data From 2 Tables

Mar 27, 2010

I have 2 tables with UserId and FirstName, LastName Columns that I want to combine the data in a Select Statement or Stored Procedure

1. The 2 tables will never have the same data, each table will be distinct

2. I want to combine first and lastnames to a full name (t1.FirstName + ' ' + t1.LastName) AS FullName

3. The statement will be used to populate a dropdownlist with UserId as Value, and Name as text

I am unsure how to accomplish this since I do not need to connect the tables, but combine the Sum of their data.

View 6 Replies

DataSource Controls :: Synchronize Data In 2 Tables?

Jan 6, 2010

I need to synchronize data between 2 tables. i need to update records on table2 corresponding to table1. I also need to add new records in table2 by getting new records from table1.

View 2 Replies

DataSource Controls :: Add Data To The Tables After They Are Created?

May 4, 2010

I have created a database along with the tables. The tables have the primary and foreign keys to create the relationship between them. However, I cannot now add the data to the table rows due to the key constraints. How do I now add the data to the tables without making up arbitrary data for the table ID's?

View 5 Replies

DataSource Controls :: Retrieving Data From Multiple Tables?

Aug 17, 2010

I have hard time trying to find the solution to retrieve data from multiple tables in one database.

table Kategorije has fields: idKategorija, naziv, opis table Clanak has fields: idClanak, idKategorija, naslov, autor,...

Kategorije.idKategorijais joined with Clanak.idKategorija, but that isn't the solution because I want my web site to show the Kategorije.naziv instead of Kategorije.idKategorija. This is the code I'm currently using to get idKategorije shown on my web site:

[Code]....

[Code]....

View 3 Replies

DataSource Controls :: Sum Data From Two Columns In Different Tables - SQL Query

Feb 9, 2010

I am trying to create an application in which there is a summary of outstanding payments.

One table is Table_Bills.

The other table stores records of Payments made and is called Table_Payments.

In summary i want to show 3 figures - each in separate one field datagridview with a data_source in separate data_adapter:

1) Ammount_Due 2) Amount_Paid 3) Balance.

The first two are no problem but the last is giving me a headache.

I tried this:

SELECT SUM(DHB_New_Jobtable.DayWage) - SUM(DHB_Payments.Ammount) AS Expr1

View 4 Replies

DataSource Controls :: Two Tables In MVC Using ADO Entity Data Model

Apr 6, 2010

my application have two tables. TableA and TableB TableA have one record

ID StudentName Age
1 MARK 20

I use selectlist to select StudentName .

ViewData["StudentName"] = new SelectList(_db.StudentSet.ToList(), "StudentName", "StudentName");

and then add to TableB. for this case , for me is success, but I also want to add the"Age" into TableB on same time. I don't know how to do it.

View 3 Replies

DataSource Controls :: Write Data To Multiple (two) Tables?

May 6, 2010

I have to write data to multiple (two) tables.

tbl1 has a column "ORDERID" with auto increment. I have to get this "ORDERID" whenever I write to tbl1 (Insert new record)

tbl2 has a coumn "ORDERID" as foreign key, I have to write "ORDERID" in tbl2 received from the tbl1.

How to do it using SQL ( I am not using StoredProcedure)

View 5 Replies

DataSource Controls :: Converting Access Data To SQL (.mdf) Tables?

Jun 18, 2010

I have a set of MS Access data (tables); is there a simple way to convert to SQL (.mdf) tables?

View 2 Replies

DataSource Controls :: Left Join 2 Data Tables?

Jan 29, 2010

I have 2 different datatables. 2 datatables from 2 different servers.

My first datatable is this:

SELECT DISTINCT a.name, a.create_date, a.Modify_Date, a.Object_Id
FROM dbname.sys.objects a

and my 2nd datatable is the same, but from a different server connection string

SELECT DISTINCT b.name, b.create_date, b.Modify_Date, b.Object_Id
FROM dbName.sys.objects b

Basically, I want to compare which procedures are on one server and not the other (dev and prod)

So after I have my 2 datatables i want to create a data relationship on the name and then do a left join to see whats in a and not b.

View 1 Replies

DataSource Controls :: Filtering Data Based On Multiple Tables?

Mar 16, 2010

I am writting a directory website that advertises fitness classes. These classes are listed by Class Type, and Geographical Area. Each Class Type can satisfy one or more of four Fitness Goals such as Loose Weight etc...

I have a table for Classes (classid, classname, classdesc, classtypeid, geoareaid) I have a table for geographic areas (geoareaid, geoarea) And I have a table for ClassTypes (classtypeid, classtypename, classtypedesc)

Which obviously links geographic area via the classes.geoareaid as a forgien key and classtypes by classes.classtypeid as a forgien key.

I can list all classes by type and also by geo area no problem, the problem arrises when I then also want to filter by goal.

The Goals Table (goalid, goal, goaldesc) is linked to the classtypes table via another table classtypes_goals (classtypeid, goalid) as each classtype can satisfy any of the 4 goals.

I am using a DataSet to fetch the data from a Stored Procedure in the SQL Database but because the classtypes can be linked to multiple goals I am getting duplication in my list depending on how many goals a classtype satisfies.

All I need in my data list is class name, class type and area I don't even need to display the goal I just want a drop down above the table that will filter the list and show only classes of classtype that satisfy the goal chosen.

View 18 Replies

DataSource Controls :: Deleting Data From The Multiple SQL Tables With LINQ (C#)?

Apr 22, 2010

I'm looking for ideas on deleting data from the multiple SQL tables with LINQ (C#).

My existing solution does the following:

1. DeleteAllOnSubmit( Subset of the data from the child table)

2. DeleteAllOnSubmit( Subset of the data from another child table)

3. DeleteAllOnSubmit( Data from the parent table)

4. CommitChanges()

All this resides within a single method, which makes it ugly and not re-usable.

I have considered the following alternatives, but I decided not to use them:

1. Cascade delete on the tables.

2. Do a join on all tables from which I will remove the data, but I'm not sure yet whether I could pass a join query to DeleteAllOnSubmit().

3. Write stored procedure(s) to delete data from each table. I don't have the time to implement this due to a large number of tables and the time constraints.

View 1 Replies

DataSource Controls :: Fill Data In SQLDataAdapter From Multiple Tables?

Jan 26, 2010

I'm using the following query as an SqlCommand:

[Code]....

It obviously doesn't work...what can I do? I cannot use the "Merge" method, because I am working with several tables in a single SELECT statment.

View 2 Replies

DataSource Controls :: Unable To Retrieve Data From Two Tables While Using Inner Join?

May 25, 2010

I need to retirve data from two tables...when i click a value in dropdown list, i need to retrieve values from two tables based on that id( which i have selected in dropdown)..so when i have written query ( "Select assign_issue.issue_assigned_to, assign_issue.created_on,assign_issue.last_Date,
issue_register.issue_desc,issue_register.issue_Priority from assign_issue INNER JOIN Issue_register ON assign_Issue.Issue_ID = issue_register.Issue_ID where issue_register = '" + ddlissueid.selecteditem.text + "'")..query is executing ..when it comes to dr = cmd.executereader()..Dr is unable to read..it is showing false when i trace..unable to read into while loop.

View 1 Replies

DataSource Controls :: Reterive Data From Two Tables By Using This Stored Procedure?

Jan 22, 2010

I'm using below stored procedure to reterive data and i'm displaying it in datalist... Now i want to reterive data from two tables by using this stored procedure...collegedetails is my table name... I want data from coursedetails also.

CREATE PROCEDURE [dbo].[SearchInstitute]
@startRowIndex int,
@Category varchar(500),
@inst_name varchar(500),
@course_name varchar(500),
@city varchar(500),
@pageSize int,
@totalCount int output
AS
BEGIN
SET NOCOUNT ON;
SET @totalCount = 0
SET @startRowIndex = @startRowIndex + 1
BEGIN
SELECT * FROM
( SELECT distinct *, ROW_NUMBER() OVER (ORDER BY ArticleList.clgid DESC) as RowNum
FROM (
Select distinct collegedetails.*
FROM collegedetails
WHERE category like '%' +@Category+ '%' OR inst_name like '%' +@inst_name+ '%' Or city like '%' +@city+ '%'
) as ArticleList
) as ArticleList1
WHERE RowNum BETWEEN @startRowIndex AND (@startRowIndex + @pageSize) - 1
ORDER BY clgId DESC
SELECT distinct @totalCount = Count(clgId) FROM collegedetails WHERE category like '%' +@Category+ '%' OR inst_name like '%' +@inst_name+ '%' Or city like '%' +@city+ '%'
END
END

View 4 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved