Link to home
Start Free TrialLog in
Avatar of anusdesai
anusdesai

asked on

Executing stored procedure with vb.net 2.0

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
Avatar of Dirk Haest
Dirk Haest
Flag of Belgium image

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
Avatar of anusdesai
anusdesai

ASKER

Cheers ! will try and be right back
Hi,
There is no specific method given in the article...
any example of function or procedure will be helpful

Cheers
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

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
ASKER CERTIFIED SOLUTION
Avatar of Dirk Haest
Dirk Haest
Flag of Belgium image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Cheers ...will try abd be right back
Did it solve your problem ?
Cheers mate..sorry for replying late was away for a while.
Cheers for being so concerned.