Click here to Skip to main content
15,892,005 members
Home / Discussions / ASP.NET
   

ASP.NET

 
GeneralRe: encrypt the coookies Pin
saravanan0513-Jun-07 21:12
saravanan0513-Jun-07 21:12 
GeneralRe: encrypt the coookies Pin
saravanan0513-Jun-07 21:32
saravanan0513-Jun-07 21:32 
QuestionHelp using CTYPE [modified] Pin
ASPnoob13-Jun-07 17:58
ASPnoob13-Jun-07 17:58 
QuestionRe: Help using CTYPE Pin
Venkatesh Mookkan13-Jun-07 18:11
Venkatesh Mookkan13-Jun-07 18:11 
AnswerRe: Help using CTYPE Pin
ASPnoob13-Jun-07 18:16
ASPnoob13-Jun-07 18:16 
GeneralRe: Help using CTYPE Pin
Venkatesh Mookkan13-Jun-07 18:28
Venkatesh Mookkan13-Jun-07 18:28 
GeneralRe: Help using CTYPE [modified] Pin
ASPnoob13-Jun-07 19:02
ASPnoob13-Jun-07 19:02 
AnswerRe: Help using CTYPE Pin
Venkatesh Mookkan13-Jun-07 19:38
Venkatesh Mookkan13-Jun-07 19:38 
ASPnoob wrote:
strSQL = String.Format("SELECT myUserName FROM myTable WHERE (email='{0}');", txtUserName)
myCommand.CommandText = strSQL
myCommand.CommandType = CommandType.Text


You have assigned the query, but not executed the myCommand. Again you started assigning the INSERT statement. First time you have assigned the SELECT statement. You should execute the ExecuteScalar next to it and do your conditional check there. If everything ok, then assign the INSERT statement to myCommand object and execute the ExecuteNonQuery command.

Private Sub lblRegister_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lblRegister.Click
        Dim bResult As Boolean = False
        Dim myConnection As OdbcConnection
        Dim myCommand As New OdbcCommand
        Dim strInsert As String
        Dim strGoodPassword As String
        Dim cmdInsert As New OdbcCommand
        Dim strSQL As String
        myConnection = New OdbcConnection("Driver={MySQL ODBC 3.51 Driver};Server=localhost;Database=myDb;User=myUSERassword=myPW;Option=3;")
        strSQL = String.Format("SELECT myUserName FROM myTable WHERE (email='{0}');", txtUserName)
        myConnection.Open()
        myCommand.Connection = myConnection
        myCommand.CommandText = strSQL
        myCommand.CommandType = CommandType.Text
        strGoodPassword = CType(myCommand.ExecuteScalar, String)
        If Not strGoodPassword Is Nothing Then
            If strGoodPassword = txtPassword.Text Then
                bResult = True
            Else
                lblMessage.Text = "That user name is already taken!"
                lblMessage.Text &= "  Please choose another user name."
            End If
        Else
            lblMessage.Text = "That user name is already taken!"
            lblMessage.Text &= "  Please choose another user name."
        End If
        strInsert = "INSERT into membersinfotbl (FirstName,LastName,Password,Phone,Email,Profession,StrAddress,City,State,ZipCode)value (?,?,?,?,?,?,?,?,?,?)"
        myCommand.CommandText = strInsert
        myCommand.CommandType = CommandType.StoredProcedure
        myCommand.Parameters.Add("@FirstName", txtFirst.Text)
        myCommand.Parameters.Add("@LastName", txtLast.Text)
        myCommand.Parameters.Add("@Password", txtPassword.Text)
        myCommand.Parameters.Add("@Phone", txtPhone.Text)
        myCommand.Parameters.Add("@Email", txtEmail.Text)
        myCommand.Parameters.Add("@Profession", txtProfession.Text)
        myCommand.Parameters.Add("@StrAddress", txtAddress.Text)
        myCommand.Parameters.Add("@City", txtCity.Text)
        myCommand.Parameters.Add("@State", txtState.Text)
        myCommand.Parameters.Add("@ZipCode", txtZipCode.Text)        
        myCommand.ExecuteNonQuery()
        myConnection.Close()
End Sub


Try the above code....


ASPnoob wrote:
strGoodPassword = CType(myCommand.ExecuteScalar, String)



ASPnoob wrote:

If Not strGoodPassword Is Nothing Then
If strGoodPassword = txtPassword.Text Then
bResult = True
Else
lblMessage.Text = "That user name is already taken!"
lblMessage.Text &= " Please choose another user name."
End If
Else
lblMessage.Text = "That user name is already taken!"
lblMessage.Text &= " Please choose another user name."
End If


But I am confused, why you are validating the Password with the Username field. Confused | :confused:


Regards,
Venkatesh Mookkan.
Software Engineer, India
My: Website | Yahoo Group | Blog Spot

GeneralRe: Help using CTYPE Pin
ASPnoob13-Jun-07 20:15
ASPnoob13-Jun-07 20:15 
GeneralRe: Help using CTYPE Pin
Venkatesh Mookkan13-Jun-07 20:22
Venkatesh Mookkan13-Jun-07 20:22 
GeneralRe: Help using CTYPE [modified] Pin
ASPnoob13-Jun-07 20:53
ASPnoob13-Jun-07 20:53 
AnswerRe: Help using CTYPE Pin
Chetan Ranpariya13-Jun-07 23:00
Chetan Ranpariya13-Jun-07 23:00 
Questionaspx.vb Pin
ling_luv13-Jun-07 17:50
ling_luv13-Jun-07 17:50 
AnswerRe: aspx.vb Pin
Venkatesh Mookkan13-Jun-07 18:09
Venkatesh Mookkan13-Jun-07 18:09 
AnswerRe: aspx.vb Pin
vmkumar9113-Jun-07 19:39
vmkumar9113-Jun-07 19:39 
QuestionAdobe ActiveX question Pin
rudemusik13-Jun-07 16:25
rudemusik13-Jun-07 16:25 
AnswerRe: Adobe ActiveX question Pin
Venkatesh Mookkan13-Jun-07 17:36
Venkatesh Mookkan13-Jun-07 17:36 
QuestionDynamic table with text box and button Pin
J Liang13-Jun-07 15:49
J Liang13-Jun-07 15:49 
AnswerRe: Dynamic table with text box and button Pin
Not Active13-Jun-07 16:54
mentorNot Active13-Jun-07 16:54 
QuestionC# Gridview and image field Pin
InvalidTypecast13-Jun-07 15:49
InvalidTypecast13-Jun-07 15:49 
AnswerRe: C# Gridview and image field Pin
Not Active13-Jun-07 17:05
mentorNot Active13-Jun-07 17:05 
GeneralRe: C# Gridview and image field Pin
InvalidTypecast13-Jun-07 17:11
InvalidTypecast13-Jun-07 17:11 
GeneralRe: C# Gridview and image field Pin
Sathesh Sakthivel13-Jun-07 17:28
Sathesh Sakthivel13-Jun-07 17:28 
GeneralRe: C# Gridview and image field Pin
Not Active14-Jun-07 2:17
mentorNot Active14-Jun-07 2:17 
AnswerRe: C# Gridview and image field Pin
Jay_se13-Jun-07 18:47
Jay_se13-Jun-07 18:47 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.