Solved

vb.net dataAdapter - query issue...

Posted on 2010-08-30
4
314 Views
Last Modified: 2012-05-10
I need a query that will:

1) I would like to query a ms sql 2005 db on several tables
2) if columnA = 'x' and columnC = 'y' where id = 1 then this var1 = 'true'
3) if columnc = 'x' and columnd = 'y' where id = 2 then this var2 = 'true'
4) if var1='true' then
      run_this_func()
   end if
5) if var2='true'then
      run_that_func()

heres what I have so faar....i need this ASAP...so any help...
   end ifAccept and Award Points Accept as Solution
0
Comment
Question by:GlobaLevel
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
4 Comments
 
LVL 10

Author Comment

by:GlobaLevel
ID: 33560284

forgot to post it:


Private Sub VERIFY_CLIENT_RESPONSE_client_stored_EMAIL()
        ' SO IF THE CLIENT IS STORING THE MASTER FILES TOO BE COPIED
        ' LETS

        Dim client_response As New List(Of String)
        Dim client_stores_files As New List(Of String)

        Dim dataReader As SqlDataReader

        Try

            ' ---=-=-=-=-=
            '
            '
            ' "Data Source=myServerAddress;Initial Catalog=myDataBase;User Id=myUsername;Password=myPassword;"


            Dim x As Integer = 0

            Dim sqlConnection As String

            Using sqlConn As New SqlConnection

                sqlConnection = "Data Source=xx.xx.xx.xx;Initial Catalog=xx;User Id=;Password=;"
                sqlConn.ConnectionString = sqlConnection

                Dim SQLString As String = "SELECT cr.EMAIL_RESPONSE, cr.color_number, cr.paper_line, pt.product_weight, pt.paper_legal FROM CLIENT_RESPONSE cr JOIN paper_table pt ON pt.client_id = cr.client_id WHERE server_name=" & server_name & _
                    "and P_NAME = " & P_NAME & "ORDER BY cr.email_response asc, cr.color_number asc,cr.paper_line asc"

                ' Dim dataReader As SqlDataReader
                sqlConn.Open()
                Using command As New SqlCommand(SQLString, sqlConn)
                    dataReader = command.ExecuteReader(CommandBehavior.CloseConnection)
                    Do While dataReader.Read()
                        client_response.Add(dataReader.GetValue(0).ToString())
                    Loop


                  '-------------------------------------------------------------------------------

                  ' SORT TO DATAVIEW...THEN FEED INTO VARIABLES TO BE USED LATER....
                  '       NOT GOOD TO KEEP CONNECTION OPEN FOR TOO LONG
                  ' IF COLUMN = 'THIS' THEN FEED INTO VARAIBLE
                  ' BECAUSE SIMILIAR VALUES EXIST IN DIFFERENT COLUMNS

                  Dim dt As DataTable
                  Dim myDataView As DataView

                  dt.Load(dataReader)
                  myDataView = dt.DefaultView
                  myDataView.Sort = "color_number DESC"

                  if dt.cr.paper_line = "y" and dt.cr.EMAIL_RESPONSE = "y" then
                            dim client_response_wants_legal_paper as string
                        dt = client_response_wants_legal_paper
                  end if

     
                  if dt.cr.color_number = "y" and dt.cr.vm_RESPONSE = "y" then
                            dim client_vm_wants_red_paper as string
                        dt = client_vm_wants_red_paper
                  end if

                  if dt.pt.product_weight = "y" and dt.cr.vm_RESPONSE = "y" then
                            dim client_vm_wants_weighted_paper as string
                        dt = client_vm_wants_weighted_paper
                  end if

     
                  '-------------------------------------------------------------------------------


                    dataReader.Close()
                    sqlConn.Close()
                End Using
            End Using

            'Retrieve the number of record.
            x = client_response.Count

            MsgBox("CLIENT FILE PATHS ARE NOT FOUND...")
            'UsernameTextBox.Focus()

      '-------------------------------------------------------------------------------
      '
      ' NOW THAT THE VARAIBLES HAVE BEEN SET...
      ' IF IT EXISTS...REDIRECT TO ANOTHER FUNCTION IN THE PROGRAM..

           If client_response_wants_legal_paper <> "" Then
                switch_paper_to8_x _14()
            End If

            If client_vm_wants_red_paper <> "" Then
                switch_color_to_red()
            End If

            If client_vm_wants_weighted_paper <> "" Then
                switch_paper_to_weighted()
            End If



        Catch ex As FileNotFoundException
        Catch ex As Exception
            MessageBox.Show("Please reJECT: DL ISSUE_sql connection....BODY: ERROR: " + ex.Message)
        End Try

    End Sub
0
 
LVL 10

Author Comment

by:GlobaLevel
ID: 33560291
would this work the above????
0
 
LVL 35

Accepted Solution

by:
YZlat earned 500 total points
ID: 33560677
Use CASE WHEN
0
 
LVL 10

Author Comment

by:GlobaLevel
ID: 33561166
does everything else look okay in the code?
0

Featured Post

Get Actionable Data from Your Monitoring Solution

Your communication platform is only as good as the relevance of the information you send. Ensure your alerts get to the right people every time with actionable responses. Create escalation rules that ensure everyone follows the process and nothing is left to chance.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…

717 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question