Sub btnSearch_OnClick(ByVal sender As Object, ByVal e As EventArgs)
Dim objCommand As OleDbCommand
Dim objAdapter As OleDbDataAdapter
Dim objDataSet As DataTable
Dim rs As New ADODB.Recordset
Dim rs1 As New ADODB.Recordset
Dim strHSA As String
Dim objConnection As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Documents and Settings\nimmy.k\Desktop\achievemath_1\WebSite1\App_Data\project2.mdb"
Dim cn As New OleDbConnection(objConnection)
Dim strSQLQuery As String
Dim strSQLQuery2 As String
cn.Open()
rs.Open("Select * From Primary", cn)
rs1.Open("Select * From Primary", cn)
strSQLQuery = "select distinct [image] from [Primary]"
While Not rs.EOF
strHSA = ""
strSQLQuery2 = "Select [AKA/HS1] from [Primary] where [image]=strimage"
xception Details: System.Runtime.InteropServices.COMException:
Arguments are of the wrong type, are out of acceptable range, or are in conflict with one another.
Source Error:
Line 63:
Line 64: cn.Open()
Line 65: rs.Open("Select * From Primary", cn)
Line 66: rs1.Open("Select * From Primary", cn)
Line 67:
Nimmy.K
Member
13 Points
50 Posts
Re: Need Help one to many relationship between columns
Apr 02, 2010 02:44 PM|LINK
Sub btnSearch_OnClick(ByVal sender As Object, ByVal e As EventArgs)
Dim objCommand As OleDbCommand
Dim objAdapter As OleDbDataAdapter
Dim objDataSet As DataTable
Dim rs As New ADODB.Recordset
Dim rs1 As New ADODB.Recordset
Dim strHSA As String
Dim objConnection As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Documents and Settings\nimmy.k\Desktop\achievemath_1\WebSite1\App_Data\project2.mdb"
Dim cn As New OleDbConnection(objConnection)
Dim strSQLQuery As String
Dim strSQLQuery2 As String
cn.Open()
rs.Open("Select * From Primary", cn)
rs1.Open("Select * From Primary", cn)
strSQLQuery = "select distinct [image] from [Primary]"
While Not rs.EOF
strHSA = ""
strSQLQuery2 = "Select [AKA/HS1] from [Primary] where [image]=strimage"
While Not rs1.EOF
strHSA = strHSA + Convert.ToString(rs1("[AKA/HS1]"))
Dim cmd As New OleDbCommand(strSQLQuery, cn)
cmd = New OleDbCommand(strSQLQuery2, cn)
objCommand = New OleDbCommand(strSQLQuery, cn)
objCommand = New OleDbCommand(strSQLQuery2, cn)
objAdapter = New OleDbDataAdapter(objCommand)
objDataSet = New DataTable()
objAdapter.Fill(objDataSet)
dgPaging.DataSource = objDataSet
dgPaging.DataBind()
End While
End While
cn.Close()
End Sub
</script>
<html>
<head>
<title>Search</title>
</head>
<body>
<form id="Form1" runat="server">
<asp:Button id="btnSearch" runat="server"
Text ="Search"
OnClick ="btnSearch_OnClick"
/>
<asp:GridView ID="dgPaging" runat="server" AutoGenerateColumns="false" HorizontalAlign="Justify" ShowHeader="False">
<EditRowStyle ForeColor="White" />
<AlternatingRowStyle ForeColor="White" HorizontalAlign="Justify"></AlternatingRowStyle>
<Columns>
<asp:TemplateField HeaderText="HS1">
<ItemTemplate>
<img src="pdf\<%#Eval("image")%>" />HS1-<%#Eval("AKA/HS1")%>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
</form>
</body>
</html>
I am getting a runtime exception :
xception Details: System.Runtime.InteropServices.COMException: Arguments are of the wrong type, are out of acceptable range, or are in conflict with one another.
Source Error:
Line 63: Line 64: cn.Open() Line 65: rs.Open("Select * From Primary", cn) Line 66: rs1.Open("Select * From Primary", cn) Line 67:Can you please suggest me
Thanks,
Nimmy
<div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;" id="_mcePaste">Sub btnSearch_OnClick(ByVal sender As Object, ByVal e As EventArgs)</div> <div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;" id="_mcePaste"> </div> <div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;" id="_mcePaste"> Dim objCommand As OleDbCommand</div> <div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;" id="_mcePaste"> Dim objAdapter As OleDbDataAdapter</div> <div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;" id="_mcePaste"> Dim objDataSet As DataTable</div> <div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;" id="_mcePaste"> Dim strSearch As String</div> <div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;" id="_mcePaste"> Dim strSearch2 As String</div> <div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;" id="_mcePaste"> Dim strSearch3 As String</div> <div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;" id="_mcePaste"> Dim strSearch4 As String</div> <div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;" id="_mcePaste"> Dim strSearch5 As String</div> <div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;" id="_mcePaste"> Dim strSearch6 As String</div> <div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;" id="_mcePaste"> Dim rs As New ADODB.Recordset</div> <div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;" id="_mcePaste"> Dim rs1 As New ADODB.Recordset</div> <div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;" id="_mcePaste"> Dim strimage As String</div> <div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;" id="_mcePaste"> Dim strHSA As String</div> <div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;" id="_mcePaste"> Dim objConnection As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Documents and Settings\nimmy.k\Desktop\achievemath_1\WebSite1\App_Data\project2.mdb"</div> <div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;" id="_mcePaste"> Dim cn As New OleDbConnection(objConnection)</div> <div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;" id="_mcePaste"> Dim strSQLQuery As String</div> <div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;" id="_mcePaste"> Dim strSQLQuery2 As String</div> <div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;" id="_mcePaste"> strSearch = txtSearch.Text</div> <div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;" id="_mcePaste"> strSearch2 = txtSearch2.Text</div> <div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;" id="_mcePaste"> strSearch3 = txtSearch3.Text</div> <div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;" id="_mcePaste"> strSearch4 = txtSearch4.Text</div> <div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;" id="_mcePaste"> strSearch5 = txtSearch5.Text</div> <div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;" id="_mcePaste"> strSearch6 = txtSearch6.Text</div> <div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;" id="_mcePaste"> If (Len(Trim(strSearch)) & Len(Trim(strSearch2)) & Len(Trim(strSearch3)) & Len(Trim(strSearch4)) & Len(Trim(strSearch5)) & Len(Trim(strSearch6))) > 0 Then</div> <div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;" id="_mcePaste"> </div> <div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;" id="_mcePaste"> rs.Open("Primary", cn)</div> <div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;" id="_mcePaste"> rs1.Open("Primary", cn)</div> <div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;" id="_mcePaste"> cn.Open()</div> <div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;" id="_mcePaste"> </div> <div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;" id="_mcePaste"> strSQLQuery = "select distinct [image] from [Primary]"</div> <div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;" id="_mcePaste"> While Not rs.EOF</div> <div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;" id="_mcePaste"> strHSA = ""</div> <div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;" id="_mcePaste"> strSQLQuery2 = "Select [AKA/HS1] from [Primary] where [image]=strimage"</div> <div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;" id="_mcePaste"> While Not rs1.EOF</div> <div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;" id="_mcePaste"> strHSA = strHSA + rs1[[AKA/HS1]]</div> <div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;" id="_mcePaste"> </div> <div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;" id="_mcePaste"> </div> <div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;" id="_mcePaste"> End While</div> <div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;" id="_mcePaste"> End While</div> <div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;" id="_mcePaste"> </div> <div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;" id="_mcePaste"> </div> <div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;" id="_mcePaste"> </div> <div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;" id="_mcePaste"> Dim cmd As New OleDbCommand(strSQLQuery, cn)</div> <div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;" id="_mcePaste"> cmd = New OleDbCommand(strSQLQuery2, cn)</div> <div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;" id="_mcePaste"> objCommand = New OleDbCommand(strSQLQuery, cn)</div> <div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;" id="_mcePaste"> objCommand = New OleDbCommand(strSQLQuery2, cn)</div> <div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;" id="_mcePaste"> objAdapter = New OleDbDataAdapter(objCommand)</div> <div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;" id="_mcePaste"> objDataSet = New DataTable()</div> <div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;" id="_mcePaste"> objAdapter.Fill(objDataSet)</div> <div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;" id="_mcePaste"> </div> <div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;" id="_mcePaste"> dgPaging.DataSource = objDataSet</div> <div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;" id="_mcePaste"> dgPaging.DataBind()</div> <div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;" id="_mcePaste"></div> <div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;" id="_mcePaste"> cn.Close()</div> <div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;" id="_mcePaste"> Else</div> <div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;" id="_mcePaste"> txtSearch.Text = "Add the text here!!"</div> <div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;" id="_mcePaste"> End If</div> <div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;" id="_mcePaste"> End Su</div>