Dataviews, datasets, joining, parent/child issues

college_amy

Regular
Joined
Jan 3, 2004
Messages
83
:confused: Ok.. Here is what I am trying to accomplish:
I have a webpage that I want users to be able to search for something by state and type of service.. when the results are displayed I want the user to be able to get more information about a specific result by clicking on it and having it open a new page with many details.

Here is what I have to accomplish this:
Access database with 4 tables that contain bits and pieces of the necessary information to be displayed in the detailed page.
I can successfully create a dataset that joins the two tables of which the state and service are housed. My dataview is acting crazy but I know I am missing something and don't know the best way to fix it - but it does kinda work....

My first task is to get the displayed results (not detailed displayed yet) to show up correctly - obviously. Right now when I select a state and service.. the 1st time.. it shows the correct result of the test record. But when I purposely ask it to display the same state with a different service that is NOT going to provide any records, it still shows the same record from the first search, which it shouldn't be doing. now, when I select a state that I know does not have a result, it does properly display the message of no records returned. But if I select ANY state that has a record with that state name, no matter what service I pick, it displays the answer... so it isn't checking to make sure the service is a "Yes" like displayed in my sql statement below.
So that leads me to conclude 1/2 of my program is working correctly but I don't know how to get the other part to check correctly. PLEASE HELP! BY the way, I am not getting an error.

Here is part of my code: (all the stuff important to this problem)

<CODE>
Setup the SQL String
'SQLString = "SELECT billing.state, info.'" & prof.SelectedItem.Value & "'" & _
'"FROM billing " & _
'"INNER JOIN info " & _
'"ON billing.LoginID = info.LoginID " & _
'"AND billing.state ='" & state.SelectedItem.Value & "' " & _
'"AND info.'" & prof.SelectedItem.Value & "' ='Yes'"

'Add two tables to the dataset
SQLString ="SELECT * From billing WHERE state = '" & state.SelectedItem.Value &"'"
DBAdapter = New OleDbDataAdapter(SQLString, DBConnection)
DBAdapter.Fill(DBDataSet, "billing")
DBAdapter.SelectCommand = New OleDbCommand( "Select * From info Where '" & prof.SelectedItem.Value & "' ='Yes'", DBConnection)
DBAdapter.Fill(DBDataSet, "info")

'Close the connection
DBConnection.Close()

'Add the Relations
DBDataSet.Relations.Add( _
"billing_info", _
DBDataSet.Tables( "billing" ).Columns( "LoginID" ), _
DBDataSet.Tables( "info" ).Columns( "LoginID" ) )

DBDataView = New DataView(DBDataSet.Tables("billing"))
If DBDataSet.Tables("billing").Rows.Count = 0 Then
err.Text = "No matching records"
working.Visible="false"
Else
err.Text="Search is Complete!"
working.Visible="true"
Pro_Display.DataSource = DBDataView
Pro_Display.DataBind()

</CODE>
 
I'm not sure I understand exactly what you are asking for but I'll give it a shot.

first; make sure that autopostback for both of your dropdownlist is set to true

second; I don't see the where clause in you initial statement. I think it will still work like it is but I would add the where anyway

third; If what you mean by open is something like a popup so the main form doesn't open then then you will need to add a javascript function that opens a window controls to one of your controls

control1.attributes("on_click","whatever")

function whatever(){
window.open("formname.aspx")
}

you can also set various properties on the open function

Hope this helps
 
'Add two tables to the dataset
SQLString ="SELECT * From billing WHERE state = '" & state.SelectedItem.Value &"'"
DBAdapter = New OleDbDataAdapter(SQLString, DBConnection)
DBAdapter.Fill(DBDataSet, "billing")
DBAdapter.SelectCommand = New OleDbCommand( "Select * From info Where '" & prof.SelectedItem.Value & "' ='Yes'", DBConnection)
DBAdapter.Fill(DBDataSet, "info")

'Close the connection
DBConnection.Close()

'Add the Relations
DBDataSet.Relations.Add( _
"billing_info", _
DBDataSet.Tables( "billing" ).Columns( "LoginID" ), _
DBDataSet.Tables( "info" ).Columns( "LoginID" ) )

DBDataView = New DataView(DBDataSet.Tables("billing"))
If DBDataSet.Tables("billing").Rows.Count = 0 Then
err.Text = "No matching records"
working.Visible="false"
Else
err.Text="Search is Complete!"
working.Visible="true"
Pro_Display.DataSource = DBDataView
Pro_Display.DataBind()

</CODE> [/B]

This is the section where I think the problem is. When I do the search it works, 1/2way... I get the results for the state search part of the program, But it is not checking to see if the prof=yes is true... I think the messup is somewhere in my DBDataView because I am only referencing to the billing dataset, but I don't know how to have it reference to both so that both conditions must be true to get the correct result.


Thanks for the info on the new window... and the autopostback - I have both of those figured out now... it is just this part that I am not getting...
 
Back
Top