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

Recommended Answers

All 4 Replies

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

Regards.

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" >
</asp:DataGrid>

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

Ok, good to know.
take care.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.