baz86
asked on
Prepare: CommandText property has not been initialized
Hi ,
i keep getting this message(InvalidOperationEx ception was unhandled.....Prepare: CommandText property has not been initialized) during debugging at ......da.Update(ds, "Shot") ....
can someone please explain what it means and how i can rectify it?
many thanks
i keep getting this message(InvalidOperationEx
can someone please explain what it means and how i can rectify it?
many thanks
Private Sub MenuItem6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItem6.Click
Dim da As New SqlCeDataAdapter(sql, conn)
Dim cb As New SqlCeCommandBuilder(da)
dsNewRow = ds.Tables("Shot").NewRow()
dsNewRow.Item("ShotID") = scorecount + 1
dsNewRow.Item("Club") = ComboBox2.Text
dsNewRow.Item("ActDist") = TextBox30.Text
dsNewRow.Item("EndLie") = ComboBox6.Text
dsNewRow.Item("PuttDist") = ComboBox9.Text
dsNewRow.Item("WindStrength") = WeatherCond.ComboBox3.Text
dsNewRow.Item("Assist") = WeatherCond.ComboBox5.Text
dsNewRow.Item("Crosswind") = WeatherCond.ComboBox7.Text
dsNewRow.Item("HoleNo") = Label5.Text
dsNewRow.Item("RoundID") = maxroundid()
dsNewRow.Item("BallFlight") = ComboBox1.Text
ds.Tables("Shot").Rows.Add(dsNewRow)
da.Update(ds, "Shot")
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
thanks for the reply
if you check my code snippet i have used commandbuilder..but i still get the same message
if you check my code snippet i have used commandbuilder..but i still get the same message
My Bad. What is the SQL query you are using at command object?
And also do you have to specify shotID?
And also do you have to specify shotID?
Is SHOTID Primary Key?It seems commandbuilder works only when there is unique key values. Please look into your ShotID values during run time and also look into Update statement using
cmdBuilder.GetUpdateComman d.CommandT ext to know what is the update command that is getting.
cmdBuilder.GetUpdateComman
ASKER
this is the sql statement i run at form load
ShotID is quiet misleading here (sorry about that), it isnt a primary key but just an increment of the shots taken.
ShotID is quiet misleading here (sorry about that), it isnt a primary key but just an increment of the shots taken.
conn.ConnectionString = ConnStr
conn.Open()
Dim sql As String = "SELECT * From tblShot"
da = New SqlCeDataAdapter(sql, conn)
Then CommandBuilder doesnt work for it. You have to manually give the update statement for the adapter with parameters like the code I have given on the top.
http://support.microsoft.com/kb/308055