473,383 Members | 1,855 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

VB .Net: Error generating UpdateCommand with DBF

Hi All,

Iam so green to VB that it just isnt funny.

I have read books and searchrd for 2 days now. The problem Im having is accesing a DBF file as database.

I tried using the "Add New Datasource" but I got nowhere. It seams that MS is looking for a file rather then a dirrectory which is where dbf files are recognised.

I have tried to code the connection my self and I have succeded in connecting and creating a dataset which I can then examine and change.

My problem is that I can save the changes back to the database. Im getting error

"Dynamic SQL generation for the UpdateCommand is not supported against a SelectCommand that does not return any key column information."

I dont know what to do. Key column isnt something that any of the tutorials mantioned and I obviously did not create the dbf file itself.

Here is my code
Expand|Select|Wrap|Line Numbers
  1. Imports System.Data
  2. Imports Microsoft.Data.ODBC
  3.  
  4. Public Class Form1
  5.  
  6.  
  7.     Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
  8.  
  9.         Dim vvvv As String
  10.         Dim ds As New DataSet
  11.         Dim da As OleDb.OleDbDataAdapter
  12.         Dim sql As String
  13.         Dim cb As OleDb.OleDbCommandBuilder
  14.         Dim Conn As New System.Data.OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=e:\pricePPJ;Extended Properties=dBase IV;")
  15.  
  16.         conn.Open()
  17.  
  18.         sql = "SELECT * FROM RSD.cdx "
  19.         da = New OleDb.OleDbDataAdapter(sql, Conn)
  20.         cb = New OleDb.OleDbCommandBuilder(da)
  21.  
  22.         da.Fill(ds, "AddressBook")
  23.  
  24.         vvvv = ds.Tables("AddressBook").Rows(0).Item(58)
  25.         ds.Tables("AddressBook").Rows(0).Item(58) = "Change"
  26.  
  27.         Stop
  28.  
  29.         da.Update(ds, "AddressBook")
  30.         conn.Close()
  31.     End Sub
  32. End Class
That is all I got.

Im not particularly attached to this method, so if there is a better way I'll be glad to learn it. I like the dataset because it lets me navigate through the content but if I can do this directly then that will be ok as well.

Thank you for any help

Michal
Nov 28 '07 #1
4 2039
Shashi Sadasivan
1,435 Expert 1GB
A key column means that your table should have a primary key!
A primary key uniquiely identifies a row.

Hence, in the design view that cannot be created by visual studio, you willl have to write your own (manually)

edit:
Is the error/exception being created in the above code you mentioned?
Nov 28 '07 #2
Yes,

The above code generates the error

Michal
Nov 28 '07 #3
Shashi Sadasivan
1,435 Expert 1GB
Can you edit the database file?

If you can, then create a primary index (identify which one could be a primary index)
Nov 28 '07 #4
I dont know what the key is (I undestand the concempt).
The DBF file does have an index file cdx ???

Failing this what else can I do to change content of cells in a DBF. Surely with such an old technology this sort of thing cant be that difficult. Unless you are a novice like me.

I would seatle for just knowing how to change one cell value.

Michal
Nov 28 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: JVRudnick | last post by:
Hello all... newbie here to .NET, but have dev asp pages for years. I'm trying to setup my workstation to now show .aspx pages - with no luck. I have the 1.1 NET framework installed, IIS5 and a...
0
by: Riley Phelps | last post by:
When I use the XML Serializer in the following example, the first Serialize (with the class Pets) works, but the second (with the cplaa Pets2) fails. Which arrtubute nedds to be applied to make the...
1
by: eSapient | last post by:
I get the following error when I run the XML Schema Definition Tool on a XML schema: Error: Error generating classes for schema 'codeGeoFeatureType'. - Specified cast is not valid. The XSD...
3
by: Andrea Williams | last post by:
I've created my own error handling object. and I wrtie tot eh error handler if the error is caught. Howver, I have one error it doesn't llok like I can catch.... In my form, if someone enters...
3
by: Raed Sawalha | last post by:
Hello when I serialize an object an error generated using this function public string SerializeObject(object oClassObject,System.Type oClassType) { XmlSerializer oSerializer = new...
2
by: RichardG | last post by:
I have an object data class that Inherits from a java class and implements System.Runtime.Serialization.ISerializable as I only need to transfer across three properties, string, array of objects...
1
by: idletask | last post by:
Hello, I have an XML file that is on my file system. I want to read the file into memory and call a web service with it. When I do, the VB complains: "there was an error generating the XML...
0
Sakalicek
by: Sakalicek | last post by:
Hi all, I have following problem in my application. I have Web Service and project which uses methods from this Web Service. I created proxy WsProxy by wsdl.exe and put it into that project. But...
1
by: ipramod | last post by:
Hi, I have a codebase which contains project for all the DLL's and another project for all UI presentations. When I try to open an aspx page on Visual Studio editor, I get following error on...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.