Hello,
I have a stored procedure that requires 3 parameters. How do you add
multiple parameters for a SqlConnection?
Thanks, Steven
Public strConn = "Data Source=MyServer ;Initial Catalog=MyDatab ase;User
Id=MyUser;Passw ord=MyPwd;"
Dim cnnSearch As SqlConnection = New SqlConnection(s trConn)
Dim cmdRegion As SqlCommand = New SqlCommand("Sal esByCategory", cnnSearch)
cmdRegion.Comma ndType = CommandType.Sto redProcedure
Dim myParm As SqlParameter = cmdRegion.Param eters.Add("@Cat egoryName",
SqlDbType.VarCh ar, 15)
myParm.Value = "NorthAmeri ca"
cnnSearch.Open( )
Dim myReader As SqlDataReader = cmdRegion.Execu teReader() 3 1663
It looks like you already know how to add parameters, so what's the problem?
Just do what you did to add 1 parameter, but do it 3 times.
"sck10" <sc***@online.n ospam> wrote in message
news:uo******** ******@TK2MSFTN GP15.phx.gbl... Hello,
I have a stored procedure that requires 3 parameters. How do you add multiple parameters for a SqlConnection?
Thanks, Steven
Public strConn = "Data Source=MyServer ;Initial Catalog=MyDatab ase;User Id=MyUser;Passw ord=MyPwd;" Dim cnnSearch As SqlConnection = New SqlConnection(s trConn) Dim cmdRegion As SqlCommand = New SqlCommand("Sal esByCategory", cnnSearch) cmdRegion.Comma ndType = CommandType.Sto redProcedure
Dim myParm As SqlParameter = cmdRegion.Param eters.Add("@Cat egoryName", SqlDbType.VarCh ar, 15) myParm.Value = "NorthAmeri ca"
cnnSearch.Open( )
Dim myReader As SqlDataReader = cmdRegion.Execu teReader()
Thanks for Marina's quick response!
Hi Steve,
First of all, I would like to confirm my understanding of your issue. From
your description, I understand that you need to know how to add 3
parameters to a SqlCommand object. If there is any misunderstandin g, please
feel free to let me know.
Just like Marina mentioned, seems that you know how to add 1 parameter. You
can do it 3 times to add your 3 parameters, since SqlCommand.Para meters is
a collection, which can hold all the parameters required for the stored
procedure. The return value for the Add method is the reference to the
newly added parameter.
For more information, please check the following link: http://msdn.microsoft.com/library/de...us/cpref/html/
frlrfSystemData SqlClientSqlCom mandClassParame tersTopic.asp
Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."
Hi Steve,
I'd like to know if this issue has been resolved yet. Is there anything
that I can help. I'm still monitoring on it. If you have any questions,
please feel free to post them in the community.
Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights." 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# .NET version of this article, see 320627.
This article refers to the following Microsoft .NET...
|
by: simon |
last post by:
Always when I need data reader in my programs, I simply have functions,
which creates it for me:
Dim rdr As SqlDataReader
dim sql as string
sql="myStoredProcedure"
rdr = createDataReader(sql, False)
And the functions are:
|
by: Renato Vieira |
last post by:
I get the error 'Procedure 'spBO_HeadlineCreate' expects parameter
'@imageid', which was not supplied' when i call the procedure with the
@imageid=null, but id the @imageid as a diff. value no error occurs.
Here's the code and the storedproc...
-- code
SqlConnection sqlConnection = new System.Data.SqlClient.SqlConnection
ConfigurationSettings.AppSettings); // Create connection.
SqlCommand sqlUpdProg=new SqlCommand ();...
|
by: Mike Hutton |
last post by:
I have a rather odd problem.
I have a SP which uses temp. tables along the way, and then returns a
table of results:
CREATE PROCEDURE dbo.usp_myproc(
@pNameList VARCHAR(6000)
)
AS
|
by: Tim::.. |
last post by:
I am trying to create a multiple update for a datagrid! At the moment I have
the following sub which could probably be written better but I'm new to
ASP.NET and trying to get this to work first.
For some reason in the second SQL update I keep getting
...::Error
Procedure 'OfficePageUpdate' expects parameter '@ID', which was not supplied.
Even though as far as I can see it is being supplied!
| |
by: pmud |
last post by:
Hi,
I need to use an Excel Sheet in ASP.NET application so that the users can
enter (copy, paste ) large number of rows in this Excel Sheet. Also, Whatever
the USER ENETRS needs to go to the SQL DATABASE, probably by the click of a
button.
Is this possible? & what is the BEST APPROACH for doing this? & also if any
links are there do tell those to me too coz I have no idea how to go about
doing it.
|
by: Andrew Robinson |
last post by:
Are these two equivalent? Is one better than the other? I tend to go with #1
but started wondering....
Thanks,
1:
using (SqlConnection cn = new SqlConnection(DataConnection))
using (SqlCommand cm = new SqlCommand("ItemCount", cn)) {
cm.CommandType = CommandType.StoredProcedure;
|
by: thomson |
last post by:
Hi All,
i do hae a solution in which i do have mulitple projects
including Web Projects,, Depending on the functionality it gets
redirected to different web projects and it is working fine,
for eg: http:DomainName/MainProject/index.aspx, If i login, it gets
redirectes to a different Web Project inside the solution like
http://DomainName/MainProject/ChildProject/MyPage.aspx..
|
by: satyabhaskar |
last post by:
hi all,
In my web page i have created radio buttons dynamically on to the page .....following is my code
string Course, Semester, Section;
int rowsCount;
string con = ConfigurationManager.ConnectionStrings.ConnectionString;
protected void Page_Load(object sender, EventArgs e)
{
try
|
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
| |
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 most users, this new feature is actually very convenient. If you want to control the update process,...
|
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
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 instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
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 the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
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 effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |