Wrox Programmer Forums
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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old June 1st, 2005, 08:07 PM
Authorized User
Join Date: Apr 2005
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.


Old June 2nd, 2005, 12:08 AM
Friend of Wrox
Join Date: Jun 2004
Posts: 449
Thanks: 0
Thanked 1 Time in 1 Post
Send a message via MSN to r_ganesh76

Use RadioButtonList insted


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

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.