Hello,
I can't figure out why my parameterized query from an ASP.NET page is
dropping "special" characters such as accented quotes & apostrophes, the
registered trademark symbol, etc. These symbols insert without problem from
query analyzer, so that suggests it's something within ASP.NET. I've tried
using .NET textbox web controls as well as html textareas. I have a test
database set up with 4 fields: varchar, nvarchar, text, and ntext - they
all do the same thing. Regular text inserts fine, but it will simply remove
the special characters. I've searched usenet and the web for info, but to
no avail. Someone must have expereinced this issue! I'm running v1.1 with
the latest SP. Thanks for any help! Here's my code, doing my parameters in
different ways:
------------
Dim conCS As SqlConnection
Dim cmdSqlCommand As SqlCommand
Dim strSQL As String
Dim myParam As New SqlParameter
conCS = New SqlConnection(
ConfigurationSe ttings.AppSetti ngs("Connection String") )
conCS.Open()
strSQL = " INSERT INTO TEST VALUES (@TEST_VARCHAR, @TEST_NVARCHAR,
@TEST_TEXT, @TEST_NTEXT) "
cmdSqlCommand = New SqlCommand( strSQL, conCS )
myParam.Paramet erName = "@TEST_NVARCHAR "
myParam.SqlDbTy pe = SqlDbType.NVarc har
myParam.Value = txtTest.Text
cmdSqlCommand.P arameters.Add(m yParam)
cmdSqlCommand.P arameters.Add( "@TEST_VARCHAR" , txtTest.Text )
cmdSqlCommand.P arameters.Add( "@TEST_TEXT ", txtTest.Text )
cmdSqlCommand.P arameters.Add( "@TEST_NTEX T", txtTest.Text )
cmdSqlCommand.E xecuteNonQuery( )
conCS.Close()
------------- 11 3763
I haven't used parameterized queries. We use Stored Procedures for all of
our database ops. I couldn't find a specific reference to this in the SDK
documentation, but I suspect that the difference is in how the query is
executed. My guess would be that when you create a parameterized query, .Net
puts a SQL statement together by doing the concatenation for you. If so,
single quotes and other special characters may be being dropped somehow,
although I would suspect that they would throw an exception instead. In any
case, why not use a Stored Procedure instead?
--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
I get paid good money to
solve puzzles for a living
"anony" <no**@m.com> wrote in message
news:bM******** *************@t wister.tampabay .rr.com... Hello,
I can't figure out why my parameterized query from an ASP.NET page is dropping "special" characters such as accented quotes & apostrophes, the registered trademark symbol, etc. These symbols insert without problem
from query analyzer, so that suggests it's something within ASP.NET. I've
tried using .NET textbox web controls as well as html textareas. I have a test database set up with 4 fields: varchar, nvarchar, text, and ntext - they all do the same thing. Regular text inserts fine, but it will simply
remove the special characters. I've searched usenet and the web for info, but to no avail. Someone must have expereinced this issue! I'm running v1.1
with the latest SP. Thanks for any help! Here's my code, doing my parameters
in different ways:
------------
Dim conCS As SqlConnection Dim cmdSqlCommand As SqlCommand Dim strSQL As String Dim myParam As New SqlParameter
conCS = New SqlConnection( ConfigurationSe ttings.AppSetti ngs("Connection String") ) conCS.Open()
strSQL = " INSERT INTO TEST VALUES (@TEST_VARCHAR, @TEST_NVARCHAR, @TEST_TEXT, @TEST_NTEXT) "
cmdSqlCommand = New SqlCommand( strSQL, conCS )
myParam.Paramet erName = "@TEST_NVARCHAR " myParam.SqlDbTy pe = SqlDbType.NVarc har myParam.Value = txtTest.Text cmdSqlCommand.P arameters.Add(m yParam)
cmdSqlCommand.P arameters.Add( "@TEST_VARCHAR" , txtTest.Text ) cmdSqlCommand.P arameters.Add( "@TEST_TEXT ", txtTest.Text ) cmdSqlCommand.P arameters.Add( "@TEST_NTEX T", txtTest.Text )
cmdSqlCommand.E xecuteNonQuery( ) conCS.Close()
-------------
A dump question, are you sure that txtTest.Text contains all those special
chars?
--
Girish Bharadwaj http://msmvps.com/gbvb
"anony" <no**@m.com> wrote in message
news:bM******** *************@t wister.tampabay .rr.com... Hello,
I can't figure out why my parameterized query from an ASP.NET page is dropping "special" characters such as accented quotes & apostrophes, the registered trademark symbol, etc. These symbols insert without problem
from query analyzer, so that suggests it's something within ASP.NET. I've
tried using .NET textbox web controls as well as html textareas. I have a test database set up with 4 fields: varchar, nvarchar, text, and ntext - they all do the same thing. Regular text inserts fine, but it will simply
remove the special characters. I've searched usenet and the web for info, but to no avail. Someone must have expereinced this issue! I'm running v1.1
with the latest SP. Thanks for any help! Here's my code, doing my parameters
in different ways:
------------
Dim conCS As SqlConnection Dim cmdSqlCommand As SqlCommand Dim strSQL As String Dim myParam As New SqlParameter
conCS = New SqlConnection( ConfigurationSe ttings.AppSetti ngs("Connection String") ) conCS.Open()
strSQL = " INSERT INTO TEST VALUES (@TEST_VARCHAR, @TEST_NVARCHAR, @TEST_TEXT, @TEST_NTEXT) "
cmdSqlCommand = New SqlCommand( strSQL, conCS )
myParam.Paramet erName = "@TEST_NVARCHAR " myParam.SqlDbTy pe = SqlDbType.NVarc har myParam.Value = txtTest.Text cmdSqlCommand.P arameters.Add(m yParam)
cmdSqlCommand.P arameters.Add( "@TEST_VARCHAR" , txtTest.Text ) cmdSqlCommand.P arameters.Add( "@TEST_TEXT ", txtTest.Text ) cmdSqlCommand.P arameters.Add( "@TEST_NTEX T", txtTest.Text )
cmdSqlCommand.E xecuteNonQuery( ) conCS.Close()
-------------
Try doing
myParam.Paramet erName = "@TEST_NVARCHAR "
myParam.SqlDbTy pe = SqlDbType.NVarc har
myParam.Value = "hard code charcters taht don't pass here as a test"
'txtTest.Text
cmdSqlCommand.P arameters.Add(m yParam)
In other words, what is the value of your txtTest.Text in the debugger when
you get to that point in code. I can't imagine this is a SQL problem.
Maybe when you read txtTest.Text back in ASP.NET it is escaping your
characters or something.
Greg
"anony" <no**@m.com> wrote in message
news:bM******** *************@t wister.tampabay .rr.com... Hello,
I can't figure out why my parameterized query from an ASP.NET page is dropping "special" characters such as accented quotes & apostrophes, the registered trademark symbol, etc. These symbols insert without problem from query analyzer, so that suggests it's something within ASP.NET. I've tried using .NET textbox web controls as well as html textareas. I have a test database set up with 4 fields: varchar, nvarchar, text, and ntext - they all do the same thing. Regular text inserts fine, but it will simply remove the special characters. I've searched usenet and the web for info, but to no avail. Someone must have expereinced this issue! I'm running v1.1 with the latest SP. Thanks for any help! Here's my code, doing my parameters in different ways:
------------
Dim conCS As SqlConnection Dim cmdSqlCommand As SqlCommand Dim strSQL As String Dim myParam As New SqlParameter
conCS = New SqlConnection( ConfigurationSe ttings.AppSetti ngs("Connection String") ) conCS.Open()
strSQL = " INSERT INTO TEST VALUES (@TEST_VARCHAR, @TEST_NVARCHAR, @TEST_TEXT, @TEST_NTEXT) "
cmdSqlCommand = New SqlCommand( strSQL, conCS )
myParam.Paramet erName = "@TEST_NVARCHAR " myParam.SqlDbTy pe = SqlDbType.NVarc har myParam.Value = txtTest.Text cmdSqlCommand.P arameters.Add(m yParam)
cmdSqlCommand.P arameters.Add( "@TEST_VARCHAR" , txtTest.Text ) cmdSqlCommand.P arameters.Add( "@TEST_TEXT ", txtTest.Text ) cmdSqlCommand.P arameters.Add( "@TEST_NTEX T", txtTest.Text )
cmdSqlCommand.E xecuteNonQuery( ) conCS.Close()
-------------
That's a good question, and the one he should be asking. :^)
Greg
"Girish Bharadwaj" <gi*****@mvps.o rg> wrote in message
news:uU******** ******@TK2MSFTN GP10.phx.gbl... A dump question, are you sure that txtTest.Text contains all those special chars?
-- Girish Bharadwaj http://msmvps.com/gbvb "anony" <no**@m.com> wrote in message news:bM******** *************@t wister.tampabay .rr.com... Hello,
I can't figure out why my parameterized query from an ASP.NET page is dropping "special" characters such as accented quotes & apostrophes, the registered trademark symbol, etc. These symbols insert without problem from query analyzer, so that suggests it's something within ASP.NET. I've tried using .NET textbox web controls as well as html textareas. I have a test database set up with 4 fields: varchar, nvarchar, text, and ntext - they all do the same thing. Regular text inserts fine, but it will simply remove the special characters. I've searched usenet and the web for info, but to no avail. Someone must have expereinced this issue! I'm running v1.1 with the latest SP. Thanks for any help! Here's my code, doing my parameters in different ways:
------------
Dim conCS As SqlConnection Dim cmdSqlCommand As SqlCommand Dim strSQL As String Dim myParam As New SqlParameter
conCS = New SqlConnection( ConfigurationSe ttings.AppSetti ngs("Connection String") ) conCS.Open()
strSQL = " INSERT INTO TEST VALUES (@TEST_VARCHAR, @TEST_NVARCHAR, @TEST_TEXT, @TEST_NTEXT) "
cmdSqlCommand = New SqlCommand( strSQL, conCS )
myParam.Paramet erName = "@TEST_NVARCHAR " myParam.SqlDbTy pe = SqlDbType.NVarc har myParam.Value = txtTest.Text cmdSqlCommand.P arameters.Add(m yParam)
cmdSqlCommand.P arameters.Add( "@TEST_VARCHAR" , txtTest.Text ) cmdSqlCommand.P arameters.Add( "@TEST_TEXT ", txtTest.Text ) cmdSqlCommand.P arameters.Add( "@TEST_NTEX T", txtTest.Text )
cmdSqlCommand.E xecuteNonQuery( ) conCS.Close()
-------------
Kevin - No reason why I can't use a SP, but I'm more so on a mission to
figure out what is going wrong. Greg, Girish - Yes, I'm really providing
input with special characters into the textbox! I tried your suggestion
below Greg, hardcoding the registered trademark symbol to my parameter, and
it did insert without problem. So something is lost when adding my
textbox.text as a parameter. Thanks for your replies.
"Greg Burns" <greg_burns@DON T_SPAM_ME_hotma il.com> wrote in message
news:u7******** ******@TK2MSFTN GP09.phx.gbl... Try doing
myParam.Paramet erName = "@TEST_NVARCHAR " myParam.SqlDbTy pe = SqlDbType.NVarc har myParam.Value = "hard code charcters taht don't pass here as a test" 'txtTest.Text cmdSqlCommand.P arameters.Add(m yParam)
In other words, what is the value of your txtTest.Text in the debugger when you get to that point in code. I can't imagine this is a SQL problem.
Maybe when you read txtTest.Text back in ASP.NET it is escaping your characters or something.
Greg
"anony" <no**@m.com> wrote in message news:bM******** *************@t wister.tampabay .rr.com... Hello,
I can't figure out why my parameterized query from an ASP.NET page is dropping "special" characters such as accented quotes & apostrophes, the registered trademark symbol, etc. These symbols insert without problem from query analyzer, so that suggests it's something within ASP.NET. I've tried using .NET textbox web controls as well as html textareas. I have a test database set up with 4 fields: varchar, nvarchar, text, and ntext - they all do the same thing. Regular text inserts fine, but it will simply remove the special characters. I've searched usenet and the web for info, but to no avail. Someone must have expereinced this issue! I'm running v1.1 with the latest SP. Thanks for any help! Here's my code, doing my parameters in different ways:
------------
Dim conCS As SqlConnection Dim cmdSqlCommand As SqlCommand Dim strSQL As String Dim myParam As New SqlParameter
conCS = New SqlConnection( ConfigurationSe ttings.AppSetti ngs("Connection String") ) conCS.Open()
strSQL = " INSERT INTO TEST VALUES (@TEST_VARCHAR, @TEST_NVARCHAR, @TEST_TEXT, @TEST_NTEXT) "
cmdSqlCommand = New SqlCommand( strSQL, conCS )
myParam.Paramet erName = "@TEST_NVARCHAR " myParam.SqlDbTy pe = SqlDbType.NVarc har myParam.Value = txtTest.Text cmdSqlCommand.P arameters.Add(m yParam)
cmdSqlCommand.P arameters.Add( "@TEST_VARCHAR" , txtTest.Text ) cmdSqlCommand.P arameters.Add( "@TEST_TEXT ", txtTest.Text ) cmdSqlCommand.P arameters.Add( "@TEST_NTEX T", txtTest.Text )
cmdSqlCommand.E xecuteNonQuery( ) conCS.Close()
-------------
I seem to be able to read the registered trademark character back into a
variable from the textbox after postback.
How exactly are you getting these special symbols into your textbox?
ALT-numpad????
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Load
'Put user code to initialize the page here
TextBox1.Text = Chr(174) ' registered trademark
End Sub
Private Sub Button1_Click(B yVal sender As System.Object, ByVal e As
System.EventArg s) Handles Button1.Click
Dim x As String = TextBox1.Text
End Sub
Greg
"anony" <no**@m.com> wrote in message
news:ay******** ***********@tor nado.tampabay.r r.com... Kevin - No reason why I can't use a SP, but I'm more so on a mission to figure out what is going wrong. Greg, Girish - Yes, I'm really providing input with special characters into the textbox! I tried your suggestion below Greg, hardcoding the registered trademark symbol to my parameter, and it did insert without problem. So something is lost when adding my textbox.text as a parameter. Thanks for your replies.
"Greg Burns" <greg_burns@DON T_SPAM_ME_hotma il.com> wrote in message news:u7******** ******@TK2MSFTN GP09.phx.gbl... Try doing
myParam.Paramet erName = "@TEST_NVARCHAR " myParam.SqlDbTy pe = SqlDbType.NVarc har myParam.Value = "hard code charcters taht don't pass here as a test" 'txtTest.Text cmdSqlCommand.P arameters.Add(m yParam)
In other words, what is the value of your txtTest.Text in the debugger when you get to that point in code. I can't imagine this is a SQL problem.
Maybe when you read txtTest.Text back in ASP.NET it is escaping your characters or something.
Greg
"anony" <no**@m.com> wrote in message news:bM******** *************@t wister.tampabay .rr.com... Hello,
I can't figure out why my parameterized query from an ASP.NET page is dropping "special" characters such as accented quotes & apostrophes, the registered trademark symbol, etc. These symbols insert without problem from query analyzer, so that suggests it's something within ASP.NET. I've tried using .NET textbox web controls as well as html textareas. I have a test database set up with 4 fields: varchar, nvarchar, text, and ntext - they all do the same thing. Regular text inserts fine, but it will simply remove the special characters. I've searched usenet and the web for info, but to no avail. Someone must have expereinced this issue! I'm running v1.1 with the latest SP. Thanks for any help! Here's my code, doing my parameters in different ways:
------------
Dim conCS As SqlConnection Dim cmdSqlCommand As SqlCommand Dim strSQL As String Dim myParam As New SqlParameter
conCS = New SqlConnection( ConfigurationSe ttings.AppSetti ngs("Connection String") ) conCS.Open()
strSQL = " INSERT INTO TEST VALUES (@TEST_VARCHAR, @TEST_NVARCHAR, @TEST_TEXT, @TEST_NTEXT) "
cmdSqlCommand = New SqlCommand( strSQL, conCS )
myParam.Paramet erName = "@TEST_NVARCHAR " myParam.SqlDbTy pe = SqlDbType.NVarc har myParam.Value = txtTest.Text cmdSqlCommand.P arameters.Add(m yParam)
cmdSqlCommand.P arameters.Add( "@TEST_VARCHAR" , txtTest.Text ) cmdSqlCommand.P arameters.Add( "@TEST_TEXT ", txtTest.Text ) cmdSqlCommand.P arameters.Add( "@TEST_NTEX T", txtTest.Text )
cmdSqlCommand.E xecuteNonQuery( ) conCS.Close()
-------------
Should have been:
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Load
'Put user code to initialize the page here
If Not Page.IsPostBack Then
TextBox1.Text = Chr(174)
End If
End Sub
Private Sub Button1_Click(B yVal sender As System.Object, ByVal e As
System.EventArg s) Handles Button1.Click
Dim x As String = TextBox1.Text
End Sub
but the outcome is the same.
Greg
"Greg Burns" <greg_burns@DON T_SPAM_ME_hotma il.com> wrote in message
news:eN******** ******@TK2MSFTN GP10.phx.gbl... I seem to be able to read the registered trademark character back into a variable from the textbox after postback.
How exactly are you getting these special symbols into your textbox? ALT-numpad????
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArg s) Handles MyBase.Load 'Put user code to initialize the page here TextBox1.Text = Chr(174) ' registered trademark End Sub
Private Sub Button1_Click(B yVal sender As System.Object, ByVal e As System.EventArg s) Handles Button1.Click Dim x As String = TextBox1.Text End Sub
Greg
"anony" <no**@m.com> wrote in message news:ay******** ***********@tor nado.tampabay.r r.com... Kevin - No reason why I can't use a SP, but I'm more so on a mission to figure out what is going wrong. Greg, Girish - Yes, I'm really providing input with special characters into the textbox! I tried your suggestion below Greg, hardcoding the registered trademark symbol to my parameter, and it did insert without problem. So something is lost when adding my textbox.text as a parameter. Thanks for your replies.
"Greg Burns" <greg_burns@DON T_SPAM_ME_hotma il.com> wrote in message news:u7******** ******@TK2MSFTN GP09.phx.gbl... Try doing
myParam.Paramet erName = "@TEST_NVARCHAR " myParam.SqlDbTy pe = SqlDbType.NVarc har myParam.Value = "hard code charcters taht don't pass here as a test" 'txtTest.Text cmdSqlCommand.P arameters.Add(m yParam)
In other words, what is the value of your txtTest.Text in the debugger when you get to that point in code. I can't imagine this is a SQL problem.
Maybe when you read txtTest.Text back in ASP.NET it is escaping your characters or something.
Greg
"anony" <no**@m.com> wrote in message news:bM******** *************@t wister.tampabay .rr.com... Hello,
I can't figure out why my parameterized query from an ASP.NET page is dropping "special" characters such as accented quotes & apostrophes, the registered trademark symbol, etc. These symbols insert without problem from query analyzer, so that suggests it's something within ASP.NET. I've tried using .NET textbox web controls as well as html textareas. I have a test database set up with 4 fields: varchar, nvarchar, text, and ntext - they all do the same thing. Regular text inserts fine, but it will simply remove the special characters. I've searched usenet and the web for info, but to no avail. Someone must have expereinced this issue! I'm running v1.1 with the latest SP. Thanks for any help! Here's my code, doing my parameters in different ways:
------------
Dim conCS As SqlConnection Dim cmdSqlCommand As SqlCommand Dim strSQL As String Dim myParam As New SqlParameter
conCS = New SqlConnection( ConfigurationSe ttings.AppSetti ngs("Connection String") ) conCS.Open()
strSQL = " INSERT INTO TEST VALUES (@TEST_VARCHAR, @TEST_NVARCHAR, @TEST_TEXT, @TEST_NTEXT) "
cmdSqlCommand = New SqlCommand( strSQL, conCS )
myParam.Paramet erName = "@TEST_NVARCHAR " myParam.SqlDbTy pe = SqlDbType.NVarc har myParam.Value = txtTest.Text cmdSqlCommand.P arameters.Add(m yParam)
cmdSqlCommand.P arameters.Add( "@TEST_VARCHAR" , txtTest.Text ) cmdSqlCommand.P arameters.Add( "@TEST_TEXT ", txtTest.Text ) cmdSqlCommand.P arameters.Add( "@TEST_NTEX T", txtTest.Text )
cmdSqlCommand.E xecuteNonQuery( ) conCS.Close()
-------------
Either by copy & pasting from Word or doing Alt-0174 directly in the
textbox.
I'd be curious as to what your string reads if you capture it from the
browser instead of assigning it like you're doing below. Even if I simply
Response.Write( textbox.Text ) on postback it drops the characters.
Thanks again.
"Greg Burns" <greg_burns@DON T_SPAM_ME_hotma il.com> wrote in message
news:eN******** ******@TK2MSFTN GP10.phx.gbl... I seem to be able to read the registered trademark character back into a variable from the textbox after postback.
How exactly are you getting these special symbols into your textbox? ALT-numpad????
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArg s) Handles MyBase.Load 'Put user code to initialize the page here TextBox1.Text = Chr(174) ' registered trademark End Sub
Private Sub Button1_Click(B yVal sender As System.Object, ByVal e As System.EventArg s) Handles Button1.Click Dim x As String = TextBox1.Text End Sub
Greg
"anony" <no**@m.com> wrote in message news:ay******** ***********@tor nado.tampabay.r r.com... Kevin - No reason why I can't use a SP, but I'm more so on a mission to figure out what is going wrong. Greg, Girish - Yes, I'm really providing input with special characters into the textbox! I tried your suggestion below Greg, hardcoding the registered trademark symbol to my parameter, and it did insert without problem. So something is lost when adding my textbox.text as a parameter. Thanks for your replies.
"Greg Burns" <greg_burns@DON T_SPAM_ME_hotma il.com> wrote in message news:u7******** ******@TK2MSFTN GP09.phx.gbl... Try doing
myParam.Paramet erName = "@TEST_NVARCHAR " myParam.SqlDbTy pe = SqlDbType.NVarc har myParam.Value = "hard code charcters taht don't pass here as a test" 'txtTest.Text cmdSqlCommand.P arameters.Add(m yParam)
In other words, what is the value of your txtTest.Text in the debugger when you get to that point in code. I can't imagine this is a SQL problem.
Maybe when you read txtTest.Text back in ASP.NET it is escaping your characters or something.
Greg
"anony" <no**@m.com> wrote in message news:bM******** *************@t wister.tampabay .rr.com... Hello,
I can't figure out why my parameterized query from an ASP.NET page is dropping "special" characters such as accented quotes & apostrophes, the registered trademark symbol, etc. These symbols insert without problem from query analyzer, so that suggests it's something within ASP.NET. I've tried using .NET textbox web controls as well as html textareas. I have a test database set up with 4 fields: varchar, nvarchar, text, and ntext - they all do the same thing. Regular text inserts fine, but it will simply remove the special characters. I've searched usenet and the web for info, but to no avail. Someone must have expereinced this issue! I'm running v1.1 with the latest SP. Thanks for any help! Here's my code, doing my parameters in different ways:
------------
Dim conCS As SqlConnection Dim cmdSqlCommand As SqlCommand Dim strSQL As String Dim myParam As New SqlParameter
conCS = New SqlConnection( ConfigurationSe ttings.AppSetti ngs("Connection String") ) conCS.Open()
strSQL = " INSERT INTO TEST VALUES (@TEST_VARCHAR, @TEST_NVARCHAR, @TEST_TEXT, @TEST_NTEXT) "
cmdSqlCommand = New SqlCommand( strSQL, conCS )
myParam.Paramet erName = "@TEST_NVARCHAR " myParam.SqlDbTy pe = SqlDbType.NVarc har myParam.Value = txtTest.Text cmdSqlCommand.P arameters.Add(m yParam)
cmdSqlCommand.P arameters.Add( "@TEST_VARCHAR" , txtTest.Text ) cmdSqlCommand.P arameters.Add( "@TEST_TEXT ", txtTest.Text ) cmdSqlCommand.P arameters.Add( "@TEST_NTEX T", txtTest.Text )
cmdSqlCommand.E xecuteNonQuery( ) conCS.Close()
-------------
My first attempt was to put a ® in the html. When the page loaded I
copied it into the textbox. Seemed to work fine.
Aren't those characters coming from Word font specific? You actually see
them in your textbox before you submit the page?
As far as using ATL-0147 that works too. I just removed the Page_Load
stuff, and on postback x contains the reg character in the debug window and
displays on screen with a Response.Write( x).
Try my example on a new page, it should work. Must be something else on
your page that is messing things up.
Greg
"anony" <no**@m.com> wrote in message
news:2U******** ***********@tor nado.tampabay.r r.com... Either by copy & pasting from Word or doing Alt-0174 directly in the textbox.
I'd be curious as to what your string reads if you capture it from the browser instead of assigning it like you're doing below. Even if I simply Response.Write( textbox.Text ) on postback it drops the characters.
Thanks again.
"Greg Burns" <greg_burns@DON T_SPAM_ME_hotma il.com> wrote in message news:eN******** ******@TK2MSFTN GP10.phx.gbl...I seem to be able to read the registered trademark character back into a variable from the textbox after postback.
How exactly are you getting these special symbols into your textbox? ALT-numpad????
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArg s) Handles MyBase.Load 'Put user code to initialize the page here TextBox1.Text = Chr(174) ' registered trademark End Sub
Private Sub Button1_Click(B yVal sender As System.Object, ByVal e As System.EventArg s) Handles Button1.Click Dim x As String = TextBox1.Text End Sub
Greg
"anony" <no**@m.com> wrote in message news:ay******** ***********@tor nado.tampabay.r r.com... Kevin - No reason why I can't use a SP, but I'm more so on a mission to figure out what is going wrong. Greg, Girish - Yes, I'm really providing input with special characters into the textbox! I tried your suggestion below Greg, hardcoding the registered trademark symbol to my parameter, and it did insert without problem. So something is lost when adding my textbox.text as a parameter. Thanks for your replies.
"Greg Burns" <greg_burns@DON T_SPAM_ME_hotma il.com> wrote in message news:u7******** ******@TK2MSFTN GP09.phx.gbl... Try doing
myParam.Paramet erName = "@TEST_NVARCHAR " myParam.SqlDbTy pe = SqlDbType.NVarc har myParam.Value = "hard code charcters taht don't pass here as a test" 'txtTest.Text cmdSqlCommand.P arameters.Add(m yParam)
In other words, what is the value of your txtTest.Text in the debugger when you get to that point in code. I can't imagine this is a SQL problem.
Maybe when you read txtTest.Text back in ASP.NET it is escaping your characters or something.
Greg
"anony" <no**@m.com> wrote in message news:bM******** *************@t wister.tampabay .rr.com... > Hello, > > I can't figure out why my parameterized query from an ASP.NET page is > dropping "special" characters such as accented quotes & apostrophes, > the registered trademark symbol, etc. These symbols insert without > problem from query analyzer, so that suggests it's something within > ASP.NET. I've tried using .NET textbox web controls as well as html > textareas. I have a test database set up with 4 fields: varchar, > nvarchar, text, and ntext - they all do the same thing. Regular text > inserts fine, but it will simply remove the special characters. I've > searched usenet and the web for info, but to no avail. Someone must > have expereinced this issue! I'm running v1.1 with the latest SP. > Thanks for any help! Here's my code, doing my parameters in different > ways: > > ------------ > > Dim conCS As SqlConnection > Dim cmdSqlCommand As SqlCommand > Dim strSQL As String > Dim myParam As New SqlParameter > > conCS = New SqlConnection( > ConfigurationSe ttings.AppSetti ngs("Connection String") ) > conCS.Open() > > strSQL = " INSERT INTO TEST VALUES (@TEST_VARCHAR, @TEST_NVARCHAR, > @TEST_TEXT, @TEST_NTEXT) " > > cmdSqlCommand = New SqlCommand( strSQL, conCS ) > > myParam.Paramet erName = "@TEST_NVARCHAR " > myParam.SqlDbTy pe = SqlDbType.NVarc har > myParam.Value = txtTest.Text > cmdSqlCommand.P arameters.Add(m yParam) > > cmdSqlCommand.P arameters.Add( "@TEST_VARCHAR" , txtTest.Text ) > cmdSqlCommand.P arameters.Add( "@TEST_TEXT ", txtTest.Text ) > cmdSqlCommand.P arameters.Add( "@TEST_NTEX T", txtTest.Text ) > > cmdSqlCommand.E xecuteNonQuery( ) > conCS.Close() > > ------------- > >
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Nashat Wanly |
last post by:
HOW TO: Call a Parameterized Stored Procedure by Using ADO.NET and
Visual C# .NET
View products that this article applies to.
This article was previously published under Q310070
For a Microsoft Visual Basic .NET version of this article, see 308049.
For a Microsoft Visual C++ .NET version of this article, see 310071.
For a Microsoft Visual J#...
|
by: gary b |
last post by:
Hello
When I use a PreparedStatement (in jdbc) with the following query:
SELECT store_groups_id
FROM store_groups
WHERE store_groups_id IS NOT NULL
AND type = ?
ORDER BY group_name
|
by: Neil Ginsberg |
last post by:
We're using SQL Server 7 with an Access 2000 MDB as a front end with ODBC
linked tables. I recently created a new set of tables for the app, and users
are complaining that unsaved data is being lost when they move to a new
record. This seems to be the case when there are multiple users. When there
is a single user using it, we don't seem to...
|
by: Gilberto Campos |
last post by:
Hi all.
I am having a strange problem.
I am developping an application that acceses an Access db through Jet
(.UDL files).
I have writen parametric INSERT queries that work fine.
I am now trying to write a parametric UPDATE query but I always get a
return error code that the language manual translates to:
|
by: deko |
last post by:
I'm trying to open a Recordset based on a parameterized query. I'm kind of
new to parameterized queries, so I'm sure I'm missing something simple.
Set qdfs = db.QueryDefs
Set qdf = qdfs("qryInvoices")
qdf.Parameters("prmInv") = strInvoice
qdf.Parameters("prmCid") = lngCustomerID
Set rst = db.OpenRecordset("qryInvoices")
| |
by: Wajih-ur-Rehman |
last post by:
The following query runs perfectly fine with SQL Query Analyzer:
insert into TableName(ID,ParamName,ParamValue) values
(27706,'Param6','\0V\0\0\0\0\0')
But if i try to execute the same query using OdbcCommand object, it throws
an exception. Any help plz?
|
by: anony |
last post by:
Hi,
I'm looking to find out how to properly handle the input of certain
characters into a textbox that will be inserted into a database. In this
app, text is copied and pasted into a textbox from various sources, and
sometimes contains the funky curly quotes and apostrophes which end up being
dropped on the database insert. I'm not sure...
|
by: =?Utf-8?B?Sm9uIEphY29icw==?= |
last post by:
For MS SQL Server...
I am used to declaring local variables in my SQL queries...
Declare @MyInt int, @MyChar varchar(33)
Parameters were idenfitied with a colon...
Where ModDate :MyDate
But, now that I am stwitching to .NET, the parameters are identified with @
in SqlCommand, so how do I declare local variables in my queries (like in...
|
by: TheRealDan |
last post by:
Hi all.
I'm having a problem with a special characters.
I have php script that reads from an xml file and writes to a mysql db.
It's a script called phptunest that I found on the net, although the
original website for the author appears to be gone.
It works really nicely except when it hits special characters. Everything from a sp char...
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language...
| |
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...
| |