I still am not sure of whats happening here but I have tried it and am getting the following results i am probably doing something wrong but i just can't seem to grasp it;
System.InvalidOperationException: The SelectCommand property has not been initialized before calling 'Fill'.
at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)
at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, String srcTable)
at ClubMembership.renewals.test1() in D:\Programming\vb.net\ClubMembership\renewals.vb:line 159
the code i am using:
Dim sdate As Date
sdate = DateTime.Today.AddMonths(1).ToShortDateString 'Date.Today.AddMonths(1)
tx1.Text = sdate
Dim ssql As String
ssql = "select * from information where expirydate <'" & sdate & "'"
Dim oconn As New SqlClient.SqlConnection(sconnection)
Dim da As New SqlClient.SqlDataAdapter
Dim ds As New DataSet
Dim MyCommand As New SqlClient.SqlCommand("datefind", oconn)
MyCommand.Commandtype = CommandType.StoredProcedure
MyCommand.Parameters.Add(New SqlClient.SqlParameter("@exdate", "sdate"))
Try
oconn.Open()
MyCommand.ExecuteNonQuery()
da.Fill(ds, "information")
oconn.Close()
dg1.DataSource = ds
dg1.DataMember = "information"
Catch ex As Exception
tx2.Text = ex.ToString
End Try