Solved

vb.net 4  asp.net 4 web sql parameter

Posted on 2011-03-25
2
251 Views
Last Modified: 2012-05-11
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
Comment
Question by:bidgadget
2 Comments
 
LVL 13

Accepted Solution

by:
agarwalrahul earned 500 total points
Comment Utility
0
 

Author Closing Comment

by:bidgadget
Comment Utility
Thank you very much.  Exactly what I needed.
0

Featured Post

Complete Microsoft Windows PC® & Mac Backup

Backup and recovery solutions to protect all your PCs & Mac– on-premises or in remote locations. Acronis backs up entire PC or Mac with patented reliable disk imaging technology and you will be able to restore workstations to a new, dissimilar hardware in minutes.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Hangfire / asp.net sample 3 27
DLL in ASP.NET 20 38
Script is being strange 8 48
c# regex: extract & replace text between braces 6 28
Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

771 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now