Hi,
I'll probably look really silly for asking this question, but it's been baffling me for a week now (stupid I know).
I am tring to pull data from an Access database, depending on the options selected on a form. I have tried various formats for my statement but only the most basic works (i.e. SELECT Abb1, Abb2, Abb3, Abb4, Abb5, Abb6, Abb7 FROM Abbreviations).
Let me start from the beginning. I'm trying to create a crossword solver using ASP.net, the user enters data into the form, which returns the possible solutions to a clue into a dataGrid. There are 2 RadioButtonLists on the form, one which relates to the name of the table in the database, and the other which refers to the number of letters for each solution in the table. There is also a textarea for the user to enter a clue.
What I would like to do is depending on the Clue Type (Anagram, Abbreviation, etc) (1st RadioButtonList) I want to select data in the table according to the number of letters (selected from the 2nd RadioButtonList), and the clue entered.
My coding so far goes as follows:
Dim strConnection As String = "Provider = Microsoft.Jet.OleDb.4.0;Data Source = C:\Inetpub\ Dim ojbConnection As New OleDb.OleDbConnection(strConnection)
Dim No_Letts As Integer = No_Letters.SelectedItem.Value
Dim ClueBX As String = Clue_box.Text
Dim strSQL As String = "SELECT Abb1, Abb2, Abb3, Abb4, Abb5, Abb6, Abb7 FROM Abbreviations WHERE ((' " & No_Letts & " ' = NoLett1) AND (Word = ' " & ClueBX & " '))"
Dim ojbCommand As New OleDb.OleDbCommand(strSQL, ojbConnection)
ojbConnection.Open()
AdvancedSolutions1.DataSource = ojbCommand.ExecuteReader()
AdvancedSolutions1.DataBind()
ojbConnection.Close()
I have previously tried:
Dim strConnection As New System.Data.OleDb.OleDbConnection("Provider = Microsoft.Jet.OleDb.4.0;Data Source = C:\Inetpub\ Dim myCommand As String
Dim No_Letts As String
Dim ClueBX As String
No_Letts = No_Letters.SelectedItem.Value
ClueBX = Clue_box.Text
strConnection.Open()
If ClueTypeList.SelectedItem.Value = "Abbreviation" Then
myCommand = "SELECT [Abbreviations].[Abb1], [Abbreviations].[Abb2], [Abbreviations].[Abb3], [Abbreviations].[Abb4], [Abbreviations].[Abb5], [Abbreviations].[Abb6], [Abbreviations].[Abb7] FROM [Abbreviations] WHERE ([Abbreviations].[Word]= ' " & ClueBX & " ') AND ((' " & No_Letts & " ' = [Abbreviations].[NoLett1]) OR (' " & No_Letts & " ' = [Abbreviations].[NoLett2]) OR (' " & No_Letts & " ' = [Abbreviations].[NoLett3]) OR (' " & No_Letts & " ' = [Abbreviations].[NoLett4]) OR ( ' " & No_Letts & " ' = [Abbreviations].[NoLett5]) OR ( ' " & No_Letts & " ' = [Abbreviations].[NoLett6]) OR (' " & No_Letts & " ' = [Abbreviations].[NoLett7]));"
End If
repeated for each table
And also
SELECT Abb1, Abb2, Abb3, Abb4, Abb5, Abb6,Abb7 FROM Abbreviations WHERE (Word= ' " & ClueBX & " ') AND ((' " & No_Letts & " ' = NoLett1) OR (' " & No_Letts & " ' = NoLett2) OR (' " & No_Letts & " ' = NoLett3) OR (' " & No_Letts & " ' = NoLett4) OR ( ' " & No_Letts & " ' = NoLett5) OR ( ' " & No_Letts & " ' = NoLett6) OR (' " & No_Letts & " ' = NoLett7));"
for each table.
I think there was another one, but I can't remember what it was now. It didn't work anyway!
Can anybody see where I am going wrong?
No_Letters and Clue_box are Protected Withevents in the #Region part of the code behind (I'm using Visual Studio.net, language VB)
Thanks in advance for your help
Jane
I'll probably look really silly for asking this question, but it's been baffling me for a week now (stupid I know).
I am tring to pull data from an Access database, depending on the options selected on a form. I have tried various formats for my statement but only the most basic works (i.e. SELECT Abb1, Abb2, Abb3, Abb4, Abb5, Abb6, Abb7 FROM Abbreviations).
Let me start from the beginning. I'm trying to create a crossword solver using ASP.net, the user enters data into the form, which returns the possible solutions to a clue into a dataGrid. There are 2 RadioButtonLists on the form, one which relates to the name of the table in the database, and the other which refers to the number of letters for each solution in the table. There is also a textarea for the user to enter a clue.
What I would like to do is depending on the Clue Type (Anagram, Abbreviation, etc) (1st RadioButtonList) I want to select data in the table according to the number of letters (selected from the 2nd RadioButtonList), and the clue entered.
My coding so far goes as follows:
Dim strConnection As String = "Provider = Microsoft.Jet.OleDb.4.0;Data Source = C:\Inetpub\ Dim ojbConnection As New OleDb.OleDbConnection(strConnection)
Dim No_Letts As Integer = No_Letters.SelectedItem.Value
Dim ClueBX As String = Clue_box.Text
Dim strSQL As String = "SELECT Abb1, Abb2, Abb3, Abb4, Abb5, Abb6, Abb7 FROM Abbreviations WHERE ((' " & No_Letts & " ' = NoLett1) AND (Word = ' " & ClueBX & " '))"
Dim ojbCommand As New OleDb.OleDbCommand(strSQL, ojbConnection)
ojbConnection.Open()
AdvancedSolutions1.DataSource = ojbCommand.ExecuteReader()
AdvancedSolutions1.DataBind()
ojbConnection.Close()
I have previously tried:
Dim strConnection As New System.Data.OleDb.OleDbConnection("Provider = Microsoft.Jet.OleDb.4.0;Data Source = C:\Inetpub\ Dim myCommand As String
Dim No_Letts As String
Dim ClueBX As String
No_Letts = No_Letters.SelectedItem.Value
ClueBX = Clue_box.Text
strConnection.Open()
If ClueTypeList.SelectedItem.Value = "Abbreviation" Then
myCommand = "SELECT [Abbreviations].[Abb1], [Abbreviations].[Abb2], [Abbreviations].[Abb3], [Abbreviations].[Abb4], [Abbreviations].[Abb5], [Abbreviations].[Abb6], [Abbreviations].[Abb7] FROM [Abbreviations] WHERE ([Abbreviations].[Word]= ' " & ClueBX & " ') AND ((' " & No_Letts & " ' = [Abbreviations].[NoLett1]) OR (' " & No_Letts & " ' = [Abbreviations].[NoLett2]) OR (' " & No_Letts & " ' = [Abbreviations].[NoLett3]) OR (' " & No_Letts & " ' = [Abbreviations].[NoLett4]) OR ( ' " & No_Letts & " ' = [Abbreviations].[NoLett5]) OR ( ' " & No_Letts & " ' = [Abbreviations].[NoLett6]) OR (' " & No_Letts & " ' = [Abbreviations].[NoLett7]));"
End If
repeated for each table
And also
SELECT Abb1, Abb2, Abb3, Abb4, Abb5, Abb6,Abb7 FROM Abbreviations WHERE (Word= ' " & ClueBX & " ') AND ((' " & No_Letts & " ' = NoLett1) OR (' " & No_Letts & " ' = NoLett2) OR (' " & No_Letts & " ' = NoLett3) OR (' " & No_Letts & " ' = NoLett4) OR ( ' " & No_Letts & " ' = NoLett5) OR ( ' " & No_Letts & " ' = NoLett6) OR (' " & No_Letts & " ' = NoLett7));"
for each table.
I think there was another one, but I can't remember what it was now. It didn't work anyway!
Can anybody see where I am going wrong?
No_Letters and Clue_box are Protected Withevents in the #Region part of the code behind (I'm using Visual Studio.net, language VB)
Thanks in advance for your help
Jane