The current row is not available.
I get this error message when I try to edit a datagrid that is bound to a sql server database. Any ideas?
How was your cursor opened? Forward only? Updateable?
And I only get the error on this field. I can update other fields as needed.
What is the data type for the field?
Its a varchar type in ms sql server.
Can you edit any other VARCHAR fields in this same row?
Yes, with no problem. The interesting thing is, though, that this grid is bound to the data source in code (rather than with an adodc) and is sitting on a mdichild form. When I edit other fields I run some validation on them and sometimes the msg box that indicates the user has entered incorrect data doesn't show up. I think it is behind the child form? I don't know but I hear the beep and if I hit enter the program continues to run.
Pretty bizarre I think.
Are there any data constraints, checks or Foreign key relationships on the target field? Can you update field directly or through a query?
Here is the query that I use to populate the grid with:
'get data source for display
sql = "SELECT * FROM PartData pd INNER JOIN RaceData rd ON pd.RaceID = rd.RaceID "
sql = sql & "WHERE rd.EventID = " & lEventID & " ORDER BY pd.LastName"
Set rs = New Recordset
rs.Open sql, conn, adOpenStatic, adLockOptimistic
Set dgPartData.DataSource = rs
Here is how I write to the recordset itself:
'insert into db
sql = "INSERT INTO PartData (RaceID, FirstName, LastName, Bib, Gender, Age, Address, "
sql = sql & "City, State, Zip, Phone, Email, ShrtSize, ShrtStyle, WhereReg, DateReg, "
sql = sql & "DOB, Team, Seed, SeedTime, AmtPaid, AgeGroup, Clydesdale, Wheelchair, RaceWalk) "
sql = sql & "VALUES (" & ThisRaceID(lstRace, lstRace.Text) & ", '" & txtFirstName & "', '"
sql = sql & txtlastName & "', '" & txtBib & "', '" & lstGender & "', " & RaceDayAge & ", '"
sql = sql & txtAddress & "', '" & txtCity & "', '" & txtState & "', "
sql = sql & lZip & ", '" & txtPhone & "', '" & txtEmail & "', '" & lstShrtSize & "', '"
sql = sql & lstShrtStyle & "', '" & lstWhereReg & "', '" & Date & "', '" & txtDOB & "', '"
sql = sql & txtTeam & "', '" & txtSeed & "', '" & txtSeedTime & "', '" & txtEntryFee & "', '"
sql = sql & AgeGrp(RaceDayAge, lstGender.Text, ThisRaceID(lstRace, lstRace.Text)) & "', '"
sql = sql & sClyde & "', '" & sWhlchr & "', '" & sRaceWalk & "')"
Set rs = conn.Execute(sql)
All of this seems to work fine (except the gird is quirkly as I said in my last reply) except when I try to edit this field directly on the grid-that is when I get an error.
Please don't hesitate to comment on my code if you think it could/should be written differently.