Ok i have this code to retreive data from a Table "Calendar" and the feild within the table are Id,Day ,Month and Year.
When i press the button to run this code and i get the error message "The parameterized query '(@Day varchar(8000),@Month varchar(8000),@Year varchar(8000))Sel' expects the parameter '@Day', which was not supplied. "

Dim con As New System.Data.SqlClient.SqlConnection
        con.ConnectionString = ******

        Dim cmd As System.Data.SqlClient.SqlCommand

        Dim myDA As System.Data.SqlClient.SqlDataAdapter

        Dim myDataSet As System.Data.DataSet

        'Binding database table to DataGridView

        cmd = New System.Data.SqlClient.SqlCommand("Select * FROM Calendar", con)

        If con.State = System.Data.ConnectionState.Closed Then con.Open()

        myDA = New System.Data.SqlClient.SqlDataAdapter(cmd)

        myDataSet = New System.Data.DataSet()
        myDA.Fill(myDataSet, "Calendar")

        DataGrid.DataSource = myDataSet.Tables("Calendar").DefaultView
7 Years
Discussion Span
Last Post by jbisono

at the end put DataGrid.DataBind()

also is your datagrid allow to generate the columns automatically, if not i would like to see the datagrid structure and the exact field you are retrieving from the calendar table



Ok Databind is displaying the records now which is great no i have 2 sets of columns so 2 day 2 month and 2 year, I have autogenerate column to true and thats it i havent declare any columns either
<asp:DataGrid ID="DataGrid" runat="server" AutoGenerateColumn="true" SelectedIndex="1" >


Fixed i set autogenerate to false and create columns myself Thank You

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.