Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Executing stored procedure with vb.net 2.0

Posted on 2008-06-16
9
Medium Priority
?
375 Views
Last Modified: 2013-11-26
Hi,
I am using a richtextbox to load a stored procedure in vb.net application.
Any points regarding how to execute the stored procedur like query analyser with vb.net will be helpful

Regards
0
Comment
Question by:anusdesai
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 4
9 Comments
 
LVL 53

Expert Comment

by:Dhaest
ID: 21792228
Is your stored procedure on your database ?

The Ins and Outs of Stored Procedures in VB.NET
http://www.vbdotnetheaven.com/UploadFile/dclark/StoredProceduresinVBdotNET04082005072716AM/StoredProceduresinVBdotNET.aspx
0
 

Author Comment

by:anusdesai
ID: 21792422
Cheers ! will try and be right back
0
 

Author Comment

by:anusdesai
ID: 21793300
Hi,
There is no specific method given in the article...
any example of function or procedure will be helpful

Cheers
0
Basic Security of Your VPC

So, you’ve got this shiny new VPC and a fancy new application configured on your EC2 servers ready to go. This application is only accessible from your computer, which is great for security, but you need your users to be able to access it! So, what’s the easiest way to do this?

 
LVL 53

Expert Comment

by:Dhaest
ID: 21793320
Do you have a stored procedure on your sql-server ?
Calling Stored Procedures with ADO.NET
http://www.developer.com/db/article.php/3438221


Below you can find an example to call the stored procedure "SelectCustomer" with 1 parameter
Public Sub SelectCustomer()
    Dim connection As SqlConnection = _
        New SqlConnection(connectionString)
    connection.Open()
    Try
 
        Dim command As SqlCommand = _
            New SqlCommand("SelectCustomer", _ connection)
        command.Parameters.Add("@CustomerID", "PAULK")
        command.CommandType = CommandType.StoredProcedure
 
        Dim adapter As SqlDataAdapter = New SqlDataAdapter(command)
 
        Dim table As DataTable = New DataTable
        adapter.Fill(table)
 
    Catch ex As Exception
        Console.WriteLine(ex.Message)
        Throw
    Finally
        connection.Close()
    End Try
End Sub

Open in new window

0
 

Author Comment

by:anusdesai
ID: 21794107
Hi,
Cheers
But ,the requirement is i have a script in my sqlbox example
Go
declare @i smallint

set @i = 1

Update abc set @i = no =  
                  case @i
                        when 1 then Countstmode
                        else @i - 1
                  End
GO

 
I need to read the script line by line and then execute .

Cheers
0
 
LVL 53

Accepted Solution

by:
Dhaest earned 2000 total points
ID: 21800173
Did you try the following:

Dim sqlComm As New SqlCommand(YourSqlBox.Text, sqlConn)
sqlComm.ExecuteNonQuery
0
 

Author Comment

by:anusdesai
ID: 21801013
Cheers ...will try abd be right back
0
 
LVL 53

Expert Comment

by:Dhaest
ID: 21819800
Did it solve your problem ?
0
 

Author Closing Comment

by:anusdesai
ID: 31467530
Cheers mate..sorry for replying late was away for a while.
Cheers for being so concerned.
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It seems a simple enough task, yet I see repeated questions asking how to do it: how to pass data between two forms. In this article, I will show you the different mechanisms available for you to do just that. This article is directed towards the .N…
Welcome my friends to the second instalment and follow-up to our Minify and Concatenate Your Scripts and Stylesheets (http://www.experts-exchange.com/Programming/Languages/.NET/ASP.NET/A_4334-Minify-and-Concatenate-Your-Scripts-and-Stylesheets.html)…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …

715 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question