Showing posts with label writing. Show all posts
Showing posts with label writing. Show all posts

Friday, March 30, 2012

Need help creating a temporary table in MS SQL Server.

Hello,

I am working on a webapp using VB.net

Right now I am writing to a sql table during a process where the end userstarts entering the contents for a file that is going to be generated once hefinishes entering the data, but the problem is that if more than one user isdoing the same process the data would get mixed up. To avoid this Ithought in creating a temporary table (its name will consist of a stringand the current date time).

I would like to see any tutorialabout creating and working with temp tables. Or if you have anysuggestions, I will appreciate them. Thanks

There are two types of temp tables in SQL Server # local temp table scope very limted but also the most used because it uses less resources and SQL Server may clean up if you forget it, the other ## global temp table longer scope but you must drop it explicitly or it can harm your application. Try the link below for some tricks of how to use the temp tables, I am assuming you know they are created in the Temp Db. Hope this helps.

http://www.awprofessional.com/articles/article.asp?p=25288&seqNum=4&rl=1

Need help building/reading C# SQL Array

I'm stuck and uinder a bit of a time crunch.

I have 5 fields I want to get out of a sql database using a function that I'm writing. I figure it sounds like an array. basically I want to make an array, and fill it up with the results of a sql select, then read the array.

This is what I have so far....

String TempHRAcctCode, TempJobDescription, TempHourlyRate, TempEmplID;
Array TempArray;
TempJobDescription = DDDept.SelectedItem.Text; (to get KeY Value)

SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings["MYCONN"].ToString());
connection.Open();
SqlCommand command = new SqlCommand("Select HRAcctCode, HourlyRate , EmplID, ... FROM TimeMyProfile WHERE JobDescription = " + TempJobDescription + " ", connection);
SqlDataReader TempDataReader = command.ExecuteReader;
while TempDataReader.Read
(
... OK I GIVE UP!

Thanks in advance



why you want read as an array ?? If you really want to read these data later then load into aDataSetrather than reading from Data Reader into an array and then later read again the array...

using (SqlDataAdapter da = new SqlDataAdapter(command))
{
DataSet ds = new DataSet();

// Fill the DataSet using default values for DataTable names, etc
da.Fill(ds);

connection.Close();

// Return the dataset
return ds;
}

And you can read the data set like

foreach (DataRow dr in ds.Tables[0] .Rows)

{

string myVar = dr["HourlyRate"].ToString()

}

|||

Funny thing is, as I was typing th equestion I was asking myself the same thing, WHY use an array!
Excellent suggestion, it works GREAAT!

Thanks

Wednesday, March 21, 2012

Need code examples of how to call SSRS reports from winforms app

I'm writing a vb.net winforms app and need to call up reports from SSRS. I
also need to pass in secure parameters into the report and I don't want to
pass the credentials if I don't have to. I was hoping I could call my own
web service where I can pass encrypted data to my web service which would
contain the parameters. then a business object on the server could generate
the credential needed by SSRS and pass both the credentials and decrypted
parameters into the report. Problem is I don't know how to get the report
back to the client. One idea was to render the report on the server side
and then convert its html into a byte stream and pass the byte stream as a
return value for my web service. Then my winform client could convert the
byte stream into an html document. However, I have no idea if this is
possible and need examples for the various parts.
can someone please give me advise (and preferable links to code examples) on
how to solve this problem?
Thanks.
--
moondaddy@.nospam.nospamHello,
The following link might be helpful for you:
http://www.codeproject.com/useritems/SQLRSViewer.asp
Regards,
Peter Yang
MCSE2000/2003, MCSA, MCDBA
Microsoft Online Partner Support
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
=====================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
| From: "moondaddy" <moondaddy@.nospam.nospam>
| Subject: Need code examples of how to call SSRS reports from winforms app
| Date: Fri, 29 Apr 2005 00:29:02 -0500
| Lines: 22
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2900.2527
| X-RFC2646: Format=Flowed; Original
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2527
| Message-ID: <ujCUetHTFHA.2756@.tk2msftngp13.phx.gbl>
| Newsgroups: microsoft.public.sqlserver.reportingsvcs
| NNTP-Posting-Host: adsl-70-240-196-183.dsl.hstntx.swbell.net
70.240.196.183
| Path: TK2MSFTNGXA01.phx.gbl!TK2MSFTNGP08.phx.gbl!tk2msftngp13.phx.gbl
| Xref: TK2MSFTNGXA01.phx.gbl microsoft.public.sqlserver.reportingsvcs:42254
| X-Tomcat-NG: microsoft.public.sqlserver.reportingsvcs
|
| I'm writing a vb.net winforms app and need to call up reports from SSRS.
I
| also need to pass in secure parameters into the report and I don't want
to
| pass the credentials if I don't have to. I was hoping I could call my
own
| web service where I can pass encrypted data to my web service which would
| contain the parameters. then a business object on the server could
generate
| the credential needed by SSRS and pass both the credentials and decrypted
| parameters into the report. Problem is I don't know how to get the
report
| back to the client. One idea was to render the report on the server side
| and then convert its html into a byte stream and pass the byte stream as
a
| return value for my web service. Then my winform client could convert the
| byte stream into an html document. However, I have no idea if this is
| possible and need examples for the various parts.
|
| can someone please give me advise (and preferable links to code examples)
on
| how to solve this problem?
|
| Thanks.
|
| --
| moondaddy@.nospam.nospam
|
|
|sql

Friday, March 9, 2012

Need advice on a Data Import Routine

Hello,
I have a system that I am writing to automaticly import Credit Transaction
data into a SQL Server 2000 Database. I am using a VB.Net application to
detect when the file arives and prep it for parsing. The file is
aproximately 10Mb of relatively complex hierarchal data that is defined by 2
character tokens at the begining of each data line. The structure breaks ou
t
into aproximately 6 parent-child related tables with numerous lookup tables
on each primary table.
The previous aproach loaded each line of raw data into an Import table and
used a Stored Procedure to break down the information into the tables. The
Stored Procedure is large and very complex. It also has the problem that th
e
Parsing takes so long I need to implement a very long timeout on my
connection or I get errors. It is also difficult to track progress through
the Import for the user to see.
The options I see at this point are;
1. Use the current approach of loading the raw data into an Import table and
Parsing with a Stored Procedure.
2. Write the Parsing Routine in VB.NET and use ADO.NET to load the data into
the apropriate tables.
3. Use a mixed aproach of breaking the massive Stored Procedure into smaller
procedures and managing the steps with VB.Net.
I am looking for any tips and advice that the guru's out there are willing
to give. Especially a comparision of the effiency of doing ADO.NET bulk
inserts vs. Stored Procedure parsing.
Thanks for any help given.
Doug
PS - Sorry for the cross posting in dotnet.general but I am hoping to get a
balanced set of views on this issue.Doug,
I have heard that sql server is not good for parsing routines, so this can
lead you to do it in your client app.
What about using XML to represent this complex hierarchal data?
AMB
"Doug R" wrote:

> Hello,
> I have a system that I am writing to automaticly import Credit Transaction
> data into a SQL Server 2000 Database. I am using a VB.Net application to
> detect when the file arives and prep it for parsing. The file is
> aproximately 10Mb of relatively complex hierarchal data that is defined by
2
> character tokens at the begining of each data line. The structure breaks
out
> into aproximately 6 parent-child related tables with numerous lookup table
s
> on each primary table.
> The previous aproach loaded each line of raw data into an Import table and
> used a Stored Procedure to break down the information into the tables. Th
e
> Stored Procedure is large and very complex. It also has the problem that
the
> Parsing takes so long I need to implement a very long timeout on my
> connection or I get errors. It is also difficult to track progress throug
h
> the Import for the user to see.
> The options I see at this point are;
> 1. Use the current approach of loading the raw data into an Import table a
nd
> Parsing with a Stored Procedure.
> 2. Write the Parsing Routine in VB.NET and use ADO.NET to load the data in
to
> the apropriate tables.
> 3. Use a mixed aproach of breaking the massive Stored Procedure into small
er
> procedures and managing the steps with VB.Net.
> I am looking for any tips and advice that the guru's out there are willing
> to give. Especially a comparision of the effiency of doing ADO.NET bulk
> inserts vs. Stored Procedure parsing.
> Thanks for any help given.
> Doug
> PS - Sorry for the cross posting in dotnet.general but I am hoping to get
a
> balanced set of views on this issue.|||I have done the same type of thing in the recent past. The methodology I
have used is to execute a BCP statement into a properly structured table.
BCP is native SQL Server, much faster than a Bulk Insert statement, deals
with security in-line (you specify user.password in the command) and if the
data is consistent (the type of data appears in the same position in each
line) the BCP command will import into the properly formatted table without
any parsing required. The syntax for command is listed in Books On-line.
You will need to create a format file for the import to use. This is simply
executing a BCP FORMAT command against the desired SQL Server destination
table. Once the format file is built, you use that to define for the BCP IN
command the data structure you are importing. It is an extra step to create
the format file, but once you have it you place it in a location where your
process can access it will do the heavy lifting for you.
The advantages to this process are several. First, because you are
pre-defining a data structure to the import process, no additional parsing
is needed. Second, because BCP runs in a DOS environment it is very fast.
Third, because user ID and password are contained in the command line,
connection strings and other security items are unnecessary.
There is one additional caveat to using BCP in a procedure. You will have
to run it in a DOS environment using the xp_cmdshell extended procedure.
This allows SQL Server to run DOS commands from within a stored procedure.
The user ID that runs this will need privileges assigned to the
master.dbo.xp_cmdshell proc in SQL Server Enterprise Manager.
My suggestion for implementation would be to write a simple stored procedure
that builds the BCP statement as a Varchar variable and passes it to
master.dbo.xp_cmdshell to run. Call this stored procedure using the execute
nonquery option of the SQLServer.SQLCommand object in VB.Net. Doing this
will allow for full automation of the import process.
If you need any further assistance you can contact me at
groutme_alternate@.sbcglobal.net.
Good Luck:
groutme in SO Cal.
"Doug R" <DougR@.discussions.microsoft.com> wrote in message
news:D7FEFA89-E6BD-49C9-A0E5-5464130B3440@.microsoft.com...
> Hello,
> I have a system that I am writing to automaticly import Credit Transaction
> data into a SQL Server 2000 Database. I am using a VB.Net application to
> detect when the file arives and prep it for parsing. The file is
> aproximately 10Mb of relatively complex hierarchal data that is defined by
2
> character tokens at the begining of each data line. The structure breaks
out
> into aproximately 6 parent-child related tables with numerous lookup
tables
> on each primary table.
> The previous aproach loaded each line of raw data into an Import table and
> used a Stored Procedure to break down the information into the tables.
The
> Stored Procedure is large and very complex. It also has the problem that
the
> Parsing takes so long I need to implement a very long timeout on my
> connection or I get errors. It is also difficult to track progress
through
> the Import for the user to see.
> The options I see at this point are;
> 1. Use the current approach of loading the raw data into an Import table
and
> Parsing with a Stored Procedure.
> 2. Write the Parsing Routine in VB.NET and use ADO.NET to load the data
into
> the apropriate tables.
> 3. Use a mixed aproach of breaking the massive Stored Procedure into
smaller
> procedures and managing the steps with VB.Net.
> I am looking for any tips and advice that the guru's out there are willing
> to give. Especially a comparision of the effiency of doing ADO.NET bulk
> inserts vs. Stored Procedure parsing.
> Thanks for any help given.
> Doug
> PS - Sorry for the cross posting in dotnet.general but I am hoping to get
a
> balanced set of views on this issue.|||Thanks for the reply. Regretably I have no control over the form of the
input data or I would be using XML. The data is being sent to us from an
outside business.
Are you familiar with ADO.NET for doing bulk inserts? I would be very
interested in hearing the Pros and Cons of Stored Proc vs ADO.NET.
An alternative would possibly be something that parses the import data file
into XML before the insert. Any ideas on how this could be done efficiently
?
"Alejandro Mesa" wrote:
> Doug,
> I have heard that sql server is not good for parsing routines, so this can
> lead you to do it in your client app.
> What about using XML to represent this complex hierarchal data?
>
> AMB
> "Doug R" wrote:
>|||If your stored procedure uses cursors or some other method to processes the
data line-by-line then probably you can rewrite some or all of it as
set-based SQL code for a significant performance improvement.

> Especially a comparision of the effiency of doing ADO.NET bulk
> inserts vs. Stored Procedure parsing
Bulk Insert is equally possible from TSQL or ADO.NET code so this doesn't
seem to me like a meaningful comparison. The real question is whether TSQL o
r
client code can transform the data efficiently. Since this is fundamentally
about data manipulation my money would be on TSQL ... but that's without
seeing the detail of the actual problem.
David Portas
SQL Server MVP
--|||Doug,
If you are subcribed to SQL Server Magazine, there is a good article about
this theme.
Bulk-Insert Options for ADO.NET
http://www.windowsitpro.com/Article...>
oad_7pv0.asp
ADO.NET 2.0 will include this feature.
http://www.windowsitpro.com/SQLServ...62.html

AMB
"Doug R" wrote:
> Thanks for the reply. Regretably I have no control over the form of the
> input data or I would be using XML. The data is being sent to us from an
> outside business.
> Are you familiar with ADO.NET for doing bulk inserts? I would be very
> interested in hearing the Pros and Cons of Stored Proc vs ADO.NET.
> An alternative would possibly be something that parses the import data fil
e
> into XML before the insert. Any ideas on how this could be done efficient
ly?
>
> "Alejandro Mesa" wrote:
>

Wednesday, March 7, 2012

Need a SP to read Table A and update Table B

Hi

I need a SP to read table A (1000 records) and updates Table B. I think I have to use Cursor, but I'm not very good at writing SP. Any help would be appreciated. Thanks.You need to help us a little bit. What, if any relationship exists between Table A and B? Is there a column in each that links one to the other?|||The two tables (A and B) are identical and both have a primary key. What I need to do is to update all rows in Table B with the new one from Table A. This is like a batch update from A to B.

Need a little help with Join (Beginner)

Im writing this stored procedure and just need to add one more column to the mix. But i cant recall exactly what to do with joins. I have examples, but they all look alittle different. Anyways, i realized that the column i want to add (its highlighted) Needs to have a join. Here is my code. Can anyone explain to me, how i join this with the rest. IT is located in a table called Budget_Reporting_Group and the column is called Budget_Reporting_Group_Description. As you can see, I have another Table called Salesperson_Purchaser, Im pretty sure these two tables are relational by a Salesperson_Purchaser_ID. How would i do the join? If anything, can you display what it would look like (IE yourDatabase.dbo.TableName as Table_Name ON etc etc) I completely forgot the format.

USE [RC_STAT]

GO

/****** Object: StoredProcedure [dbo].[PROC_RPT_EXPENSE_DETAIL_T&E_MKT_Copy] Script Date: 06/28/2007 09:49:08 ******/

SET ANSI_NULLS ON

GO

SET QUOTED_IDENTIFIER ON

GO

ALTERPROCEDURE [dbo].[PROC_RPT_EXPENSE_DETAIL_T&E_MKT_COPY]

(@.Region int=Null)

AS

BEGIN

SELECT

[Item_Ledger_Posting_Datetime] Post_Date

,'SMP' Budget_Type

,'Invoice'as Document_Type

,[Item_Ledger_Document_No] Document_Number

,[Item_Description]+' '+'('+[Item_No]+')' Entry_Description

,ISNULL(RC_STAT.dbo.udf_Correct_Price(Item_No, Item_Ledger_Posting_Datetime,'SALESAMP')*-1*Item_Ledger_Invoiced_Qty,Item_Ledger_Cost_Posted_GL *-1 ) Amount

,-1*[Item_Ledger_Invoiced_Qty] Quantity

,Customer_Name

,'' External_Doc_no

,[Item_Ledger_Sales_Responsible] SR_Code

,[Item_Ledger_Mars_Period_Code] ThePeriod

,[Item_Ledger_Mars_Year] TheYear

,Territory.Name AS Territory_Name

,Region.Region AS Region_Name

,Budget_Reporting_Group.Budget_Reporting_Group_Description

FROM [NavisionReplication].[dbo].[Qry_Item_Ledger_Detail]

INNERJOIN NavisionReplication.dbo.Tbl_Salesperson_Purchaser AS Salesperson_Purchaser

ON [Item_Ledger_Sales_Responsible] = Salesperson_Purchaser.SalesPerson_Purchaser_Code

INNERJOIN RC_DWDB_INSTANCE_1.dbo.Territory AS Territory

ON Territory.Code = Salesperson_Purchaser.Territory_Code

INNERJOIN NavisionReplication.dbo.Tbl_Budget_Reporting as Budget_Reporting

ON Salesperson_Purchaser.Salesperson_Purchaser_Code=Budget_Reporting.Salesperson_Purchaser_Code

LEFTOUTERJOIN RC_DWDB_INSTANCE_1.dbo.Region AS Region

ON Territory.Region_Key = Region.Region_Key

WHERE Region.Region_Key = @.Region

AND [Item_Ledger_Mars_Year] = 2007

UNIONALL

SELECT

[GL_Entry_Posting_DateTime]

,[Budget_Type_Code]

,[Document_Type]

,[GL_Entry_Document_No]

,[GL_Entry_Description]

,[GL_Entry_Amount]

,0 Quantity

,[User_ID]

,[GL_Entry_External_Document_No]

,[Sales_Responsible]

,[Mars_Period_Code]

,[Mars_Year]

,Territory.Name AS Territory_Name

,Region.Region AS Region_Name

,Budget_Reporting_Group.Budget_Reporting_Group_Description

FROM [NavisionReplication].[dbo].[Tbl_GL_entry] GL_entry

INNERJOIN [RC_DWDB_INSTANCE_1].[dbo].[Tbl_Budget_Accounts] Budget_Accounts

ON Budget_Accounts.[GL_Account_No] = GL_entry.[GL_Account]

INNERJOIN NavisionReplication.dbo.Tbl_Salesperson_Purchaser AS Salesperson_Purchaser

ON GL_entry.[Sales_Responsible] = Salesperson_Purchaser.SalesPerson_Purchaser_Code

INNERJOIN RC_DWDB_INSTANCE_1.dbo.Territory AS Territory

ON Territory.Code = Salesperson_Purchaser.Territory_Code

LEFTOUTERJOIN RC_DWDB_INSTANCE_1.dbo.Region AS Region

ON Territory.Region_Key = Region.Region_Key

INNERJOIN NavisionReplication.dbo.Tbl_Budget_Reporting as Budget_Reporting

ON Salesperson_Purchaser.Salesperson_Purchaser_Code=Budget_Reporting.Salesperson_Purchaser_Code

WHERE GL_entry.[Mars_Year] = 2007

END

Code Snippet

INNER JOIN Budget_Reporting_Group

ON BUDGET_REPORTING_GROUP.Salesperson_Purchaser_ID = SALESPERSON_PURCHASER.Salesperson_Purchaser_ID

|||

I still keep getting this error:

sg 208, Level 16, State 1, Procedure PROC_RPT_EXPENSE_DETAIL_T&E_MKT_COPY, Line 7

Invalid object name 'Tbl_Budget_Reporting_Group'.

Msg 208, Level 16, State 1, Procedure PROC_RPT_EXPENSE_DETAIL_T&E_MKT_COPY, Line 7

Invalid object name 'Tbl_Budget_Reporting_Group'.

Need a hand...

i've been writing an app for my company that has a front end screen in which the user types in all infos needed (ie. name, address, city, state, etc - 82 fields to be exact) then clicks an "add" button, which i put at the bottom, and have that data dumped into a SQL table... the page is then redirected to another page which reads the record just added and displays all the fields that the user submitted...

here is my front end "add" screen code behind written in C#:

using System;

using System.Data;

using System.Data.SqlClient;

using System.Configuration;

using System.Collections;

using System.Web;

using System.Web.Security;

using System.Web.UI;

using System.Web.UI.WebControls;

using System.Web.UI.WebControls.WebParts;

using System.Web.UI.HtmlControls;

publicpartialclassVinny_Credit_Application_AddCredApp : System.Web.UI.Page

{

protectedvoid Page_Load(object sender,EventArgs e)

{

}

protectedvoid SubmitButton_Click(object sender,EventArgs e)

{

string ConnectionString =ConfigurationManager.ConnectionStrings["ws2dbConnectionString2"].ConnectionString;

SqlConnection connection =newSqlConnection(ConnectionString);

SqlCommand cmd =newSqlCommand(@."INSERT INTO CreditAppFile (

GI_RB_Div,

GI_RB_ExistCust,

GI_TB_LegalFirmName,

GI_TB_Address,

GI_TB_City,

GI_DDL_State,

GI_TB_Zip,

GI_TB_TradeName,

GI_TB_BillAddress,

GI_TB_BillCity,

GI_DDL_BillState,

GI_TB_BillZip,

GI_TB_ContName,

GI_TB_Title,

GI_TB_MobilePager,

GI_TB_Email,

GI_TB_Fax,

GI_TB_BusDesc,

GI_TB_BusStartDate,

GI_TB_BusPhone,

GI_RB_PuchOrdsReq,

GI_RB_BusType,

GI_RB_LiensJudges,

GI_RB_TaxExempt,

GI_TB_FedIDNO,

GI_RB_PriorBankrupt,

GI_TB_PriorBankr,

BFR_TB_ContPhone,

BFR_TB_AcctNum1,

BFR_TB_AcctNum2,

BFR_TB_CurrBal1,

BFR_TB_CurrBal2,

BFR_TB_CurrBal3,

BFR_TB_CurrBal4,

BFR_RB_AcctType,

TR_TB_ContName1,

TR_TB_ContAddr1,

TR_TB_ContCity1,

TR_DDL_ContSt1,

TR_TB_ContZip1,

TR_TB_ContPhone1,

TR_TB_Cont_Acct1,

TR_TB_ContName2,

TR_TB_ContAddr2,

TR_TB_ContCity2,

TR_DDL_ContSt2,

TR_TB_ContZip2,

TR_TB_ContPhone2,

TR_TB_Cont_Acct2,

TR_TB_ContName3,

TR_TB_ContAddr3,

TR_TB_ContCity3,

TR_DDL_ContSt3,

TR_TB_ContZip3,

TR_TB_ContPhone3,

TR_TB_Cont_Acct3,

PI_TB_Name1,

PI_TB_HomeAddr1,

PI_TB_BDay1,

PI_TB_SSNum1,

PI_TB_HomePh1,

PI_TB_PrcntOwn1,

PI_TB_NetWorth1,

PI_TB_AnnInc1,

PI_TB_MonHouPay1,

PI_TB_Name2,

PI_TB_HomeAddr2,

PI_TB_BDay2,

PI_TB_SSNum2,

PI_TB_HomePh2,

PI_TB_PrcntOwn2,

PI_TB_NetWorth2,

PI_TB_AnnInc2,

PI_TB_MonHouPay2,

PI_TB_Name3,

PI_TB_HomeAddr3,

PI_TB_BDay3,

PI_TB_SSNum3,

PI_TB_HomePh3,

PI_TB_PrcntOwn3,

PI_TB_NetWorth3,

PI_TB_AnnInc3,

PI_TB_MonHouPay3

)

VALUES (

@.GI_RB_Div,

@.GI_RB_ExistCust,

@.GI_TB_LegalFirmName,

@.GI_TB_Address,

@.GI_TB_City,

@.GI_DDL_State,

@.GI_TB_Zip,

@.GI_TB_TradeName,

@.GI_TB_BillAddress,

@.GI_TB_BillCity,

@.GI_DDL_BillState,

@.GI_TB_BillZip,

@.GI_TB_ContName,

@.GI_TB_Title,

@.GI_TB_MobilePager,

@.GI_TB_Email,

@.GI_TB_Fax,

@.GI_TB_BusDesc,

@.GI_TB_BusStartDate,

@.GI_TB_BusPhone,

@.GI_RB_PuchOrdsReq,

@.GI_RB_BusType,

@.GI_RB_LiensJudges,

@.GI_RB_TaxExempt,

@.GI_TB_FedIDNO,

@.GI_RB_PriorBankrupt,

@.GI_TB_PriorBankr,

@.BFR_TB_ContPhone,

@.BFR_TB_AcctNum1,

@.BFR_TB_AcctNum2,

@.BFR_TB_CurrBal1,

@.BFR_TB_CurrBal2,

@.BFR_TB_CurrBal3,

@.BFR_TB_CurrBal4,

@.BFR_RB_AcctType,

@.TR_TB_ContName1,

@.TR_TB_ContAddr1,

@.TR_TB_ContCity1,

@.TR_DDL_ContSt1,

@.TR_TB_ContZip1,

@.TR_TB_ContPhone1,

@.TR_TB_Cont_Acct1,

@.TR_TB_ContName2,

@.TR_TB_ContAddr2,

@.TR_TB_ContCity2,

@.TR_DDL_ContSt2,

@.TR_TB_ContZip2,

@.TR_TB_ContPhone2,

@.TR_TB_Cont_Acct2,

@.TR_TB_ContName3,

@.TR_TB_ContAddr3,

@.TR_TB_ContCity3,

@.TR_DDL_ContSt3,

@.TR_TB_ContZip3,

@.TR_TB_ContPhone3,

@.TR_TB_Cont_Acct3,

@.PI_TB_Name1,

@.PI_TB_HomeAddr1,

@.PI_TB_BDay1,

@.PI_TB_SSNum1,

@.PI_TB_HomePh1,

@.PI_TB_PrcntOwn1,

@.PI_TB_NetWorth1,

@.PI_TB_AnnInc1,

@.PI_TB_MonHouPay1,

@.PI_TB_Name2,

@.PI_TB_HomeAddr2,

@.PI_TB_BDay2,

@.PI_TB_SSNum2,

@.PI_TB_HomePh2,

@.PI_TB_PrcntOwn2,

@.PI_TB_NetWorth2,

@.PI_TB_AnnInc2,

@.PI_TB_MonHouPay2,

@.PI_TB_Name3,

@.PI_TB_HomeAddr3,

@.PI_TB_BDay3,

@.PI_TB_SSNum3,

@.PI_TB_HomePh3,

@.PI_TB_PrcntOwn3,

@.PI_TB_NetWorth3,

@.PI_TB_AnnInc3,

@.PI_TB_MonHouPay3

); Select Scope_Identity()"

, connection);

try

{

cmd.Parameters.AddWithValue("@.GI_RB_Div", GI_RB_Div.SelectedValue);

cmd.Parameters.AddWithValue("@.GI_RB_ExistCust", GI_RB_ExistCust.SelectedValue);

cmd.Parameters.AddWithValue("@.GI_TB_LegalFirmName", GI_TB_LegalFirmName.Text);

cmd.Parameters.AddWithValue("@.GI_TB_Address", GI_TB_Address.Text);

cmd.Parameters.AddWithValue("@.GI_TB_City", GI_TB_City.Text);

cmd.Parameters.AddWithValue("@.GI_DDL_State", GI_DDL_State.SelectedValue);

cmd.Parameters.AddWithValue("@.GI_TB_Zip", GI_TB_Zip.Text);

cmd.Parameters.AddWithValue("@.GI_TB_TradeName", GI_TB_TradeName.Text);

cmd.Parameters.AddWithValue("@.GI_TB_BillAddress", GI_TB_BillAddress.Text);

cmd.Parameters.AddWithValue("@.GI_TB_BillCity", GI_TB_BillCity.Text);

cmd.Parameters.AddWithValue("@.GI_DDL_BillState", GI_DDL_BillState.SelectedValue);

cmd.Parameters.AddWithValue("@.GI_TB_BillZip", GI_TB_BillZip.Text);

cmd.Parameters.AddWithValue("@.GI_TB_ContName", GI_TB_ContName.Text);

cmd.Parameters.AddWithValue("@.GI_TB_Title", GI_TB_Title.Text);

cmd.Parameters.AddWithValue("@.GI_TB_MobilePager", GI_TB_MobilePager.Text);

cmd.Parameters.AddWithValue("@.GI_TB_Email", GI_TB_Email.Text);

cmd.Parameters.AddWithValue("@.GI_TB_Fax", GI_TB_Fax.Text);

cmd.Parameters.AddWithValue("@.GI_TB_BusDesc", GI_TB_BusDesc.Text);

cmd.Parameters.AddWithValue("@.GI_TB_BusStartDate", GI_TB_BusStartDate.Text);

cmd.Parameters.AddWithValue("@.GI_TB_BusPhone", GI_TB_BusPhone.Text);

cmd.Parameters.AddWithValue("@.GI_RB_PuchOrdsReq", GI_RB_PuchOrdsReq.SelectedValue);

cmd.Parameters.AddWithValue("@.GI_RB_BusType", GI_RB_BusType.SelectedValue);

cmd.Parameters.AddWithValue("@.GI_RB_LiensJudges", GI_RB_LiensJudges.SelectedValue);

cmd.Parameters.AddWithValue("@.GI_RB_TaxExempt", GI_RB_TaxExempt.SelectedValue);

cmd.Parameters.AddWithValue("@.GI_TB_FedIDNO", GI_TB_FedIDNO.Text);

cmd.Parameters.AddWithValue("@.GI_RB_PriorBankrupt", GI_RB_PriorBankrupt.SelectedValue);

cmd.Parameters.AddWithValue("@.GI_TB_PriorBankr", GI_TB_PriorBankr.Text);

cmd.Parameters.AddWithValue("@.BFR_TB_ContPhone", BFR_TB_ContPhone.Text);

cmd.Parameters.AddWithValue("@.BFR_TB_AcctNum1", BFR_TB_AcctNum1.Text);

cmd.Parameters.AddWithValue("@.BFR_TB_AcctNum2", BFR_TB_AcctNum2.Text);

cmd.Parameters.AddWithValue("@.BFR_TB_CurrBal1", BFR_TB_CurrBal1.Text);

cmd.Parameters.AddWithValue("@.BFR_TB_CurrBal2", BFR_TB_CurrBal2.Text);

cmd.Parameters.AddWithValue("@.BFR_TB_CurrBal3", BFR_TB_CurrBal3.Text);

cmd.Parameters.AddWithValue("@.BFR_TB_CurrBal4", BFR_TB_CurrBal4.Text);

cmd.Parameters.AddWithValue("@.BFR_RB_AcctType", BFR_RB_AcctType.Text);

cmd.Parameters.AddWithValue("@.TR_TB_ContName1", TR_TB_ContName1.Text);

cmd.Parameters.AddWithValue("@.TR_TB_ContAddr1", TR_TB_ContAddr1.Text);

cmd.Parameters.AddWithValue("@.TR_TB_ContCity1", TR_TB_ContCity1.Text);

cmd.Parameters.AddWithValue("@.TR_DDL_ContSt1", TR_DDL_ContSt1.SelectedValue);

cmd.Parameters.AddWithValue("@.TR_TB_ContZip1", TR_TB_ContZip1.Text);

cmd.Parameters.AddWithValue("@.TR_TB_ContPhone1", TR_TB_ContPhone1.Text);

cmd.Parameters.AddWithValue("@.TR_TB_Cont_Acct1", TR_TB_Cont_Acct1.Text);

cmd.Parameters.AddWithValue("@.TR_TB_ContName2", TR_TB_ContName2.Text);

cmd.Parameters.AddWithValue("@.TR_TB_ContAddr2", TR_TB_ContAddr2.Text);

cmd.Parameters.AddWithValue("@.TR_TB_ContCity2", TR_TB_ContCity2.Text);

cmd.Parameters.AddWithValue("@.TR_DDL_ContSt2", TR_DDL_ContSt2.SelectedValue);

cmd.Parameters.AddWithValue("@.TR_TB_ContZip2", TR_TB_ContZip2.Text);

cmd.Parameters.AddWithValue("@.TR_TB_ContPhone2", TR_TB_ContPhone2.Text);

cmd.Parameters.AddWithValue("@.TR_TB_Cont_Acct2", TR_TB_Cont_Acct2.Text);

cmd.Parameters.AddWithValue("@.TR_TB_ContName3", TR_TB_ContName3.Text);

cmd.Parameters.AddWithValue("@.TR_TB_ContAddr3", TR_TB_ContAddr3.Text);

cmd.Parameters.AddWithValue("@.TR_TB_ContCity3", TR_TB_ContCity3.Text);

cmd.Parameters.AddWithValue("@.TR_DDL_ContSt3", TR_DDL_ContSt3.SelectedValue);

cmd.Parameters.AddWithValue("@.TR_TB_ContZip3", TR_TB_ContZip3.Text);

cmd.Parameters.AddWithValue("@.TR_TB_ContPhone3", TR_TB_ContPhone3.Text);

cmd.Parameters.AddWithValue("@.TR_TB_Cont_Acct3", TR_TB_Cont_Acct3.Text);

cmd.Parameters.AddWithValue("@.PI_TB_Name1", PI_TB_Name1.Text);

cmd.Parameters.AddWithValue("@.PI_TB_HomeAddr1", PI_TB_HomeAddr1.Text);

cmd.Parameters.AddWithValue("@.PI_TB_BDay1", PI_TB_BDay1.Text);

cmd.Parameters.AddWithValue("@.PI_TB_SSNum1", PI_TB_SSNum1.Text);

cmd.Parameters.AddWithValue("@.PI_TB_HomePh1", PI_TB_HomePh1.Text);

cmd.Parameters.AddWithValue("@.PI_TB_PrcntOwn1", PI_TB_PrcntOwn1.Text);

cmd.Parameters.AddWithValue("@.PI_TB_NetWorth1", PI_TB_NetWorth1.Text);

cmd.Parameters.AddWithValue("@.PI_TB_AnnInc1", PI_TB_AnnInc1.Text);

cmd.Parameters.AddWithValue("@.PI_TB_MonHouPay1", PI_TB_MonHouPay1.Text);

cmd.Parameters.AddWithValue("@.PI_TB_Name2", PI_TB_Name2.Text);

cmd.Parameters.AddWithValue("@.PI_TB_HomeAddr2", PI_TB_HomeAddr2.Text);

cmd.Parameters.AddWithValue("@.PI_TB_BDay2", PI_TB_BDay2.Text);

cmd.Parameters.AddWithValue("@.PI_TB_SSNum2", PI_TB_SSNum2.Text);

cmd.Parameters.AddWithValue("@.PI_TB_HomePh2", PI_TB_HomePh2.Text);

cmd.Parameters.AddWithValue("@.PI_TB_PrcntOwn2", PI_TB_PrcntOwn2.Text);

cmd.Parameters.AddWithValue("@.PI_TB_NetWorth2", PI_TB_NetWorth2.Text);

cmd.Parameters.AddWithValue("@.PI_TB_AnnInc2", PI_TB_AnnInc2.Text);

cmd.Parameters.AddWithValue("@.PI_TB_MonHouPay2", PI_TB_MonHouPay2.Text);

cmd.Parameters.AddWithValue("@.PI_TB_Name3", PI_TB_Name3.Text);

cmd.Parameters.AddWithValue("@.PI_TB_HomeAddr3", PI_TB_HomeAddr3.Text);

cmd.Parameters.AddWithValue("@.PI_TB_BDay3", PI_TB_BDay3.Text);

cmd.Parameters.AddWithValue("@.PI_TB_SSNum3", PI_TB_SSNum3.Text);

cmd.Parameters.AddWithValue("@.PI_TB_HomePh3", PI_TB_HomePh3.Text);

cmd.Parameters.AddWithValue("@.PI_TB_PrcntOwn3", PI_TB_PrcntOwn3.Text);

cmd.Parameters.AddWithValue("@.PI_TB_NetWorth3", PI_TB_NetWorth3.Text);

cmd.Parameters.AddWithValue("@.PI_TB_AnnInc3", PI_TB_AnnInc3.Text);

cmd.Parameters.AddWithValue("@.PI_TB_MonHouPay3", PI_TB_MonHouPay3.Text);

cmd.Connection = connection;

cmd.Connection.Open();

string NewID = cmd.ExecuteScalar().ToString();

cmd.Connection.Close();

Response.Redirect("DisplayCredApp.aspx?ID=" + Request["NewID"]);

}

catch (Exception ex)

{

lblMessage.Text ="ERROR: " + ex.Message;lblMessage.Visible =true;

}

}

}

this seems to be ok... but i get a load of errors on my "read/display" page which looks like the folowing... (this is the code behind, again, written in C#)

using System;

using System.Data;

using System.Data.SqlClient;

using System.Configuration;

using System.Collections;

using System.Web;

using System.Web.Security;

using System.Web.UI;

using System.Web.UI.WebControls;

using System.Web.UI.WebControls.WebParts;

using System.Web.UI.HtmlControls;

publicpartialclassVinny_Credit_Application_DisplayCredApp : System.Web.UI.Page

{

protectedvoid Page_Load(object sender,EventArgs e)

{

if (!IsPostBack && Response["NewID"] !=null)

{

string ConnectionString =ConfigurationManager.ConnectionStrings["ws2dbConnectionString"].ConnectionString;

SqlConnection connection =newSqlConnection(ConnectionString);

SqlCommand cmd =newSqlCommand(@."SELECT * FROM CreditAppFile WHERE ID = @.ID", connection);cmd.Parameters.Add("@.ID", Response["NewID"].ToString());

connection.Open();

SqlDataReader reader = cmd.ExecuteReader();

reader.Read();

GI_RB_Div.Text = reader["GI_RB_Div"].ToString();

GI_RB_ExistCust.Text = reader["GI_RB_ExistCust"].ToString();

GI_TB_LegalFirmName.Text = reader["GI_TB_LegalFirmName"].ToString();

GI_TB_Address.Text = reader["GI_TB_Address"].ToString();

GI_TB_City.Text = reader["GI_TB_City"].ToString();

GI_DDL_State.Text = reader["GI_DDL_State"].ToString();

GI_TB_Zip.Text = reader["GI_TB_Zip"].ToString();

GI_TB_TradeName.Text = reader["GI_TB_TradeName"].ToString();

GI_TB_BillAddress.Text = reader["GI_TB_BillAddress"].ToString();

GI_TB_BillCity.Text = reader["GI_TB_BillCity"].ToString();

GI_DDL_BillState.Text = reader["GI_DDL_BillState"].ToString();

GI_TB_BillZip.Text = reader["GI_TB_BillZip"].ToString();

GI_TB_ContName.Text = reader["GI_TB_ContName"].ToString();

GI_TB_Title.Text = reader["GI_TB_Title"].ToString();

GI_TB_MobilePager.Text = reader["GI_TB_MobilePager"].ToString();

GI_TB_Email.Text = reader["GI_TB_Email"].ToString();

GI_TB_Fax.Text = reader["GI_TB_Fax"].ToString();

GI_TB_BusDesc.Text = reader["GI_TB_BusDesc"].ToString();

GI_TB_BusStartDate.Text = reader["GI_TB_BusStartDate"].ToString();

GI_TB_BusPhone.Text = reader["GI_TB_BusPhone"].ToString();

GI_RB_PuchOrdsReq.Text = reader["GI_RB_PuchOrdsReq"].ToString();

GI_RB_BusType.Text = reader["GI_RB_BusType"].ToString();

GI_RB_LiensJudges.Text = reader["GI_RB_LiensJudges"].ToString();

GI_RB_TaxExempt.Text = reader["GI_RB_TaxExempt"].ToString();

GI_TB_FedIDNO.Text = reader["GI_TB_FedIDNO"].ToString();

GI_RB_PriorBankrupt.Text = reader["GI_RB_PriorBankrupt"].ToString();

GI_TB_PriorBankr.Text = reader["GI_TB_PriorBankr"].ToString();

BFR_TB_ContPhone.Text = reader["BFR_TB_ContPhone"].ToString();

BFR_TB_AcctNum1.Text = reader["BFR_TB_AcctNum1"].ToString();

BFR_TB_AcctNum2.Text = reader["BFR_TB_AcctNum2"].ToString();

BFR_TB_CurrBal1.Text = reader["BFR_TB_CurrBal1"].ToString();

BFR_TB_CurrBal2.Text = reader["BFR_TB_CurrBal2"].ToString();

BFR_TB_CurrBal3.Text = reader["BFR_TB_CurrBal3"].ToString();

BFR_TB_CurrBal4.Text = reader["BFR_TB_CurrBal4"].ToString();

BFR_RB_AcctType.Text = reader["BFR_RB_AcctType"].ToString();

TR_TB_ContName1.Text = reader["TR_TB_ContName1"].ToString();

TR_TB_ContAddr1.Text = reader["TR_TB_ContAddr1"].ToString();

TR_TB_ContCity1.Text = reader["TR_TB_ContCity1"].ToString();

TR_DDL_ContSt1.Text = reader["TR_DDL_ContSt1"].ToString();

TR_TB_ContZip1.Text = reader["TR_TB_ContZip1"].ToString();

TR_TB_ContPhone1.Text = reader["TR_TB_ContPhone1"].ToString();

TR_TB_Cont_Acct1.Text = reader["TR_TB_Cont_Acct1"].ToString();

TR_TB_ContName2.Text = reader["TR_TB_ContName2"].ToString();

TR_TB_ContAddr2.Text = reader["TR_TB_ContAddr2"].ToString();

TR_TB_ContCity2.Text = reader["TR_TB_ContCity2"].ToString();

TR_DDL_ContSt2.Text = reader["TR_DDL_ContSt2"].ToString();

TR_TB_ContZip2.Text = reader["TR_TB_ContZip2"].ToString();

TR_TB_ContPhone2.Text = reader["TR_TB_ContPhone2"].ToString();

TR_TB_Cont_Acct2.Text = reader["TR_TB_Cont_Acct2"].ToString();

TR_TB_ContName3.Text = reader["TR_TB_ContName3"].ToString();

TR_TB_ContAddr3.Text = reader["TR_TB_ContAddr3"].ToString();

TR_TB_ContCity3.Text = reader["TR_TB_ContCity3"].ToString();

TR_DDL_ContSt3.Text = reader["TR_DDL_ContSt3"].ToString();

TR_TB_ContZip3.Text = reader["TR_TB_ContZip3"].ToString();

TR_TB_ContPhone3.Text = reader["TR_TB_ContPhone3"].ToString();

TR_TB_Cont_Acct3.Text = reader["TR_TB_Cont_Acct3"].ToString();

PI_TB_Name1.Text = reader["PI_TB_Name1"].ToString();

PI_TB_HomeAddr1.Text = reader["PI_TB_HomeAddr1"].ToString();

PI_TB_BDay1.Text = reader["PI_TB_BDay1"].ToString();

PI_TB_SSNum1.Text = reader["PI_TB_SSNum1"].ToString();

PI_TB_HomePh1.Text = reader["PI_TB_HomePh1"].ToString();

PI_TB_PrcntOwn1.Text = reader["PI_TB_PrcntOwn1"].ToString();

PI_TB_NetWorth1.Text = reader["PI_TB_NetWorth1"].ToString();

PI_TB_AnnInc1.Text = reader["PI_TB_AnnInc1"].ToString();

PI_TB_MonHouPay1.Text = reader["PI_TB_MonHouPay1"].ToString();

PI_TB_Name2.Text = reader["PI_TB_Name2"].ToString();

PI_TB_HomeAddr2.Text = reader["PI_TB_HomeAddr2"].ToString();

PI_TB_BDay2.Text = reader["PI_TB_BDay2"].ToString();

PI_TB_SSNum2.Text = reader["PI_TB_SSNum2"].ToString();

PI_TB_HomePh2.Text = reader["PI_TB_HomePh2"].ToString();

PI_TB_PrcntOwn2.Text = reader["PI_TB_PrcntOwn2"].ToString();

PI_TB_NetWorth2.Text = reader["PI_TB_NetWorth2"].ToString();

PI_TB_AnnInc2.Text = reader["PI_TB_AnnInc2"].ToString();

PI_TB_Name2.Text = reader["PI_TB_MonHouPay2"].ToString();

PI_TB_Name3.Text = reader["PI_TB_Name3"].ToString();

PI_TB_HomeAddr3.Text = reader["PI_TB_HomeAddr3"].ToString();

PI_TB_BDay3.Text = reader["PI_TB_BDay3"].ToString();

PI_TB_SSNum3.Text = reader["PI_TB_SSNum3"].ToString();

PI_TB_HomePh3.Text = reader["PI_TB_HomePh3"].ToString();

PI_TB_PrcntOwn3.Text = reader["PI_TB_PrcntOwn3"].ToString();

PI_TB_NetWorth3.Text = reader["PI_TB_NetWorth3"].ToString();

PI_TB_AnnInc3.Text = reader["PI_TB_AnnInc3"].ToString();PI_TB_MonHouPay3.Text = reader["PI_TB_MonHouPay3"].ToString();

connection.Close();

}

}

}

been working on this for days... everytime i get a little closer i seem to get that much farther away... if you can help by all means give me what you got...

thanks for all the help in advance!!!!

- Vinny

Hi Vinny,

Thats alot of columns in that table. Anyway what is the error message you are getting. It would help to know where it stops.

|||

VinnyPip:

string NewID = cmd.ExecuteScalar().ToString();

cmd.Connection.Close();

Response.Redirect("DisplayCredApp.aspx?ID=" + Request["NewID"]);

.

.

.

SqlCommand cmd =newSqlCommand(@."SELECT * FROM CreditAppFile WHERE ID = @.ID", connection);cmd.Parameters.Add("@.ID", Response["NewID"].ToString());

Change

Response.Redirect("DisplayCredApp.aspx?ID=" + Request["NewID"]);

to

Response.Redirect("DisplayCredApp.aspx?ID=" +NewID);

Change

SqlCommand cmd =newSqlCommand(@."SELECT * FROM CreditAppFile WHERE ID = @.ID", connection);cmd.Parameters.Add("@.ID", Response["NewID"].ToString());

to

SqlCommand cmd =newSqlCommand(@."SELECT * FROM CreditAppFile WHERE ID = @.ID", connection);cmd.Parameters.Add("@.ID", Request.QueryString["NewID"]);

|||

made the above changes Mike suggested and the main error is still the same...

Description:An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.

Compiler Error Message:CS0021: Cannot apply indexing with [] to an expression of type 'System.Web.HttpResponse'

Source Error:

Line 15: protected void Page_Load(object sender, EventArgs e)Line 16: {Line 17: if (!IsPostBack && Response["NewID"] != null)Line 18: {Line 19: string ConnectionString = ConfigurationManager.ConnectionStrings["ws2dbConnectionString"].ConnectionString;

|||

Damn. Missed that one. Change it to

if (!IsPostBack && Request.QueryString["ID"] != null)

And - where I changed something to Request,QueryString["NewID"] before (in the parameters), change that to

Request.QueryString["ID"]
|||

that seemed to compile ok...

and for my next trick... uhh... i mean error:

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.InvalidOperationException: Invalid attempt to read when no data is present.

Source Error:

Line 29: reader.Read();Line 30:Line 31: GI_RB_Div.Text = reader["GI_RB_Div"].ToString();Line 32: GI_RB_ExistCust.Text = reader["GI_RB_ExistCust"].ToString();Line 33: GI_TB_LegalFirmName.Text = reader["GI_TB_LegalFirmName"].ToString();


keep em comin' mike... really appreciate this!!!

|||

NEVERMIND MIKE!!!!!!!!

IT WORKS!!!!!!

next time you're in NYC the drinks are on me... thanks a ton!!!

|||That suggests there is no data. Check the value of ID in the querystring of the page to make sure it was passed correctly (no spaces or odd urlencoded chars), then try running the query in SSMS to see that it works.

Saturday, February 25, 2012

Need - help to create DLOOKUP with SSIS

Hi,

Does anybody knows how to create a DLOOKUP (dynamic lookup) in SSIS withour writing any kind of script?
I need to test records existance in destination from the source before inserting or updating in the destination (if the record exist in destination then update, else insert).

Any help apreciated.
I find the Lookup component works best for this. Jamie wrote an article that compares lookup as well as other methods.
http://www.sqlis.com/default.aspx?311
Adrian