troubleshooting Question

An unhandled exception occurred during the execution of the current web request in ASP.NET

Avatar of redcoder
redcoder asked on
ASP.NET
3 Comments1 Solution558 ViewsLast Modified:
I am using WebMatrix to learn some ASP.NET. I have the following code :

        Function ShowSingleRecord(ByVal mySQL As string) As System.Data.IDataReader
        Dim connectionString As String = "Provider=Microsoft.Jet.OLEDB.4.0; Ole DB Services=-4; Data Source=H:\E_Commerce P"& _
"rac\31Jan_RevOfDB\TutECommerce\jewels.mdb"
        Dim dbConnection As System.Data.IDbConnection = New System.Data.OleDb.OleDbConnection(connectionString)


        Dim queryString As String = mySQL
        Dim dbCommand As System.Data.IDbCommand = New System.Data.OleDb.OleDbCommand
        dbCommand.CommandText = queryString
        dbCommand.Connection = dbConnection

        dbConnection.Open
        Dim dataReader As System.Data.IDataReader = dbCommand.ExecuteReader(System.Data.CommandBehavior.CloseConnection)

        Return dataReader
    End Function

Sub Button2_Click(sender As Object, e As EventArgs)
dim mycust as integer
mycust=(CInt(TextBox1.Text))

Dim thisSQL = "SELECT [Customer].* FROM [Customer] WHERE ([Customer].[CustID] = mycust)"
DataGrid1.DataSource=ShowSingleRecord(thisSQL)
DataGrid1.DataBind()
End Sub

-------------------------------------------------------------------------------------
and HTML code :

<html>
<head>
</head>
<body>
    <form runat="server">
        <p>
            Enter Your customer ID here:
            <asp:TextBox id="TextBox1" runat="server"></asp:TextBox>
        </p>
        <p>
            <asp:DataGrid id="DataGrid1" runat="server"></asp:DataGrid>
        </p>
        <p>
            <asp:Button id="Button2" onclick="Button2_Click" runat="server" Text="Show Record"></asp:Button>
        </p>
        <!-- Insert content here -->
    </form>
</body>
</html>

-------------------------------------------------------------------------------------
But receive error :

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Data.OleDb.OleDbException: No value given for one or more required parameters.


'and some long description of the error..' What could be the problem ?
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 3 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 3 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros