473,549 Members | 2,682 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to call parameterized stored procedure by "OdbcConnection " in c#.net

2 New Member
Hi,
I am facing a problem with stored procedure in case of "OdbcConnection ". The code is given below:-
Expand|Select|Wrap|Line Numbers
  1.  
  2.  OdbcConnection conn = new OdbcConnection(connstring);
  3.             conn.Open();
  4.             OdbcCommand cmd = new OdbcCommand("sp_comboIDChange", conn);
  5.             cmd.CommandType = CommandType.StoredProcedure;
  6.             OdbcParameter parameter1 = new OdbcParameter();
  7.  
  8.             parameter1.OdbcType = OdbcType.VarChar;
  9.             parameter1.ParameterName = "@Branch_Code";
  10.             parameter1.Value = Combo;
  11.             cmd.Parameters.Add(parameter1);
  12.  
  13.             OdbcDataReader dr = cmd.ExecuteReader();
  14.             while (dr.Read())
  15.             {
  16.                 s = dr[0].ToString();
  17.             }
  18.  
  19.             conn.Dispose();
  20.  
And my stored procedure is:-
[SCRIPT]
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFI ER ON
GO
ALTER PROCEDURE [dbo].[sp_comboIDChang e]
@Branch_Code bigint
AS
BEGIN
select Branch_Name from TBranch_Entry where Branch_Code=@Br anch_Code
END
GO
SET ANSI_NULLS OFF
GO
SET QUOTED_IDENTIFI ER OFF
GO
[/SCRIPT]

The Error is:-

ERROR [42000] [Microsoft][ODBC SQL Server Driver][SQL Server]Procedure or Function 'sp_comboIDChan ge' expects parameter '@Branch_Code', which was not supplied.

But if i use "SqlConnect ion" in spite of "OdbcConnection " then the is not occurred. What is the problem in "OdbcConnection "? Please, anyone inform me.

Your regards
Miraz
Mar 21 '11 #1
0 1191

Sign in to post your reply or Sign up for a free account.

Similar topics

3
1473
by: Charles Stanley | last post by:
Hi all, I'm new to C#, and have two pretty simple questions: I have a class, in a .cs file by itself. I need to make use of the sole function in this class in another .cs file. Here's the code, filename bannertrack.cs First question - the function "LogImpr" users ServerVariables + "')"; The compiler tells me that this is not included...
6
4431
by: bill salkin | last post by:
I setup a "Try..." block and attempted to open a non- existant database. It went to the second "catch" not the first. What is the proper "catch" clause for this specific case? TIA, Bill
7
3726
by: bazzer | last post by:
i am having trouble updating a datset because i get the follwing error in the Data Adapter configuration Wizard: Generated UPDATE statement. could not determine which columns uniquely identify the rows for "Customers" 'Customers' is the only table from the database that im using for this query, so it cant be anything to do with a problem...
2
1000
by: ewpatton | last post by:
I'm having trouble using OdbcConnection and OdbcCommand to make updates to a System database. I can open the database in Access and make changes, but executing a simple: INSERT INTO LoginInfo DEFAULT VALUES fails miserably. I have set Everyone to have all permissions to the folder that contains the database so there shouldn't be any...
0
7520
marktang
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...
0
7720
Oralloy
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. ...
0
7957
jinu1996
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...
1
7470
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...
0
7809
tracyyun
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...
0
6043
agi2029
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5368
isladogs
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...
0
5088
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...
0
3481
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.