Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 386
  • Last Modified:

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
0
anusdesai
Asked:
anusdesai
  • 5
  • 4
1 Solution
 
DhaestCommented:
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
 
anusdesaiAuthor Commented:
Cheers ! will try and be right back
0
 
anusdesaiAuthor Commented:
Hi,
There is no specific method given in the article...
any example of function or procedure will be helpful

Cheers
0
Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

 
DhaestCommented:
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
 
anusdesaiAuthor Commented:
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
 
DhaestCommented:
Did you try the following:

Dim sqlComm As New SqlCommand(YourSqlBox.Text, sqlConn)
sqlComm.ExecuteNonQuery
0
 
anusdesaiAuthor Commented:
Cheers ...will try abd be right back
0
 
DhaestCommented:
Did it solve your problem ?
0
 
anusdesaiAuthor Commented:
Cheers mate..sorry for replying late was away for a while.
Cheers for being so concerned.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

  • 5
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now