Help With Logic - VB - Formview - Multiple Database Tables

Jan 4, 2008

Guys, here is my scenario:

I have 3 tables

1) Vendor

2) Service

3) Service Product

Each vendor has the ability to have any number of services, all with any number of service products.

How should I setup my page so I can edit/insert vendors, and tie a list of service products and services to them?

My plan was to have a Formview with either a checkboxlist, or multilist (to select multiple items -  but they don't work that way) and then store selected items in another table (each item selected with its own record) to hold onto the vendor id and tie it to a service id and a product id, but I was unsure how to do this.

Any help would be greatly appreciated. 

FYI I am writing in VB.

View 2 Replies


ADVERTISEMENT

Multiple Tables In Business Logic Handler

Oct 25, 2007

Hi,

I have 2 related tables in SQL 2005. I am using Business Logic Handler on one of those tables during Merge Replication to reject data for few rows during web synchronization. Once a row is rejected, I would like to run the Business Logic Handler for the related table to reject changes for the row with same foreign key as the rejected row in first table.

Not sure if I need to create separate Business Logic Handlers for each table or can it be achieved in a single Handler.

Also is it possible to get a list of rejected rows back from the handler?

Thanks for help.

View 1 Replies View Related

How Do I Populate A Formview From Multiple Columns In A Gridview

Jun 29, 2006

Hi,
I have a master/detail scenario whereby to populate a formview, the user selects a row in the gridview.  The SqlDataSource used to populate the formview needs to check 2 columns from the gridview, ZRef (which is the SelectedValue of the Gridview) and ZName (a string).
From searching the forums it looks like I have to programmatically assign the SelectParameters in order to get ZName from the gridview.  Seems fair enough, so I set the parameters in the 'Selecting' event of the SqlDataSource.  (Code shown below).
 However the formview never shows.  In debug I can see that the values I'm setting in the SelectParameters.Add are correct; and if I set the default values for those parameters in the SqlDataSource itself, everything works fine.
Can anyone point me to some sample VB code that does this - I'm sure this must be a common situation.
Thanks.
Protected Sub sdsOff_Selecting(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.SqlDataSourceSelectingEventArgs)
Dim tmpSDS As SqlDataSource
Dim tmpLBL As Label
tmpSDS = CType(FormView1.FindControl("sdsOff"), SqlDataSource)
If tmpSDS Is Nothing Then
      Server.Transfer("ErrorOnPage.htm")
End If
tmpLBL = Me.GridView1.Rows(GridView1.SelectedIndex).FindControl("lblName")
If tmpLBL Is Nothing Then
      Server.Transfer("ErrorOnPage.htm")
End If
tmpSDS.SelectParameters.Clear()
tmpSDS.SelectParameters.Add("ZRef", GridView1.SelectedValue)   'In debug, this shows 7 - which is correct
tmpSDS.SelectParameters.Add("ZName", tmpLBL.Text)  'In debug, this shows 'Fred Bloggs' - which is correct
End Sub
 

View 5 Replies View Related

Insert Two Rows Into Two Tables At The Same Time From A Formview

Jul 31, 2007

I have a formview that uses a predefined dataset based on a cross table query. When the formview is in insert mode I need to insert the data into two seperate tables. Essentially I have tblPerson and tblAddress and my formview is capturing username, password, name, address line1, address line 2, etc. I presume I need to use a stored procedure to insert a row into tblPerson and then insert a row intp tblAddress. This is easy enough to do but the tables use RI and tblPerson has an imcremental primary key which needs to be innserted into a foreign key field in my address row. How do I do this? I'm using SQL Server. 

View 3 Replies View Related

Formview Does Not Update Database

May 21, 2006

HiI'm using a FormView to allow my administrator to add/edit/remove questions/answers to the FAQ of my helpdesk.Now I figured out how to use the FormView to adjust the data, the only thing the FormView does NOT do, is actually update the database, it does not give any errors, it just doesn't do anything.This is the code:  <asp:SqlDataSource ID="sdsAdminFaqDetails" runat="server" ConnectionString="<%$ ConnectionStrings:ASPNETDBConnectionString1 %>"
DeleteCommand="DELETE FROM [Faq] WHERE [QuestionID] = @QuestionID"
InsertCommand="INSERT INTO [Faq] ([Question], [Answer]) VALUES (@Question, @Answer)"
SelectCommand="SELECT * FROM [Faq]"
UpdateCommand="UPDATE [Faq] SET [Question] = @Question, [Answer] = @Answer WHERE [QuestionID] = @QuestionID">
<DeleteParameters>
<asp:Parameter Name="QuestionID" />
</DeleteParameters>
<UpdateParameters>
<asp:Parameter Name="Question" />
<asp:Parameter Name="Answer" />
<asp:Parameter Name="QuestionID" />
</UpdateParameters>
<InsertParameters>
<asp:Parameter Name="Question" />
<asp:Parameter Name="Answer" />
</InsertParameters>
</asp:SqlDataSource>
<asp:FormView ID="FormView1" runat="server" DataSourceID="sdsAdminFaqDetails">
<ItemTemplate>
<table border="0">
<tr>
<td style="width: 189px"><asp:Label ID="lblQuestionLabel" runat="server" Text="Vraag:"></asp:Label></td>
</tr>
<tr>
<td style="width: 189px"><asp:TextBox ReadOnly="True" ID="txtQuestion" runat="server" Text='<%# Eval("Question") %>' Width="309px"></asp:TextBox></td>
</tr>
<tr>
<td style="width: 189px"><asp:Label ID="lblAnswerLabel" runat="server" Text="Antwoord:"></asp:Label></td>
</tr>
<tr>
<td style="width: 189px; height: 40px"><asp:TextBox ReadOnly="True" ID="txtAnswer" runat="server" Text='<%# Eval("Answer") %>' Height="160px" TextMode="MultiLine" Width="457px"></asp:TextBox></td>
</tr>
<tr>
<td><asp:Button ID="btnEdit" runat="server" Text="Wijzig" CommandName="Edit" /> <asp:Button ID="btnInsert" runat="server" Text="Nieuw" CommandName="New" /></td>
</tr>
</table>
</ItemTemplate>
<EditItemTemplate>
<table border="0">
<tr>
<td style="width: 189px"><asp:Label ID="lblQuestionLabel" runat="server" Text="Vraag:"></asp:Label></td>
</tr>
<tr>
<td style="width: 189px"><asp:TextBox ID="txtQuestion" runat="server" Text='<%# Bind("Question") %>' Width="309px"></asp:TextBox></td>
</tr>
<tr>
<td style="width: 189px"><asp:Label ID="lblAnswerLabel" runat="server" Text="Antwoord:"></asp:Label></td>
</tr>
<tr>
<td style="width: 189px; height: 40px"><asp:TextBox ID="txtAnswer" runat="server" Text='<%# Bind("Answer") %>' Height="160px" TextMode="MultiLine" Width="457px"></asp:TextBox></td>
</tr>
<tr>
<td><asp:Button ID="btnUpdate" runat="server" Text="Bevestig" CommandName="Update" /> <asp:Button ID="btnDelete" runat="server" Text="Verwijder" CommandName="Delete" /></td>
</tr>
</table>
</EditItemTemplate>
<InsertItemTemplate>
<table border="0">
<tr>
<td style="width: 189px"><asp:Label ID="lblQuestionLabel" runat="server" Text="Vraag:"></asp:Label></td>
</tr>
<tr>
<td style="width: 189px"><asp:TextBox ID="txtQuestion" runat="server" Width="309px"></asp:TextBox></td>
</tr>
<tr>
<td style="width: 189px"><asp:Label ID="lblAnswerLabel" runat="server" Text="Antwoord:"></asp:Label></td>
</tr>
<tr>
<td style="width: 189px; height: 40px"><asp:TextBox ID="txtAnswer" runat="server" Height="160px" TextMode="MultiLine" Width="457px"></asp:TextBox></td>
</tr>
<tr>
<td><asp:Button ID="btnInsert" runat="server" Text="Voeg toe" CommandName="Insert" /> <asp:Button ID="btnCancel" runat="server" Text="Annuleer" CommandName="Cancel" /></td>
</tr>
</table>
</InsertItemTemplate>
<EmptyDataTemplate>
U hebt niet geselecteerd welke vraag u wilt wijzigen.
</EmptyDataTemplate>
</asp:FormView>
hope one of you sees where i made a mistake, or forgot about something...thx for your help

View 12 Replies View Related

Multiple Parameters - How To Configure The Logic?

Apr 15, 2008



Hi,

Im trying to set up a report in visual studio 2005 which uses multiple parameters (6) on which the user can filter to get the information they want.

here is what i want to happen - I've tried to explain as best i can but i dont think i've done a very good job...please ask questions if things need clarifying:

the 6 parameters are - userid, printers, default printer, area, applications, supervisor.

these need to be able to be filtered on any/all/combination of those parameters. parameters are set up and data is accessible, however when i run the report and try and filter on these it only works if all parameters are set to "All" (this is made available through a UNION select statement), or if i individually select a value for each category. if i choose a combination of say userid =myname, printers = myprinter, default=all, area=all etc it will match if ANY of the criteria is matched (including the ALL criteria, therefore it will always display all the values). i need to it work so if i pick the userid and the printer it will only match records containing BOTH the values i select, not either, or if i choose just the area, it will only return those records that contain that department.


Below is the WHERE statement i am currently entering in


WHERE (AllUserData.tp_ListId = '36948548-bfa8-4b25-aff8-b3d1f401dca1') AND (((AllUserData.nvarchar3 LIKE @Area) OR (@Area = 'All')) OR ((AllUserData.nvarchar4 LIKE @Default) OR (@Default = 'All')) OR ((AllUserData.ntext1 LIKE '%' + @Printer + '%') OR (@Printer = 'All')) OR ((AllUserData.ntext2 LIKE '%' + @Application + '%') OR (@Application = 'All')) OR ((@Application = 'All') AND (@Printer = 'All') AND (@Default = 'All') AND (@Area = 'All')))

and here is what Visual Studio automatically translates that into as soon as i execute the script:


WHERE (AllUserData.tp_ListId = '36948548-bfa8-4b25-aff8-b3d1f401dca1') AND (AllUserData.nvarchar3 LIKE @Area) OR
(AllUserData.tp_ListId = '36948548-bfa8-4b25-aff8-b3d1f401dca1') AND (@Area = 'All') OR
(AllUserData.tp_ListId = '36948548-bfa8-4b25-aff8-b3d1f401dca1') AND (AllUserData.nvarchar4 LIKE @Default) OR
(AllUserData.tp_ListId = '36948548-bfa8-4b25-aff8-b3d1f401dca1') AND (@Default = 'All') OR
(AllUserData.tp_ListId = '36948548-bfa8-4b25-aff8-b3d1f401dca1') AND (AllUserData.ntext1 LIKE '%' + @Printer + '%') OR
(AllUserData.tp_ListId = '36948548-bfa8-4b25-aff8-b3d1f401dca1') AND (@Printer = 'All') OR
(AllUserData.tp_ListId = '36948548-bfa8-4b25-aff8-b3d1f401dca1') AND (AllUserData.ntext2 LIKE '%' + @Application + '%') OR
(AllUserData.tp_ListId = '36948548-bfa8-4b25-aff8-b3d1f401dca1') AND (@Application = 'All') OR
(AllUserData.tp_ListId = '36948548-bfa8-4b25-aff8-b3d1f401dca1') AND (@Area = 'All') AND (@Default = 'All') AND (@Printer = 'All') AND
(@Application = 'All')


Note: AllUserData.tp_ListId references a specific row in the database which must be queried to get the correct information. so it must match on that before anything else.

any help structuring the logic i am using or better understanding the way visual studio/sql handles this kind of thing would be fantastic! thanks!

Shannon

View 2 Replies View Related

Updating Database In Cs File - Using Sqldatsource And Formview

Feb 8, 2007

Hi
I am new to asp.net world. I have a page with two formviews bound to two sqldatsources. One datasource connects to sql database and other to access. The information from both the databases is quite similar. The default mode for formview1 is edittemplate and for formview2 it is itemtemplate. I want to give the user an option to update formview1 data based on information retrevied in formview2 on a click of a button.  
I want to do this in code behind  .cs file. I am not sure how can I access the values from formview templates e.g formview1.itemtemplate... etc?
Can anyone please suggest a way to acheive this?
Thanks 
 
 
 
 

View 5 Replies View Related

Trying To Return MAX(value) Of A Database In Formview Text='&<%# Eval(MAX(ID1)) %&>

Mar 4, 2008

I am trying to return the ID of the last record entered into my database so the user will have his Record ID.  I'm trying to do this in a from view.
 text='<%#eval("ID")%>'
 SelectCommand="SELECT MAX(ID) FROM [Webenhancetest]">
 If it is done in this manner, it says DataBinding: 'System.Data.DataRowView' does not contain a property with the name 'MAX'. 
and if I just use SELECT IDFROM [Webenhancetest it works but only returns the first record which is 1.
 
How do I grab the last record, or Max(ID)???
 
 

View 2 Replies View Related

Transferring Two Tables Between Servers (was Logic)

May 12, 2005

I have 2 tables with the following structure:
CREATE TABLE [dbo].[table1] (
[RID] [int] IDENTITY (1, 1) NOT NULL ,
[RText] [varchar] (400) NULL ,
[DateModified] [datetime] NULL
) ON [PRIMARY]

CREATE TABLE [dbo].[Table2] (
[GrpRID] [int] IDENTITY (1, 1) NOT NULL ,
[GrpID] [varchar] (10) NOT NULL ,
[RID] [int] NOT NULL ,
[Status] [bit] NULL ,
[SortOrder] [int] NULL ,
[DateModified] [datetime] NULL
) ON [PRIMARY]
GO
I am transfering 2 table between 2 SQL server based on GrpRID from table2.
Since RID is identity in table1 sometimes it is different text for spesific
Rid in second server. Some how I need to get the match the right text from server1
to server2 and if text doesn't exists create a bew entry in table1 with the update to table2
wich should reflect correct RID.

View 1 Replies View Related

Insert From Formview And Checking Database To Avoid A Duplicate Entry

Apr 6, 2007

I have a form view that I am using to insert new data into a sql express database and would like to find a way to avoid attempting to insert a record if the key already exists.  is there a way to do this with the formview insert command.  Everything works great until I try to add a record with an already existing value in the unique key field, then it breaks.

View 1 Replies View Related

Query Multiple Database Tables

May 3, 2006

Sql2005??? -NEW to SQL. Have a database which creates tables basically named the same thing except the date. i.e. dbo.table05012006, dbo.table05022006. I need to query a table if the date is = yesterday. I am searching for a way to do this everyday dynamically. Is this even possible?

View 1 Replies View Related

How To Create Multiple Tables In A Database

Mar 6, 2008

I am trying to create multiple tables in a database using a SQL Script. First i want to find all the tables that have an Identity Column as a primary key in the database. Then for all the tables that meet the Identity Column and primary key criteria, I want to create a New Table.

For example if the Orders table has a Identity Column as a primary key, I want to Create a New Table called ProdID_Orders. The ProdID_Orders will have 1 column called ProdID.

If the OrdersDetails table has a Identity Column as a primary key, I want to Create a New Table called ProdID_OrdersDetails. The ProdID_OrdersDetails will have 1 column called ProdID.

If the Employee table has a Identity Column as a primary key, I want to Create a New Table called ProdID_Employee. The ProdID_Employee will have 1 column called ProdID.


so the Create Table Statement for the ProdID_Orders will look like this:


CREATE TABLE [dbo].[ProdID_Orders](

[ProdID] [int] NULL

) ON [PRIMARY]


The Create Table Statement for the ProdID_OrdersDetails will look like this:


CREATE TABLE [dbo].[ProdID_OrdersDetails](

[ProdID] [int] NULL

) ON [PRIMARY]

This sequence will continue for all the tables in the database that have an Identity Column as a primary key. Thanks. I will appreciate some assistance with this.

View 1 Replies View Related

SQLCE V3.5: Single SDF With Multiple Tables Or Multiple SDFs With Fewer Tables

Mar 21, 2008

Hi! I have a general SQL CE v3.5 design question related to table/file layout. I have an system that has multiple tables that fall into categories of data access. The 3 categories of data access are:


1 is for configuration-related data. There is one application that will read/write to the data, and a second application that will read the data on startup.

1 is for high-performance temporal storage of data. The data objects are all the same type, but they are our own custom object and not just simple types.

1 is for logging where the data will be permanent - unless the configured size/recycling settings cause a resize or cleanup. There will be one application writing alot [potentially] of data depending on log settings, and another application searching/reading sections of data.
When working with data and designing the layout, I like to approach things from a data-centric mindset, because this seems to result in a better performing system. That said, I am thinking about using 3 individual SDF files for the above data access scenarios - as opposed to a single SDF with multiple tables. I'm thinking this would provide better performance in SQL CE because the query engine will not have alot of different types of queries going against the same database file. For instance, the temporal storage is basically reading/writing/deleting various amounts of data. And, this is different from the logging, where the log can grow pretty large - definitely bigger than the default 128 MB. So, it seems logical to manage them separately.

I would greatly appreciate any suggestions from the SQL CE experts with regard to my approach. If there are any tips/tricks with respect to different data access scenarios - taking into account performance, type of data access, etc. - I would love to take a look at that.

Thanks in advance for any help/suggestions,
Bob

View 1 Replies View Related

How Would I Retrieve Values From Multiple Tables In The Database?

Feb 27, 2008

 Hi, i m using vwd 2005 express and sql express. i have created following tables table_office,table_customer,table_order in my sql express. i also added one more table named table_final. In my webform i have 2 textbox and submit button plus(controls to take values for table_office,table_customer,table_order).so when user fills the form and clicks the button the data gets inserted into thier respected tables.similarly table_final gets populated with values   in this way (id,name,address,table_office_id,table_customer_id,table_order_id) Now when displaying the output in the gridview. i combined values of all these  tables together. its fine till here. Now what i want is i want to write a query to retrieve these values back into the webform . Here i want the values from all the tables back into the webform controls on a click of a button.so that i can modify it manually, make updation on it and finally show it into gridview. i hope i m able to make u understand. anyway can somebody help me with simple code(C#) and sql query to achieve this task.? thanks. jack.     

View 8 Replies View Related

How Add A GUID Column To Multiple Tables In A Database

Mar 1, 2008



Does anyone have a script that can add a GUID Column to multiple Tables in a Database.

The SQL script below adds a column to a single table in a database. But i need a script that can add a column to all the tables in a database. Thanks

USE ProductDB

ALTER TABLE dbo.Employees
Add EmployeeGUID UNIQUEIDENTIFIER ROWGUIDCOL NOT NULL DEFAULT NEWSEQUENTIALID()

View 1 Replies View Related

Database Design Selecting Multiple Different Child Tables

Sep 19, 2000

I want to have a linking table say for example we call this a claim. Based on the claim number you need to relate to one of say 6 different types of claims. The types of claims related to their own individual parent table. (individual because each type of claim tracks completely different information) does anyone have an idea on how to set this up?

Sample Structure

table = Claim
Field 1 = ClaimTypeA_ID
Field 2 = ClaimTypeB_ID
Field 3 = ClaimTypeC_ID
Field 4 = ClaimTypeD_ID
Field 5 = ClaimTypeE_ID
Field 6 = ClaimTypeF_ID

The six field relate to the 6 different tables ID.

If I do this how do I store the data? put 0's in each of the claim types that are not used???

Any suggestions would be appreciated.

View 2 Replies View Related

How To Add A GUID Column To Multiple Tables In A Database Using A SQL Script

Mar 1, 2008



Does anyone have a script that can add a GUID Column to multiple Tables in a Database.

For example when a table has an Identity column like EmployeeID, a column called EmployeeGUID is added to the table. When a table has an Identity column like CustomerID, a column called CustomerGUID is added to the table. When a table has an Identity column like OrderID, a column called OrderGUID is added to the table.

I intend to implement replication in SQL Server 2005, so i want to add new GUID columns to all the table in my database before implementing replication

The SQL script below adds a column to a single table in a database. But i need a script that can add a column to all the tables in a database.

Thanks

USE ProductDB

ALTER TABLE dbo.Employees
Add EmployeeGUID UNIQUEIDENTIFIER ROWGUIDCOL NOT NULL DEFAULT NEWSEQUENTIALID()



View 3 Replies View Related

Multiple Tables, Inserts, Identity Columns And Database Integrity

Apr 30, 2008

Hi all,
I am writing a portion of an app that is of intensely high online eCommerce usage. I have a question about identity columns and locking or not.
What I am doing is, I have two tables (normalized), one is OrderDemographics(firstname,lastname,ccum,etc) the other is OrderItems. I have the primary key of OrderDemographics as a column called 'ID' (an Identity Integer that is incrementing). In the OrderItems table, the 'OrderID' column is a foreign key to the OrderDemographics Primary Key column 'ID'.
What I have previously done is to insert the demographics into OrderDemographics, then do a 'select top 1 ID from OrderDemographics order by ID DESC' to get that last ID, since you can't tell what it is until you add another row....
The problem is, there's up to 20,000 users/sessions at once and there is a possiblity that in the fraction of a second it takes to select back that ID integer and use it for the initial OrderItems row, some other user might have clicked 'order' a fraction of a second after the first user and created another row in OrderDemographics, thus incrementing the ID column and throwing all the items that Customer #1 orders into Customer #2's order....
How do I lock a SQL table or lock the Application in .NET to handle this problem and keep it from occurring?
Thanks, appreciate it.

View 2 Replies View Related

Got An Error When Trying To Import Multiple Tables From One SQL Server 2005 Database To Another

Oct 1, 2007



We just upgraded from SQL Server 2000 to 2005. In the past, when I ran the import/export wizard to copy multiple tables from one database to another with SQL Server 2000, I had no problem. Now when I used the import/export wizard to copy multiple tables with SQL Server 2005, I kept getting an error. For example, when copied three tables, the first table might be copied fine and I got an error with the second table and the whole thing stop. Sometimes I could copy two tables. However, when I ran the import/export wizard to copy each table one at a time, it worked.

The error that I got was "Cannot insert duplicate key in object..." I selected the options to "Delete rows in existing destination tables", and "Enable identity insert". What am I doing wrong?

R. Jiwungkul

View 15 Replies View Related

SQL Server 2012 :: Count From Multiple Tables For Same Column Exists In Database?

May 19, 2014

i have database which has 25 tables. all tables have productid column. i need to find total records for product id = 20003 from all the tables in database.

View 9 Replies View Related

Transact SQL :: Triggers - Pass INSERTED / DELETED Logical Tables To Function To Encapsulate Logic?

Jun 13, 2015

I would like to wrap the following code in a function and reuse it.  I use this code in many triggers.

DECLARE @Action as char(1);
SET @Action = (CASE WHEN EXISTS(SELECT * FROM INSERTED) AND EXISTS(SELECT * FROM DELETED)
THEN 'U'  -- Set Action to Updated.
WHEN EXISTS(SELECT * FROM INSERTED)
THEN 'I'  -- Set Action to Insert.
WHEN EXISTS(SELECT * FROM DELETED)
THEN 'D'  -- Set Action to Deleted.
ELSE NULL -- Skip. It may have been a "failed delete".   
END)

Is it possible to write a function and pass the INSERTED and DELETED logical tables to it?

View 5 Replies View Related

Database Logic

Jul 31, 2006

I am trying to figure out how to set up this database.
Basically, there are products with their associated fields. Each product can belong to multiple categories, and each category also has subcategories.So far I have the following, but not sure if this is the best way to set it up...TABLE Products:product_id (int) (1-many relationship to product_id in Table Product_Category)sku (int)descriptionpriceTABLE Categorycategory_id (int) (1-many relationship to category_id in Table Product_Category)nameTABLE SubCategorysubcategory_id (int) (1-many relationship to subcategory_id in Table Product_Category)category_id (int)nameTABLE Product_Categoryprodcat_id (int) product_id (int) (many-1 relationship to product_id in Table Products)category_id (int) (many-1 relationship to category_id in Table Category)subcategory_id (int) (many-1 relationship to subcategory_id in Table SubCategory)
Thanks,Mick

View 1 Replies View Related

Integration Services :: Import Multiple Files Into Multiple Tables Using SSIS

Jun 16, 2015

I have a requirement where in i have around 15 different flat files , filenames are fixed but folder path can be changed(i think i should use a variable for folder path). These 15 files data should go to their respective tables in the database.

Whether I need to create separate data flow task for each file or separate package? In addition to these, example : while importing product data into product table, if product ID already exists, we need to ignore it and upload only the new records.

View 4 Replies View Related

Integration Services :: Import Data From Multiple Excel Sheets To Multiple Tables Using SSIS?

Aug 25, 2015

I have an excel file that has multiple sheets and I need to import data from each separate sheet to a separate table using SSIS. 

E.g. Sheet A data should go to Table A and Sheet B data should go to Table B and so on. Is it possible to do this with out using script task.

View 6 Replies View Related

One Receipt Number, Query Multiple Tables Gives Multiple Data.

Sep 8, 2006

I have just taken over the job of sorting out a rather poorly designed database. It looks like it was 'upsized' from an access database to the SQL server. The SQL server is the 2000 version.

Now I am trying to generate a report of what the students in the database are owing by referencing the Receipt table and then all the available payment methods and allocations. I was wondering if there was anyway to work out data being displayed twice (Let me demonstrate)

Note1: All the tables are linked by a key of ReceiptNo. From what I can see there is a table for every payment type and allocation but no link between the two other then the receipt number.

Using the query:
SELECT T_Receipt.ReceiptNo, T_cheque.Amount AS Chq_Amount, T_credit.Amount AS Cre_Amount, StandingOrder.Amount AS Stn_Amount,
T_BankTransfer.amount AS Bnk_Amount, T_cash.TotalAmount AS Cas_Amount, T_RentPayment.AmountPayed AS Ren_Paid,
T_AdminPayment.AmountPaid AS Adm_Paid, T_InternetBilling.Total AS Int_Paid, T_Utilities.AmountPaid AS Util_Amount,
T_InvoicePayment.amountPaid AS Inv_Paid, T_OtherPayments.paymentAmount AS Oth_Paid, T_parkingBill.paymentAmount AS Prk_Paid,
T_TelephoneBills.TelephoneCredit AS Tel_Paid, T_DepositPayment.[Deposit payment] AS Dep_Amount, T_Receipt.cancelled AS Canceled,
T_Receipt.RemittanceReceiptNo AS Rec_Ref, T_Receipt.Student
FROM T_Receipt INNER JOIN
T_DepositPayment ON T_Receipt.ReceiptNo = T_DepositPayment.receiptNo LEFT OUTER JOIN
T_RentPayment ON T_Receipt.ReceiptNo = T_RentPayment.RentPaymentNo LEFT OUTER JOIN
StandingOrder ON T_Receipt.ReceiptNo = StandingOrder.ReceiptNo LEFT OUTER JOIN
T_TelephoneBills ON T_Receipt.ReceiptNo = T_TelephoneBills.ReceiptNo LEFT OUTER JOIN
T_parkingBill ON T_Receipt.ReceiptNo = T_parkingBill.ReceiptNo LEFT OUTER JOIN
T_OtherPayments ON T_Receipt.ReceiptNo = T_OtherPayments.ReceiptNo LEFT OUTER JOIN
T_InvoicePayment ON T_Receipt.ReceiptNo = T_InvoicePayment.receiptNo LEFT OUTER JOIN
T_cash ON T_Receipt.ReceiptNo = T_cash.ReceiptNo LEFT OUTER JOIN
T_AdminPayment ON T_Receipt.ReceiptNo = T_AdminPayment.ReceiptNo LEFT OUTER JOIN
T_BankTransfer ON T_Receipt.ReceiptNo = T_BankTransfer.receiptNo LEFT OUTER JOIN
T_Utilities ON T_Receipt.ReceiptNo = T_Utilities.receiptNo LEFT OUTER JOIN
T_credit ON T_Receipt.ReceiptNo = T_credit.ReceiptNo LEFT OUTER JOIN
T_cheque ON T_Receipt.ReceiptNo = T_cheque.ReceiptNo LEFT OUTER JOIN
T_InternetBilling ON T_Receipt.ReceiptNo = T_InternetBilling.ReceiptNo
GROUP BY T_Receipt.Student, T_Receipt.ReceiptNo, T_cheque.Amount, T_credit.Amount, StandingOrder.Amount, T_BankTransfer.amount, T_cash.TotalAmount,
T_AdminPayment.AmountPaid, T_InternetBilling.Total, T_Utilities.AmountPaid, T_InvoicePayment.amountPaid, T_OtherPayments.paymentAmount,
T_parkingBill.paymentAmount, T_TelephoneBills.TelephoneCredit, T_Receipt.cancelled, T_Receipt.RemittanceReceiptNo,
T_DepositPayment.[Deposit payment], T_RentPayment.AmountPayed, T_Receipt.Student
HAVING (T_Receipt.Student LIKE N'06%')

Which gives a result of:




RecNo.
30429
Cheque
250
Deposit
250


30429
679.98
250


This is fine but when I do analysis on this it appears as though the student has paid two deposit payments. I was wondering with out querying each table independently from an application if there was a criteria to specify that I only get one deposit result.
So as such say, give me all the payments but I only want one result from the other tables. I though about discrete but that wouldn't work here.

View 3 Replies View Related

Merging Data From Multiple Databases With Multiple Tables (all With The Same Structure)

Nov 15, 2006

Hi!

I have 7 source databases and one target database, all using the same structure. The structure is made of 10 tables, with foreign key constraints.

I need to merge the source databases into the target (which won't have any data before that process, but will already have the correct schema), and to keep the relationships between the records.

I know how to iterate over the source databases (with SMO foreach), but I'd like to know if someone can advise the best copy method for that context in SSIS ? (I don't want to keep the primary keys, but I need to keep the relationships...)

Any pointer most welcome!

best regards and thanks

Thibaut

View 1 Replies View Related

Importing Multiple Flat Files To Multiple Tables In SSIS

Jun 27, 2006

I have a couple of hundred flat files to import into database tables using SSIS.

The files can be divided into groups by the format they use. I understand that I could import each group of files that have a common format at the same time using a Foreach Loop Container.

However, the example for the Foreach Loop Container has multiple files all being imported into the same database table. In my case, each file needs to be imported into a different database table.

Is it possible to import each set of files with the same format into different tables in a simple loop? I can't see a way to make a Data Flow Destination item accept its table name dynamically, which seems to prevent me doing this.

I suppose I could make a different Data Flow Destination item for each file, in the Data Flow. Would that be a reasonable solution, or is there a simpler solution, or should I just resign myself to making a separate Data Flow for every single file?

View 9 Replies View Related

Multiple Insert Into Multiple Tables With A Stored Procedure

Mar 1, 2007

Hello
I am building a survey application.
 I have 8 questions. 
 Textbox -  Call reference
 Dropdownmenu  - choose Support method
 Radio button lists - Customer satisfaction questions 1-5
Multiline textbox - other comments.
I want to insert textbox, dropdown menu into a db table, then insert each question score into a score column with each question having an ID.
I envisage to do this I will need an insert query for the textbox and dropdownlist and then an insert for each question based on ID and score.
Please help me!
Thanks
Andrew
 

View 9 Replies View Related

Insert Single Row / Multiple Rows Into Multiple Tables

Sep 3, 2014

How to insert single row/multiple rows into multiple tables by using single insert statement.

View 1 Replies View Related

Bulk Insert Multiple Files To Multiple Tables - How?

Feb 15, 2008

I need to be able to bulk insert a bunch of tables from their corresponding flat file. I have created an XML file (see below) which has the file name/table name pair at each node. I then created a ForEachLoop task and used the Node enumeration type and the following OuterXpathString: ReferenceFiles/File. At this point I get lost. How do I pass the 2 inside node values (file name and table name) to variables which I can then use as expressions for the bulk insert task inside the Foreach?

Here is XML file:




Code Snippet
<ReferenceFiles>

<File>


<FileName>Ref_Categories.txt</FileName>
<TableName>Ref_Categories</TableName>
</File>
<File>

<FileName>Ref_Configs.txt</FileName>
<TableName>Ref_Configs</TableName>
</File>
</ReferenceFiles>






Thanks.

View 1 Replies View Related

Export Multiple Tables To Multiple Flat Files

Nov 29, 2007

I used the data export wizard to export a single table to a single flat file (multiple wasn't allowed). I saved the package as a *.dtsx file which I'm attempting to edit to add the additional tables.

Creating additional sources is fairly easy copy of the first source and change to the table name.

I've tried copying the destination connection and changing to a new text file, but can't get past having to add each column manually to the new destination.

How can I duplicate the mapping that must be taking place in the wizard in the *.dtsx editing environment?


This seems like a simple / common task, but I've been unable to find a solution.

Thanks, Richard

View 1 Replies View Related

Querying Multiple Tables Multiple Times

May 31, 2007

I am trying to query the Topics in my discussion forum...The Topic contains a "last_poster_id" and a "author_id" I need the username and userid for both "last_poster_id" and "author_id" in the table "aspnet_Users"How do I do this?I would guess I need to use sub select statements. Can someone help me? 

View 12 Replies View Related

Search Multiple Parameters In Multiple Tables

Dec 21, 2007

Hi,
I am trying to build search engin with 11 parameters in 4 different tables in the database.
For example:
In search.aspx I have 11 textboxes namely
nameTextbox, phoneTextbox, nationalityTextbox, ageTextbox etc.
And in the result.aspx page I have gridview which post data from the database if the search match.
I wrote this stored procedure. P.S please ignore the syntax.
  @name var(30),

@nationality (30),

@phone int,

etc

as



Select a.UserId, b.UserId, c.UserId FROM Table1 a, Table2 b, Table3 c

WHERE

name LIKE '%' @name '%'

OR nationality LIKE '%' @nationality '%'

OR phone LIKE '%' @phone '%'

etc
 
But I got an error when I am trying to execute this code because the nulls values so I wrote
 1 @name var(30),
2
3 @nationality (30),
4
5 @phone int,
6
7 etc
8
9 as
10
11
12
13 Select a.UserId, b.UserId, c.UserId FROM Table1 a, Table2 b, Table3 c
14
15 WHERE
16
17 name LIKE '%' ISNULL(@name, '') '%'
18
19 OR nationality LIKE '%' ISNULL(@nationality,'') '%'
20
21 OR phone LIKE '%' ISNULL(@phone,'') '%'
22
23 etc
24
25

 
Also the error still exist.
What is the best way to search for multiple parameters in multiple tables ?
 
Thanks in advanced

View 4 Replies View Related







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