473,378 Members | 1,493 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

Response.Write

Below I note that my response.write is adding spaces after the characters. I
use this code as Middleware, an application calls this page passing the
LogonID and the page is suppose to returen the password from the database.
It does but then when I open the file where I save this i notice I have
extra spaces after the password? Is there a better way to pass this data
back to my app?

<%@ Import Namespace="System.Data.SqlClient" %>
<%@ Import Namespace="System.Data" %>
<%

Dim conMMTMP As SqlConnection
Dim cmdSelect As SqlCommand
dim parmPassword As SqlParameter

conMMTMP = New SqlConnection(
"server=localhost;UID=sa;PWD=1amINIT2;database=mmt mp")
cmdSelect = New SqlCommand( "GetParam" , conMMTMP)
cmdSelect.CommandType = CommandType.StoredProcedure

cmdSelect.Parameters.Add( "@LogonID", Request.Querystring("LogonID"))

parmPassword = cmdSelect.Parameters.Add("@passwd", SqlDbType.Varchar)
parmPassword.Size = 40
parmPassword.Direction = ParameterDirection.Output

conMMTMP.Open()
cmdSelect.ExecuteNonQuery()

'Some reason it adds 12 spaces after the password!
response.write(cmdSelect.Parameters("@passwd").val ue)

conMMTMP.Close()
%>
Nov 18 '05 #1
4 1897
Can I just add that in future, you don't include your Connection String
details (which include your Username and Password) - this could compromise
your security.

If you need to explain the connection string on this newsgroup then use
dummy data or something like UID={username}; PWD={password}

Regards
Paul.

"Toby Boogerd" <tw****@hickorytech.net> wrote in message
news:e0**************@tk2msftngp13.phx.gbl...
Below I note that my response.write is adding spaces after the characters. I use this code as Middleware, an application calls this page passing the
LogonID and the page is suppose to returen the password from the database.
It does but then when I open the file where I save this i notice I have
extra spaces after the password? Is there a better way to pass this data
back to my app?

<%@ Import Namespace="System.Data.SqlClient" %>
<%@ Import Namespace="System.Data" %>
<%

Dim conMMTMP As SqlConnection
Dim cmdSelect As SqlCommand
dim parmPassword As SqlParameter

conMMTMP = New SqlConnection(
"server=localhost;UID=sa;PWD=1amINIT2;database=mmt mp")
cmdSelect = New SqlCommand( "GetParam" , conMMTMP)
cmdSelect.CommandType = CommandType.StoredProcedure

cmdSelect.Parameters.Add( "@LogonID", Request.Querystring("LogonID"))

parmPassword = cmdSelect.Parameters.Add("@passwd", SqlDbType.Varchar)
parmPassword.Size = 40
parmPassword.Direction = ParameterDirection.Output

conMMTMP.Open()
cmdSelect.ExecuteNonQuery()

'Some reason it adds 12 spaces after the password!
response.write(cmdSelect.Parameters("@passwd").val ue)

conMMTMP.Close()
%>

Nov 18 '05 #2
On 7/29/2004 10:52 AM, Toby Boogerd wrote:
Below I note that my response.write is adding spaces after the characters. I
use this code as Middleware, an application calls this page passing the
LogonID and the page is suppose to returen the password from the database.
It does but then when I open the file where I save this i notice I have
extra spaces after the password? Is there a better way to pass this data
back to my app?

<%@ Import Namespace="System.Data.SqlClient" %>
<%@ Import Namespace="System.Data" %>
<%

Dim conMMTMP As SqlConnection
Dim cmdSelect As SqlCommand
dim parmPassword As SqlParameter

conMMTMP = New SqlConnection(
"server=localhost;UID=sa;PWD=1amINIT2;database=mmt mp")
cmdSelect = New SqlCommand( "GetParam" , conMMTMP)
cmdSelect.CommandType = CommandType.StoredProcedure

cmdSelect.Parameters.Add( "@LogonID", Request.Querystring("LogonID"))

parmPassword = cmdSelect.Parameters.Add("@passwd", SqlDbType.Varchar)
parmPassword.Size = 40
parmPassword.Direction = ParameterDirection.Output

conMMTMP.Open()
cmdSelect.ExecuteNonQuery()

'Some reason it adds 12 spaces after the password!
response.write(cmdSelect.Parameters("@passwd").val ue)

conMMTMP.Close()
%>


are you sure that the password column in the database is defined
correctly? As a varchar? That could be padding it (or the sproc
itself), run the sproc in Query Analyzer and see if it's padded. Then
you can tell if it's in the code or the DB side.

If that isn't the case, try removing the .Size=40 line. Don't know if
that would cause this....

What does it look like in your debugger? Look at
cmdSelect.Parameters("@passwd").value in debug mode and see if it's
padded there....

Also, what does it mean 'file where I save this notice'...are you
writing something to file? Where and how is that setup?

--
Craig Deelsnyder
Microsoft MVP - ASP/ASP.NET
Nov 18 '05 #3
It seems my database is padding. I changed the type to char(8) and it still
pads it for example password=bcc it puts bcc with 5 spaces
If I take parPassword.Size = 8 out then my code doesn't work i get an error
saying @passwd is 0
How can I set this up so it doens't pad?

"Craig Deelsnyder" <cdeelsny@NO_SPAM_4_MEyahoo.com> wrote in message
news:ON*************@TK2MSFTNGP12.phx.gbl...
On 7/29/2004 10:52 AM, Toby Boogerd wrote:
Below I note that my response.write is adding spaces after the characters. I use this code as Middleware, an application calls this page passing the
LogonID and the page is suppose to returen the password from the database. It does but then when I open the file where I save this i notice I have
extra spaces after the password? Is there a better way to pass this data
back to my app?

<%@ Import Namespace="System.Data.SqlClient" %>
<%@ Import Namespace="System.Data" %>
<%

Dim conMMTMP As SqlConnection
Dim cmdSelect As SqlCommand
dim parmPassword As SqlParameter

conMMTMP = New SqlConnection(
"server=localhost;UID=sa;PWD=1amINIT2;database=mmt mp")
cmdSelect = New SqlCommand( "GetParam" , conMMTMP)
cmdSelect.CommandType = CommandType.StoredProcedure

cmdSelect.Parameters.Add( "@LogonID", Request.Querystring("LogonID"))

parmPassword = cmdSelect.Parameters.Add("@passwd", SqlDbType.Varchar)
parmPassword.Size = 40
parmPassword.Direction = ParameterDirection.Output

conMMTMP.Open()
cmdSelect.ExecuteNonQuery()

'Some reason it adds 12 spaces after the password!
response.write(cmdSelect.Parameters("@passwd").val ue)

conMMTMP.Close()
%>


are you sure that the password column in the database is defined
correctly? As a varchar? That could be padding it (or the sproc
itself), run the sproc in Query Analyzer and see if it's padded. Then
you can tell if it's in the code or the DB side.

If that isn't the case, try removing the .Size=40 line. Don't know if
that would cause this....

What does it look like in your debugger? Look at
cmdSelect.Parameters("@passwd").value in debug mode and see if it's
padded there....

Also, what does it mean 'file where I save this notice'...are you
writing something to file? Where and how is that setup?

--
Craig Deelsnyder
Microsoft MVP - ASP/ASP.NET

Nov 18 '05 #4
On 7/29/2004 11:49 AM, Toby Boogerd wrote:
It seems my database is padding. I changed the type to char(8) and it still
pads it for example password=bcc it puts bcc with 5 spaces
If I take parPassword.Size = 8 out then my code doesn't work i get an error
saying @passwd is 0
How can I set this up so it doens't pad?

"Craig Deelsnyder" <cdeelsny@NO_SPAM_4_MEyahoo.com> wrote in message
news:ON*************@TK2MSFTNGP12.phx.gbl...
On 7/29/2004 10:52 AM, Toby Boogerd wrote:

Below I note that my response.write is adding spaces after the
characters. I
use this code as Middleware, an application calls this page passing the
LogonID and the page is suppose to returen the password from the
database.
It does but then when I open the file where I save this i notice I have
extra spaces after the password? Is there a better way to pass this data
back to my app?

<%@ Import Namespace="System.Data.SqlClient" %>
<%@ Import Namespace="System.Data" %>
<%

Dim conMMTMP As SqlConnection
Dim cmdSelect As SqlCommand
dim parmPassword As SqlParameter

conMMTMP = New SqlConnection(
"server=localhost;UID=sa;PWD=1amINIT2;database= mmtmp")
cmdSelect = New SqlCommand( "GetParam" , conMMTMP)
cmdSelect.CommandType = CommandType.StoredProcedure

cmdSelect.Parameters.Add( "@LogonID", Request.Querystring("LogonID"))

parmPassword = cmdSelect.Parameters.Add("@passwd", SqlDbType.Varchar)
parmPassword.Size = 40
parmPassword.Direction = ParameterDirection.Output

conMMTMP.Open()
cmdSelect.ExecuteNonQuery()

'Some reason it adds 12 spaces after the password!
response.write(cmdSelect.Parameters("@passwd"). value)

conMMTMP.Close()
%>

are you sure that the password column in the database is defined
correctly? As a varchar? That could be padding it (or the sproc
itself), run the sproc in Query Analyzer and see if it's padded. Then
you can tell if it's in the code or the DB side.

If that isn't the case, try removing the .Size=40 line. Don't know if
that would cause this....

What does it look like in your debugger? Look at
cmdSelect.Parameters("@passwd").value in debug mode and see if it's
padded there....

Also, what does it mean 'file where I save this notice'...are you
writing something to file? Where and how is that setup?

--
Craig Deelsnyder
Microsoft MVP - ASP/ASP.NET


use varchar(8) (or whatever size you need) instead...using a char type,
the database always allocates that number of spaces for that column, and
will pad values as they're inserted. a varchar type says 'this is the
max number needed' and the database only uses what's needed (doesn't
pad). usually varchar is better for this reason, unless you know
something will always be '2 chars' for example (like a non-nullable
state code).

--
Craig Deelsnyder
Microsoft MVP - ASP/ASP.NET
Nov 18 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Ricardo | last post by:
Hi. How should I pass a " (doble-quote) character to response.write() in order for it to be sent to the output ? Thanks in advance for the help.
2
by: Rob McLennan - ZETLAND | last post by:
Hi, I'm relatively clueless when it comes to correct ASP syntax. I'm testing out a search form for my company's website which is done in ASP. The results are displayed as per the code shown at the...
3
by: PorkyJr | last post by:
Running an asp page that has the following code: <% response.Write MonthName(Month(date)) %> &nbsp; <% response.Write Day(date) %> ,
9
by: Dominic Godin | last post by:
Hi, I have an asp page that does a lot of processing and reports it's finished by printing the word "Success". For example: <% SomeFunction(SomeVar) SomeFunction(SomeVar1) ...
14
by: Hugh Welford | last post by:
Hi - trying to display a memo field using response.write but it truncates it. Is there a size issue with response.write? If so how do I get round it and to be able to display the whole memo field ...
1
by: Dan | last post by:
Hi I've created a generic 'Report' class that takes a DataView from a DataGrid control and writes it out to the response as a csv file for download. Basically, when a user clicks the download...
5
by: matthew | last post by:
Hi all, I am now writing a aspx that get a session variable (string) and then write it out using Response.Write. The string length is: 494710. But Response.Write only write the string...
11
by: Russ | last post by:
My web app writes some binary data to a file at the client site via Response.Write and Response.BinaryWrite. This action is accomplished in response to a button click, with C# code behind as...
2
by: Jack | last post by:
Hi, I have a asp page. This page pulls all data from a query. Part of the code is as follows: <% Response.Write "<table border='1' width='80%' height='1' cellspacing='1' >" Response.Write...
4
by: cbtechlists | last post by:
I have an ASP app that we've moved from a Windows 2000 to a Windows 2003 server (sql server 2000 to sql server 2005). The job runs fine on the old servers. Part of the app takes a recordset and...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.