The Selectcommand Property Has Not Been Initialized Before Calling 'fill'
The SelectCommand property has not been initialized before calling 'Fill' I am getting this error when running StoredProcedure.ExecuteDataSet(); DataSet ds= new DataSet();
Solution 1:
I was able to fix this by adding the following code:
[162] DbDataAdapter da = Factory.CreateDataAdapter();[163] da.SelectCommand = cmd; <-- add this
[164] da.Fill(ds);
Hope this helps if anyone else had this problem...
Solution 2:
i was having this problem and that line made it work....
ProtectedSub searchButton_Click(ByVal sender AsObject, ByVal e As System.EventArgs) Handles searchButton.Click
TryDim dt AsNew Data.DataTable
Dim con AsNew SqlConnection(ConfigurationManager.ConnectionStrings("connection1").ToString())
Dim cmd AsNew SqlCommand("getAllPerson", con)
cmd.CommandType = Data.CommandType.StoredProcedure
cmd.Parameters.Add("@id", Data.SqlDbType.Int).Value = CInt(SearchBox.Text)
Dim da AsNew SqlDataAdapter
da.SelectCommand = cmd
da.Fill(dt)
fnameTextBox.Text = dt.Rows(0).Item("FName")
lnameTextBox.Text = dt.Rows(0).Item("LName")
dobTextBox.Text = dt.Rows(0).Item("DOB")
addressTextBox.Text = dt.Rows(0).Item("Address")
address1TextBox.Text = dt.Rows(0).Item("Address1")
contactTextbox.Text = dt.Rows(0).Item("ContactNo")
Catch ex As Exception
MsgBox(ex.Message.ToString())
EndTryEndSub
Post a Comment for "The Selectcommand Property Has Not Been Initialized Before Calling 'fill'"