I have a problem with ASP.NET and entering data into a MS SQL database.
I have the following
code and what happens is the data gets into the database, but with one
extra space at the end of
the entry. Is this preventable with something other than a trim in my
stored procedure? I know this is not necessarily in ASP.NET because I
returned the value with quotes around it and it shows up right, but
when I look in the database, it is wrong. I think it is with the SQL
Server.
***************************************
ASP.NET code
***************************************
<%@ Page Language="VB"%>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.OleDb" %>
<script language="VB" runat="server">
Function gstrConn As String
gstrConn = "Provider = SQLOLEDB;" & _
"Initial Catalog = main;" & _
"Data Source = mssql.somesite.com;" & _
"User Id = someuser;" & _
"PASSWORD = password"
End Function
Function SignUpUser(strUserName As String, strPassword As String) As
Boolean
SignUpUser = False
Dim booResult As Boolean = False
Dim intUserId As Integer = 0
Dim objConn As New OleDbConnection(gstrConn)
Dim objCmd As OleDbCommand
Dim objParam As OleDbParameter
Dim objReader As OleDbDataReader
Dim ds As DataSet = New DataSet()
objCmd = New OleDbCommand("signup_user", objConn)
objCmd.CommandType = CommandType.StoredProcedure
objParam = objCmd.Parameters.Add("@user_name", OleDbType.Char)
objParam.Direction = ParameterDirection.Input
objParam.Value = strUserName
objParam = objCmd.Parameters.Add("@password", OleDbType.Char)
objParam.Direction = ParameterDirection.Input
objParam.Value = strPassword
Try
objCmd.Connection.Open()
objReader = objCmd.ExecuteReader
Catch Ex As OleDbException
Response.Write("x")
objCmd.Connection.Close()
SignUpUser = False
Exit Function
End Try
While objReader.Read()
intUserId = objReader.GetInt32(0)
End While
objReader.Close()
objCmd.Connection.Close()
If intUserId > 0 Then
booResult = True
Else
booResult = False
End If
SignUpUser = booResult
End Function
Sub Page_Load(Sender As Object, E As EventArgs)
End Sub
Sub btnSignUp_Click(Sender As Object, E As EventArgs)
lbltesttext.text = chr(34) & tbtesttext.text & chr(34)
SignUpUser(tbtesttext.text, tbtesttext.text)
End Sub
Sub btnReset_click(Sender As Object, E As EventArgs)
lbltesttext.text = ""
End Sub
</script>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD><TITLE></TITLE>
<META http-equiv=Content-Type content="text/html; charset=utf-8">
</HEAD>
<BODY>
<FORM runat="server">
<asp:label id="lbltesttext" runat="server"/>
<asp:textbox id="tbtesttext" runat="server"/>
<asp:button id="btntesttext" text="Test" onclick="btnSignUp_Click"
runat="server"/>
<asp:button id="btnReset" text="Reset" onclick="btnReset_click"
runat="server"/>
</FORM>
</BODY>
</HTML>
***************************************
MS SQL Stored Procedure
***************************************
CREATE PROCEDURE signup_user
@user_name VARCHAR(32),
@password VARCHAR(32)
AS
INSERT INTO forum_users
(forum_user_name, forum_user_password)
VALUES(@user_name, @password) 5 1504
What are the SQL data types in this table? Are they char (fixed
length) or varchar (variable length). If they are char, then your
entries will likely be padded with spaces unless they are of the exact
length as the column length.
Bill E.
Hollywood, FL
In ASP.NET or in MS SQL (the Stored Procedure)? This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Sarah Tanembaum |
last post by:
I was wondering if it is possible to create a secure database system
using RDBMS(MySQL, Oracle, SQL*Server, PostgreSQL etc) and web
scripting/programming language(Perl, PHP, Ruby, Java, ASP, etc)...
|
by: Matt Bush |
last post by:
Using .NET Framework 1.1 and Visual Studio .NET 2003. Language is VB.NET.
When loading an XML String using XMLDocument.LoadXml we are getting an extra
space inserted into abbreviated end tags:
...
|
by: Neil Ginsberg |
last post by:
I have a strange situation using Access to automate a Word mail merge. Using
Access 2000 and Word 2000, the code opens Word, opens the document in Word,
sets a table
in the calling Access...
|
by: Trent |
last post by:
I am in the design phase of a new database and am having a devil of a
time with a subform.
I have three tables that relate to problem - Suppliers tbl, Customers
tbl and a SuppliersCustomers tbl....
|
by: PC Datasheet |
last post by:
How do I get the Len function to count a space at the end of a string? For
example, if I enter AB(space), how do I get Len to return 3 instead of 2?
Thanks,
Steve
|
by: MP |
last post by:
Greets,
context: vb6/ado/.mdb/jet 4.0 (no access)/sql
beginning learner, first database, planning stages
(I think the underlying question here is whether to normalize or not to
normalize this...
|
by: dchristjohn |
last post by:
I am currently developing a small windows application using Visual
Basic via Visual Studio 2005. My database resides on a SQL 2000 server.
I have a table with three fields:
id (int, Not Null)...
|
by: dancer |
last post by:
Using ASP.net 1.1 to create user input form.
When I put a RequiredFieldValidator I have extra space at the bottom of the
cell, as if I had put a <br>.
When I comment out the...
|
by: Jibran |
last post by:
I need some help with extra spaces in HTML form. There is a big white space appearing at the center of the HTML form that I am designing even though there is no <br> tags been used: ...
|
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...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
| |