Solved

Executing stored procedure with vb.net 2.0

Posted on 2008-06-16
9
363 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
Turn Insights into Action

Communication across every corner of your business is essential to increase the velocity of your application delivery and support pipeline. Automate, standardize, and contextualize your communication processes with xMatters.

 
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 500 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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)…
Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
If you're a developer or IT admin, you’re probably tasked with managing multiple websites, servers, applications, and levels of security on a daily basis. While this can be extremely time consuming, it can also be frustrating when systems aren't wor…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

696 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