473,394 Members | 1,718 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

ODBC parameters

1
Hi,
I am using visual studio vb .net and sql server database

I need help on show to set the ODBC parameters names and types of a stored procure at run time in visual basic .net

The below code is a sample code
Expand|Select|Wrap|Line Numbers
  1. Dim command As OdbcCommand = New OdbcCommand ("{ CALL StoredProcedureName(?) }", Connection)
  2.  
  3. Dim Parameter as OdbcParameter
  4.  
  5. command.CommandType = CommandType.StoredProcedure
  6.  
  7. Parameter = command.Parameters.Add("@Parameter Name", OdbcType.VarChar, 10)
  8.  
  9. Parameter.Value = “test”
  10.  
  11.  
  12.  
  13. command.ExecuteNonQuery ()
  14.  

I can set the parameter value at run time as the user enters the value but I need the code to be more dynamic in the following sense:

Can I set the parameter name at run time i.e. from a variable?
Expand|Select|Wrap|Line Numbers
  1. Parameter = command.Parameters.Add(ParamName, OdbcType.VarChar, 10)


Can I set the parameter Type (OdbcType) at run time i.e. from a variable?
Expand|Select|Wrap|Line Numbers
  1. Parameter = command.Parameters.Add("@Parameter Name", ParamType, 10)
Jul 23 '07 #1
1 2226
Frinavale
9,735 Expert Mod 8TB
Hi,
I am using visual studio vb .net and sql server database

I need help on show to set the ODBC parameters names and types of a stored procure at run time in visual basic .net
...
Can I set the parameter name at run time i.e. from a variable?
Expand|Select|Wrap|Line Numbers
  1. Parameter = command.Parameters.Add(ParamName, OdbcType.VarChar, 10)
I've never used ODBC before but...
Have you tried using something like:
Expand|Select|Wrap|Line Numbers
  1. command.Parameters.Add("@MyName", OdbcType.VarChar, 30)
  2. command.Parameters("@MyName").Value = names
  3.  
-Frinny
Jul 23 '07 #2

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

Similar topics

6
by: Andreas Lauffer | last post by:
I changed from Access97 to AccessXP and I have immense performance problems. Details: - Access XP MDB with Jet 4.0 ( no ADP-Project ) - Linked Tables to SQL-Server 2000 over ODBC I used...
4
by: Roger Redford | last post by:
Dear Experts, I'm attempting to marry a system to an Oracle 817 datbase. Oracle is my specialty, the back end mainly, so I don't know much about java or javascript. The system uses javascript...
3
by: Lauren Quantrell | last post by:
Maybe a dumb question - I'm new to ODBC. How do I install an Access ..mde file on a user's workstation and create the ODBC connection to the backend SQL Server database without having to go through...
5
by: Alec | last post by:
Hi All, I am currently trying to link in Access 97 to a table in a MSSQL 7 server. Initially the link is fine, however, when I close the access database and re-open it from the same network...
3
by: juststarter | last post by:
Hello all, I am executing a stored procedure (on an SQL Server) using ODBC but i can't get the output parameter's value on the client. The stored proc has 3 parameters ,2 of them are input and 1...
0
by: jwtulp | last post by:
Hello all, I receive the following error when updating MSAccess2003 Memo fields using an ODBC connection in ASP.Net 1.1 when the length of the text to be updated exceeds 255 characters....
4
by: datapro01 | last post by:
Running DB28.2 on AIX 5.2. I have two questions if its possible for anyone to assist. 1. Is it possible to make use of a 'Shadow Catalog' on DB2 UDB v8.2 on AIX? If so, how? Can anyone give...
1
by: cindy | last post by:
this is the call private void Page_Load(object sender, System.EventArgs e) { OdbcConnection connection = new OdbcConnection ("DSN=PFW52"); CreateDataAdapter(connection); } this is the code,...
2
by: Santosh | last post by:
Hii all i have written following code for inserting records into database but it gives me an error espected parameter @NewsTitle which is not supplied. OdbcConnection conn = new...
0
by: NM | last post by:
Hello, I've got a problem inserting binary objects into the postgres database. I have binary objects (e.g. images or smth else) of any size which I want to insert into the database. Funny is it...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
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...
0
BarryA
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
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...
0
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...
0
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,...
0
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...
0
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,...

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.