Click here to Skip to main content
15,914,924 members
Home / Discussions / ASP.NET
   

ASP.NET

 
GeneralRe: encrypt the coookies Pin
saravanan0513-Jun-07 20:34
saravanan0513-Jun-07 20:34 
GeneralRe: encrypt the coookies Pin
Sathesh Sakthivel13-Jun-07 20:37
Sathesh Sakthivel13-Jun-07 20:37 
GeneralRe: encrypt the coookies Pin
saravanan0513-Jun-07 20:41
saravanan0513-Jun-07 20:41 
GeneralRe: encrypt the coookies Pin
Sylvester george13-Jun-07 20:45
Sylvester george13-Jun-07 20:45 
GeneralRe: encrypt the coookies Pin
saravanan0513-Jun-07 20:51
saravanan0513-Jun-07 20:51 
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 
Hi, I am new to ASP.NET and VB.NET. My app is supposed to check if a user already exists. On one of the lines of code below I'm trying to use CType to retrieve a data from the database. I get the error message "Object reference not set to an instance of an object". I did a search on this error message and found one site that saia that the most common cause of this is that one for gets to declare a variable. The second most common cause is bad scoping (declaring the variable locally instead of globally). I've checked but I did not find the above to be the cause of the error message. Perhaps you could help me spot the cause of the error message. It's most likely that I am using the CType and ExecuteScalar methods incorrectly. The following is my code, please take a look. Thank you in advance for your help.
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 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=myUSER;Password=myPW;Option=3;")
    strSQL = String.Format("SELECT myUserName FROM myTable WHERE (email='{0}');", txtUserName)
    myCommand.CommandText = strSQL
    myCommand.CommandType = CommandType.Text

    strInsert = "INSERT into membersinfotbl (FirstName,LastName,Password,Phone,Email,Profession,StrAddress,City,State,ZipCode)value (?,?,?,?,?,?,?,?,?,?)"
    myCommand = New OdbcCommand("StrInsert", myConnection)
    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)

    myConnection.Open()
    strGoodPassword = CType(myCommand.ExecuteScalar, String)
    myCommand.ExecuteNonQuery()
    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

    myConnection.Close()


End Sub







-- modified at 0:19 Thursday 14th June, 2007
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 
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 

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.