Hi
I have a problem populating my datagrid when the values passed have an apostrophie (') like this test's. Any other values work. This is my asp.net cod
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Loa
'Put user code to initialize the page her
Dim s As String = Request.QueryString("id").ToString(
If Not Page.IsPostBack The
Dim conPos As SqlConnectio
Dim cmdSel As SqlDataAdapte
Dim ds As DataSe
conPos = New SqlConnection("Server = prod01\enterprise;UID=sa;PWD=xxxx;Database=POS"
cmdSel = New SqlDataAdapter("LoadOrderRegulation", conPos
cmdSel.SelectCommand.CommandType = CommandType.StoredProcedur
cmdSel.SelectCommand.Parameters.Add(New SqlParameter("@productName", SqlDbType.VarChar, 15)
cmdSel.SelectCommand.Parameters("@productName").Va lue =
ds = New DataSe
cmdSel.Fill(ds, "Oreg"
DataGrid1.DataSource = ds.Tables("Oreg").DefaultVie
DataGrid1.DataBind(
End I
End Su
This is my stored pro
create procedure LoadOrderRegulation
@productName varchar(50
a
declare @productNumber varchar(10
exec POS_GetProductNumber @productName, @productNumber OUTPU
If len(@productNumber) = 1
Set @productNumber = '0000' + @productNumbe
If len(@productNumber) =
Set @productNumber = '000' + @productNumbe
If len(@productNumber) =
Set @productNumber = '00' + @productNumbe
If len(@productNumber) =
Set @productNumber = '0' + @productNumbe
select
POS_Product_Number
POS_Store_Number
POS_Account_Number
POS_Current_Draw
POS_Proposed_Draw
POS_Average_Sale
POS_Date_Regulated
POS_Adjustmen
from pos_order_regulation where POS_Product_Number = @productNumbe
retur
I think my stored proc is expecting test''s instead of test's. How can I handle this. If I execute the stored procedure from query analyzer like this
declare @datatest varchar(20
exec LoadOrderRegulation 'test''s', @datatest OUTPU
Select @datatest
it work 1 920
Here's how I solve a similar problem, building a SQL query with
Stringbuilder (yes, soon to be a stored procedure...):
sbldr.Append(Me.shipTo_First_Name.Replace("'", "''")) : sbldr.Append("','")
"Chris" <an*******@discussions.microsoft.com> wrote in message
news:8A**********************************@microsof t.com... Hi, I have a problem populating my datagrid when the values passed have an
apostrophie (') like this test's. Any other values work. This is my asp.net
code Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load 'Put user code to initialize the page here Dim s As String = Request.QueryString("id").ToString()
If Not Page.IsPostBack Then
Dim conPos As SqlConnection Dim cmdSel As SqlDataAdapter Dim ds As DataSet
conPos = New SqlConnection("Server =
prod01\enterprise;UID=sa;PWD=xxxx;Database=POS")
cmdSel = New SqlDataAdapter("LoadOrderRegulation", conPos)
cmdSel.SelectCommand.CommandType = CommandType.StoredProcedure
cmdSel.SelectCommand.Parameters.Add(New
SqlParameter("@productName", SqlDbType.VarChar, 15)) cmdSel.SelectCommand.Parameters("@productName").Va lue = s ds = New DataSet cmdSel.Fill(ds, "Oreg")
DataGrid1.DataSource = ds.Tables("Oreg").DefaultView DataGrid1.DataBind()
End If
End Sub This is my stored proc create procedure LoadOrderRegulation( @productName varchar(50) )
as
declare @productNumber varchar(10)
exec POS_GetProductNumber @productName, @productNumber OUTPUT
If len(@productNumber) = 1
Set @productNumber = '0000' + @productNumber
If len(@productNumber) = 2
Set @productNumber = '000' + @productNumber
If len(@productNumber) = 3
Set @productNumber = '00' + @productNumber
If len(@productNumber) = 4
Set @productNumber = '0' + @productNumber
select POS_Product_Number, POS_Store_Number, POS_Account_Number, POS_Current_Draw, POS_Proposed_Draw, POS_Average_Sale, POS_Date_Regulated, POS_Adjustment
from pos_order_regulation where POS_Product_Number = @productNumber return
I think my stored proc is expecting test''s instead of test's. How can I
handle this. If I execute the stored procedure from query analyzer like this
declare @datatest varchar(20)
exec LoadOrderRegulation 'test''s', @datatest OUTPUT
Select @datatest
it works This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: WertmanTheMad |
last post by:
Ok,
This sounds dangerous (and yes I know it is)
But its in a controlled enviroment and I really need to know how to do
this.
How can I pass a Subquery for an Exist or In clause as a...
|
by: WertmanTheMad |
last post by:
Ok here goes, another odd SQL Question ....as always..
How do I get ...
The value of a paramater passed to say a Trigger
OR The SQL Itself
Like this , say I have a Trigger set on delete,
...
|
by: Andre |
last post by:
I'm trying to write a Password generating program which will fill one
of the fields in our Accounts Table with an eight-digit password made
up of numerals, upper and lower case letters. I'm...
|
by: Max Adams |
last post by:
Question about using delegates with a string paramater to return a
ListViewItem object...
All,
I have a thread and I want this thread to post messages to the main GUI
thread using a delegate....
|
by: Chris |
last post by:
Hi
I have a problem populating my datagrid when the values passed have an apostrophie (') like this test's. Any other values work. This is my asp.net cod
Private Sub Page_Load(ByVal sender As...
|
by: gane kol |
last post by:
Hi
I have a set of Yes/No radio buttons with textboxes for each. I need to
write a common customvalidation function that checks, if radiobutton "yes"
is selected, the value in the corresponding...
|
by: Ihsan_al-shorafa |
last post by:
We are trying to put together an exception handling framework and were
wondering if you can help us out with a problem that we ran into...
Q: Is there a way, through reflection or any other...
|
by: Jim Langston |
last post by:
In my function/method paramater list I try to keep constant correctness.
I.E. I would use:
int Foo( const char* a, int b )
instead of
int Foo( char* a, int b )
My question reguards int b. ...
|
by: Cirene |
last post by:
I have a stored procedure named insertcompany.
I keep getting the error:
Sys.webforms.pagerequestmanagerservererrorexception: Procedure or function
'InsertCompany' expects parameter...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
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...
|
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: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
| |