Stored Procedure

  • Thread starter Catalin Porancea
  • Start date
C

Catalin Porancea

Hello,

How can I execute a stored procedure through a odbc command? My stored
procedure only modifies data in db, it doesn't returns any rows and doesn't
use any parameter.

Thank you
 
C

Catalin Porancea

I did, but I got an error saying:

The command text is invalid. To call a stored procedure through ODBC managed
provider the following syntax should be used:

{ CALL <stored procedure name> ( <parameter list> ) }

--
Catalin Porancea
: You can use ExecuteNonQuery method on your connection object.
:
: : > Hello,
: >
: > How can I execute a stored procedure through a odbc command? My stored
: > procedure only modifies data in db, it doesn't returns any rows and
: doesn't
: > use any parameter.
: >
: > Thank you
: >
: >
: >
: > --
: > Catalin Porancea
: >
: >
:
:
 
A

Armin Zingler

Catalin Porancea said:
How can I execute a stored procedure through a odbc command? My
stored procedure only modifies data in db, it doesn't returns any
rows and doesn't use any parameter.

This is a VB.NET language group. Please turn to
microsoft.public.dotnet.framework.adonet.
 
H

Herfried K. Wagner [MVP]

C

Catalin Porancea

ok, if I want to execute the command as a select statement I only have to
use

cmd.commandtext = "select * from table"
cmd.executenonquery

I tried to use
cmd.commandtext = "exec sp_procedure"
cmd.executenonquery

but I get an error.

Does anybody have a solution instead of sending me from one group to
another. Arm, my question is exactly about VB .Net.

--
Catalin Porancea
: Hello,
:
: How can I execute a stored procedure through a odbc command? My stored
: procedure only modifies data in db, it doesn't returns any rows and
doesn't
: use any parameter.
:
: Thank you
:
:
:
: --
: Catalin Porancea
:
:
 
C

Chris Dunaway

Does anybody have a solution instead of sending me from one group to
another. Arm, my question is exactly about VB .Net.
I agree with Armin that your question would probably recieve a quicker
response in the ADO.Net newsgroup, but here is an answer.

Be sure to set the command type to StoredProcedure. Here is an example:


'Code starts here
Dim strCN As String = ConfigurationSettings.AppSettings("Northwind_DSN")
Dim cn As New SqlConnection(strCN)
Dim cmd As New SqlCommand

cn.Open()

With cmd
.Connection = cn
.CommandType = CommandType.StoredProcedure
.CommandText = "usp_region_save"
.Parameters.Add("@id", mintRegionId)
.Parameters.Add("@region", mstrRegionDescription)
.ExecuteNonQuery()
End With

cmd = Nothing
cn.Close()
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top