Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VB.net SUB?

Status
Not open for further replies.

tsp1lrk72

IS-IT--Management
Feb 25, 2008
100
US
Hi,

I'm trying to do an update with a Case Statement to a SQL DB, but I want to do it from my .NET Windows App

I have this, doesn't work...

Code:
Sub FindReplace()
        Dim cn As New SqlClient.SqlConnection
        Dim cmd As New SqlClient.SqlCommand
        Dim ISAID As String
        Select Case ISAID
            Case 8473819430
                ISAID = 2016511600
            Case 135926871
                ISAID = "WEYERHAEUSER"
            Case 6015823680
                ISAID = 9784399625
                cn.ConnectionString = strDbConn
                cn.Open()
                cmd.Connection = cn
                Dim MySQL As String = "UPDATE InovisInt_Lisa " & _
                              "SET ISAID=@ISAID, " & _
                              "WHERE ISAID = @ISAID "
                cmd.Parameters.Add(New SqlParameter("@ISAID", ISAID))
                Dim myCommand As New SqlCommand(MySQL, cn)
                myCommand.ExecuteNonQuery()
                cn.Close()
        End Select
    End Sub

it just doesn't do anything, obviously something is off- any ideas?
Thanks
 
Just an FYI... I got it to work...after adding the Try/Catch... I found that my stored procedure was lacking the necessary rights for it to run...As soon as I granted rights to it, it called the procedure and everything worked- thanks for the advice, I appreciate everyone's help with my issues...

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top