By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
464,662 Members | 1,281 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 464,662 IT Pros & Developers. It's quick & easy.

Stored Procedure

P: n/a
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
Nov 20 '05 #1
Share this Question
Share on Google+
6 Replies

P: n/a
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
"Scott Meddows" <sc******************@tsged.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
: You can use ExecuteNonQuery method on your connection object.
:
: "Catalin Porancea" <cp*******@midwestern.net> wrote in message
: news:%2****************@tk2msftngp13.phx.gbl...
: > 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
: >
: >
:
:
Nov 20 '05 #2

P: n/a
"Catalin Porancea" <cp*******@midwestern.net> schrieb
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.
--
Armin

Nov 20 '05 #3

P: n/a
"Catalin Porancea" <cp*******@midwestern.net> schrieb:
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.


Why don't update to ADO.NET?

This is a VB.NET language group. Please turn to the ADO.NET newsgroup:

news://msnews.microsoft.com/microsof...amework.adonet

Web interface:

http://msdn.microsoft.com/newsgroups...amework.adonet

--
Herfried K. Wagner
MVP VB Classic, VB.NET
http://www.mvps.org/dotnet
Nov 20 '05 #4

P: n/a
"Herfried K. Wagner [MVP]" <hi*******@m.activevb.de> schrieb:
Why don't update to ADO.NET?


Just ignore the line above...

--
Herfried K. Wagner
MVP VB Classic, VB.NET
http://www.mvps.org/dotnet
Nov 20 '05 #5

P: n/a
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
"Catalin Porancea" <cp*******@midwestern.net> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
: 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
:
:
Nov 20 '05 #6

P: n/a
"Catalin Porancea" <cp*******@midwestern.net> wrote in news:
#F**************@tk2msftngp13.phx.gbl:

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()

Nov 20 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.