Showing posts with label app. Show all posts
Showing posts with label app. Show all posts

Monday, March 26, 2012

Need Help

I have a web app in asp.net which has 8 textboxes

the user searches the database and the search result is shown in a datagrid

the user has the option to select any records displayed using a checkbox

and they can enter values into the textboxes (or leave it empty) and when they say edit

the app updates the database the selected rows with values from the 8 textboxes id any of the text boxes are empty or "" then the existing value in that column has to be retained if the text box is not empty then then the new value is updated

the way i am doing it now is putting the update statement in a for loop and checking if the text box is not null and then updating the DB for that row

the problem is that if the user selects 5000 rows then the app has to do 5000 updates.

and it is a big performance problem

I want to do this update in the SQL 2000 by using a Stored Proc or do I need to use a Cursor

can somebody help me with small code snippet ..

Thanks

PKGCan you show us some code? Like what the update looks like?

In your case though, I might use a work table...and do the updates on the server...|||Originally posted by Brett Kaiser
Can you show us some code? Like what the update looks like?

In your case though, I might use a work table...and do the updates on the server...

here is a sample update statement

UPDATE BIRECIN SET GLDEBIT = '789945562.524', GLCREDIT ='74859612.586' WHERE EntryClass = 'AADM' and AccCode ='MDH' and RevArea='CCU '

then..


UPDATE BIRECIN SET GLDEBIT = '789945562.524', GLCREDIT ='74859612.586' WHERE EntryClass = 'AAFM' and AccCode ='MDH' and RevArea='CCI '

this update statement is inside a for loop and gets executed for n number of rows|||Use the isnull function

Update YourTable
Set YourExistingValue = isnull(@.YourNewValue, YourExistingValue)
From YourTable
Where Keyfield = @.KeyField

If @.YourNewValue is null, the old value is retained.

If you can't submit null values, but have to submit zero-length strings instead, this should work:
Set YourExistingValue = isnull(null(@.YourNewValue, ''), YourExistingValue)

blindman|||Yeah, ok, but he wants to update an entire record set back to the database...

How would you do that...

He says he's looping like 5,000 times...

How do you get the data?|||I get it. The table he is updating with the check boxes isn't in SQL server. It's a dataset in his asp page?

Criminy. That's an asp problem, and out of my scope.

blindman|||Is there some way in asp to write the records (or just the checked ones) back into a temporary table that he could then join to his raw data tables?

blindman|||Yeah, that's what I was thinking, so he could do a set based op instead..

like bcp the data or is there an asp method...

There's got to be asp forums someplace...

We got the db section covered|||How about ...

Here (http://www.dbforums.com/forumdisplay.php?forumid=192)

Guys .. dont you ever look outside
dBforums Database Server Software Microsoft SQL Server|||Originally posted by Enigma
How about ...

Here (http://www.dbforums.com/forumdisplay.php?forumid=192)

Guys .. dont you ever look outside
dBforums Database Server Software Microsoft SQL Server

Sure do:

http://www.sqlteam.com/default.asp

Front end stuff...No thanks...see what a vb developer is making?

Enough to muddle through...not enough to be tapped to code...

The horror...the sheer horror...

Besides...I make all of the developers call stored procedures...they just present what I give them..|||The way the world should be. We cook the food. They can arrange it on the plate. Bon apetit', and my complements to the chef.

blindman|||Originally posted by blindman
The way the world should be. We cook the food. They can arrange it on the plate. Bon apetit', and my complements to the chef.

blindman

That's a GREAT analogy...

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 A writen Help about writen application with RS.

I need to write VB.NET or C# App. that have an input
boxes that tansfer their content to RS parameters
and then renders the report.
thanks.You can take a look at the ReportViewer sample provided
with the RS installation.
>--Original Message--
> I need to write VB.NET or C# App. that have an input
>boxes that tansfer their content to RS parameters
>and then renders the report.
>
>thanks.
>
>.
>

Wednesday, March 7, 2012

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

nedd some help with datetime

Hi,
I am passing datetime from my vb.net app for storage in sql server like this
Dim DT As DateTime = DateTime.Now
Dim str As String
str = DT.ToString("MMddyyyyHHmmss")
...insert to database str (example datetime 10312005135802)
The table column datatype is char(15). How can I convert this to datetime in
sql server? I have an sp that need to look at both the date and time. I was
trying this
declare @.dateandtime datetime
select @.dateandtime = convert(datetime,datetimecolumn,120) from tablea where
id = 1234
select @.dateandtime
I am getting the error "syntax error converting datetime from character
string".
Or should I change the format I am sending the datetime from my vb.net app?
Thanks"Chris" <Chris@.discussions.microsoft.com> wrote in message
news:01A96FD0-238C-42A8-AEF5-3BE330EC9EDC@.microsoft.com...
> Hi,
> I am passing datetime from my vb.net app for storage in sql server like
> this
> Dim DT As DateTime = DateTime.Now
> Dim str As String
> str = DT.ToString("MMddyyyyHHmmss")
> ...insert to database str (example datetime 10312005135802)
> The table column datatype is char(15). How can I convert this to datetime
> in
> sql server? I have an sp that need to look at both the date and time. I
> was
> trying this
> declare @.dateandtime datetime
> select @.dateandtime = convert(datetime,datetimecolumn,120) from tablea
> where
> id = 1234
> select @.dateandtime
> I am getting the error "syntax error converting datetime from character
> string".
> Or should I change the format I am sending the datetime from my vb.net
> app?
> Thanks
Any reason why you appear to be using dynamic SQL to do this? Pass the date
as an adDBTimeStamp type using the ADO parameters collection. That way the
conversion to SQL DATETIME is implicit. Also, you should typically call a
proc for a simple INSERT rather than constuct a dynamic SQL string in code.
See the Using Parameters topic in the ADO section of Books Online.
David Portas
SQL Server MVP
--|||> The table column datatype is char(15).
WHY? Do you put ice cream in your medicine cabinet too?
Pass it as a proper date time value, store it as a proper date time value,
and you will be amazed how many of these silly string conversion problems
magically disappear.|||Honestly, I was thinking the same thing, however, I have noticed in a few
articles a while ago where data is stored as strings and taught I was wrong
all along to use datetime type in my database when I need to pass and store
date and time form my front end app.
Thanks for rebooting that section.
"Aaron Bertrand [SQL Server MVP]" wrote:

> WHY? Do you put ice cream in your medicine cabinet too?
> Pass it as a proper date time value, store it as a proper date time value,
> and you will be amazed how many of these silly string conversion problems
> magically disappear.
>
>