Wrox Programmer Forums

Need to download code?

View our list of code downloads.

| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
ASP.NET 1.0 and 1.1 Basics ASP.NET discussion for users new to coding in ASP.NET 1.0 or 1.1. NOT for the older "classic" ASP 3 or the newer ASP.NET 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 Basics section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old June 1st, 2005, 08:07 PM
Authorized User
Join Date: Apr 2005
Location: Kuala Lumpur, Wilayah Persekutuan, Malaysia.
Posts: 60
Thanks: 0
Thanked 0 Times in 0 Posts
Default Radio Button

I have radio button for user to select Is Administrator(Yes/No), i group them, but can't assign the same name for that 2 button. That's why I can't retrieve the value of user's selection. What should I do?

Dim FirstTime, Admin As Char
 Private Sub rbtnAdmin_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles rbtnAdmin.CheckedChanged
        Admin = "Y"
    End Sub

    Private Sub rbtnNotAdmin_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles rbtnNotAdmin.CheckedChanged
        Admin = "N"
    End Sub

Private Sub btnRegister_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnRegister.Click
        Dim con As New SqlConnection("data source=localhost; initial catalog=""E-Library Records""; user id=sa")
        Dim str = "SELECT * FROM [UserAccount] WHERE User_id = '" & txtUserID.Text & "'"
        Dim dr As SqlDataReader
        Dim da As SqlDataAdapter
        Dim sSQL As New SqlCommand

        With sSQL
            sSQL.Connection = con
            sSQL.CommandText = str
            sSQL.CommandType = CommandType.Text
            dr = sSQL.ExecuteReader()
        End With

        Dim User_id, UserID, User_Password, Pwd, str1 As String
        Dim FirstTime, Admin As RadioButton

        If dr.HasRows Then
            Response.Write("Sorry, the User ID already exists. Please try again.")
            User_id = txtUserID.Text
            User_Password = txtPwd.Text
            User_id = User_id.Trim
            User_Password = User_Password.Trim

            If User_Password.Length < 4 Or User_Password.Length > 10 Then
                Response.Write("Password must be 4-10 characters!")
            End If
                str1 = "INSERT INTO UserAccount Values (@User_id," _
                                        & "@User_Password, @IsFirstTime, @IsAdministrator)"
                Dim InsCom As New SqlCommand(str1, con)
                da.InsertCommand = InsCom
                da.InsertCommand.Parameters.Add(New _
                  SqlParameter("@User_id", SqlDbType.Char, 10))
                da.InsertCommand.Parameters.Add(New _
                  SqlParameter("@User_Password", SqlDbType.Char, 10))
                da.InsertCommand.Parameters.Add(New _
                  SqlParameter("@IsFirstTime", SqlDbType.Char, 1))
                da.InsertCommand.Parameters.Add(New _
                  SqlParameter("@IsAdministrator", SqlDbType.Char, 1))
                da.InsertCommand.Parameters("@User_id").Value = txtUserID.Text
                da.InsertCommand.Parameters("@User_Password").Valu e = txtPwd.Text
                da.InsertCommand.Parameters("@IsFirstTime").Value = Request.Form("FirstTime")
                da.InsertCommand.Parameters("@IsAdministrator").Va lue = Request.Form("Admin")


            Catch err As SystemException


            End Try
        End If
    End Sub

When I debug, I found out that when the execution reach con.Open(), it will go to Catch err As SystemException directly, Is it mean the InsertCommand is not executed?

Can somebody help me? Thank you.


  #2 (permalink)  
Old June 2nd, 2005, 12:08 AM
Friend of Wrox
Join Date: Jun 2004
Location: Chennai, Tamil Nadu, India.
Posts: 449
Thanks: 0
Thanked 1 Time in 1 Post
Send a message via MSN to r_ganesh76

Use RadioButtonList insted


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Radio button gaurisharya C# 2005 2 March 16th, 2008 06:43 AM
radio button anwarraja Javascript 3 September 18th, 2007 08:18 PM
Radio button Jolley_tolson Javascript 2 July 15th, 2007 05:50 AM
radio-button grstad HTML Code Clinic 3 February 28th, 2006 08:32 AM
Button acts depending on radio button values janise Access 4 March 10th, 2004 12:53 AM

All times are GMT -4. The time now is 05:49 AM.

Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.