Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Windows Form to update VFP table with datagrid

Status
Not open for further replies.

campagnolo1

Technical User
Dec 19, 2011
54
US
Greetings everyone,

I'm stuck on a project that has me turning in circles and I need some help.
I have created a small windows form project in VS2010 using C#. The form has a datagrid which is tied to a VFP table. The table has no primary key and I can't add one (the table was given to me and I was told I can't alter it). I have populated the grid with several columns and bound the columns to the table fields. I added one unbound column (newqty) in the grid which I want to use to enter the new value for the qty column.
So far it's pretty simple. I was about to add my INSERT, UPDATE, DELETE methods when I noticed that I couldn't automatically create those methods. After some research I found that because the VFP table has no primary key, I can't create an UPDATE method. So I tried to use an UPDATE query and came up with this:
Code:
UPDATE    kokfstut
SET              qty =kokfstutDataGridView.Columns[newqty.Cells[7]
But this doesn't work and is giving me a "Column 'newqty' is not found" error. Looking at it, it seems right but when I look at the columns, the newqty column has no DataPropertyName since it's not bound to anything. So I went and changed the code to:
Code:
UPDATE    kokfstut
SET              qty = kokfstutDataGridView.Columns[qty].Cells[6]
I thought I'd just use the existing qty column to edit the data, but the above code also gives me an error, saying "Function is not implemented".
So obviously I'm missing something here. Anybody got any suggestions? And no, I can not alter the table. [wink]

Thanks in advance,

Chris
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top