Go Premium for a chance to win a PS4. Enter to Win

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

vb.net 4 asp.net 4 web sql parameter

Hello.  I am trying to have my code update a database table.  I want to create a parameter based on the value of label 3 and I am not exactly sure what I am doing wrong.  

Basically I want to use username as a parameter and I want username to always equal label3.text

Any help would be greatly appreciated.
Protected Sub ChangePasswordPushButton_Click(ByVal sender As Object, ByVal e As System.EventArgs)
        Dim username As String
        username = Label3.Text


        Dim dbcon2 As New SqlConnection("Data Source=db_server;Initial Catalog=StatementWeb;User ID=steve;Password=stephen")
        dbcon2.Open()
        Dim dbcmd2 As New SqlCommand
        dbcmd2.Connection = dbcon2
        dbcmd2.CommandText = "update [userinfo] set [pwchange]='No' WHERE ([UserName] = @username)" 
        Dim Value2 As String = dbcmd2.ExecuteScalar()
        dbcmd2.Dispose()
        dbcon2.Dispose()
    End Sub

Open in new window

0
bidgadget
Asked:
bidgadget
1 Solution
 
Rahul AgarwalTeam LeaderCommented:
0
 
bidgadgetAuthor Commented:
Thank you very much.  Exactly what I needed.
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

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