locked
how do i see if record ex. else see if its activ or... RRS feed

  • Question

  • User651828378 posted

    Hi

    I have this code to showing records from a access DB, but im new to this so need a little help.

            Using connection As OleDbConnection = New OleDbConnection(ConfigurationManager.ConnectionStrings("MyConnStr").ConnectionString)
                Using command As OleDbCommand = New OleDbCommand("select * from TableTest", connection)
                    command.Connection.Open()
                    Using reader As OleDbDataReader = command.ExecuteReader(CommandBehavior.CloseConnection)
                        While reader.Read()
                            Response.Write(reader("record") & "<br />")
                        End While
                    End Using
    
                End Using
            End Using




    With this code i normally show some records now i need to see if a record is in the database if not then do one thing, if its in the database and the status is activ, then do another thing and if its not activ then do a 3. thing.

    I have an email that i get from this Request.Form("MasterID$newsletter") if this email is in the database then
    If status = activ then

    MultiView1.SetActiveView(Activ)




    If status = notactic then

    MultiView1.SetActiveView(notactiv)



    And if the email isent in the db at all then

    MultiView1.SetActiveView(newemail)



    How can i edit "my using code" so i can check if and email is in my database and after the, check if its activ or notactiv
    And then in the response.write show one of the Multiviews



    Wednesday, April 18, 2012 12:35 PM

Answers

  • User3866881 posted

    With this code i normally show some records now i need to see if a record is in the database if not then do one thing, if its in the database and the status is activ, then do another thing and if its not activ then do a 3. thing.

    【Solutions】

    1)Check whether email exits in your db。

    1.2)If yes,Check whether it's active。Otherwises do step1。

    1.3)If active,do step2,then do step3:

    Sample:

     Using connection As OleDbConnection = New OleDbConnection(ConfigurationManager.ConnectionStrings("MyConnStr").ConnectionString)
                Using command As OleDbCommand = New OleDbCommand("select top 1 * from TableTest where [emailFieldName]='"+Request.Form["YourQueryName"]+"'", connection)
                    command.Connection.Open()
                    Using reader As OleDbDataReader = command.ExecuteReader(CommandBehavior.CloseConnection)
                        'Check whether it exits or not……
                        If reader.Read() Then
                            If reader("ActiveFieldName").ToString()=="Activated") Then
                               'Do Step 2
                            Else
                               'Do Step 3
                            End If
                        Else
                            'Do Step 1
                        End If
                    End Using
                End Using
            End Using

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, April 19, 2012 9:46 PM