Ureader.com  
Microsoft software help and Community
   home   |   control panel login   |   archive   |  
 
DotNet
acad.assignment.mngr
academic
adonet
aspnet
aspnet.announcements
aspnet.build.controls
aspnet.caching
aspnet.datagridcontrol
aspnet.mobile
aspnet.security
aspnet.webcontrols
aspnet.webservices
clr
compactframework
component_services
datatools
distributed_apps
drawing
faqs
framework
framework.wmi
general
internationalization
interop
languages.csharp
languages.jscript
languages.vb
languages.vb.controls
languages.vb.data
languages.vb.upgrade
languages.vc
languages.vc.libraries
myservices
odbcnet
performance
remoting
scripting
sdk
security
setup
vjsharp
vsa
webservi.enhancements
webservices
windowsforms
windowsforms.controls
winforms.databinding
winforms.designtime
xml
  
 
date: Thu, 04 May 2006 07:19:01 -0700,    group: microsoft.public.dotnet.datatools        back       


Building updatecommand .Net 1.1 + VFPOLEDB + dBase   
I have an originally clipper-based dbase datatable with a unique "row
serial number"-like first column. I want to make the rest of the table
updatable via a datagrid. My problem is that I can't generate the
necessary Updatecommand of the dataadapter, because the
OleDbCommandBuilder requires a table with primary key information, but
my dbase table have no schema information the VFPOLEDB driver could use
(as far as I know). Is it possible to talk the "machine" into believing,
that the first column is a primary key (and use the OleDbCommandBuilder
to build the command for updating), or my only option is to build the
Updatecommand programmaticaly (which would be quite painfull, because I
may obtain information about the rest of the table just dinamically,
during running the program).

I would appreciate any good idea!

*** Sent via Developersdex http://www.developersdex.com ***
date: Thu, 04 May 2006 07:19:01 -0700   author:   John Littlewood

Re: Building updatecommand .Net 1.1 + VFPOLEDB + dBase   
I've searched the internet more, but I couldn't modify the schema on the
fly, so I've made a small piece of coding in vb to build the necessary
Updatecommand, based on the Insertcommand generating by the
OleDbCommandBuilder. It works, but if anybody has some better or more
direct idea, please, don't keep it in himsel ;-)

If anybody is interested in it, my code is the following (there are some
declarations before, you may find them out):

cnDBase = New OleDbConnection(strConn)
daLoads.SelectCommand = New OleDbCommand(strSelect, cnDBase)
daLoads.TableMappings.Add(New
System.Data.Common.DataTableMapping("Table", strTable))
Dim cb As New OleDbCommandBuilder(daLoads)
Dim strUpdate As String = cb.GetInsertCommand.CommandText
Dim ixComma As Integer = InStr(strUpdate, ", ")
Dim ixKeyField As Integer = InStr(strUpdate, "(") + 1
strUpdate = Replace(Mid(strUpdate, ixComma + 2, InStrRev(strUpdate, ")
VAL") - InStr(strUpdate, ", ") - 3) & " , ", " , ", "=?,")
strUpdate = "UPDATE '" & strTable & "' SET " & strUpdate.TrimEnd(","c) &
" WHERE" & Mid(cb.GetInsertCommand.CommandText, ixKeyField, ixComma -
ixKeyField - 1) & "=?"
Dim cmdUpdateDBase As System.Data.OleDb.OleDbCommand = New
OleDbCommand(strUpdate, cnDBase)
For ixPar As Integer = 1 To cb.GetInsertCommand.Parameters.Count
    Dim objUpdate As OleDbParameter =
cb.GetInsertCommand.Parameters(ixPar Mod
cb.GetInsertCommand.Parameters.Count)
    cmdUpdateDBase.Parameters.Add(objUpdate.ParameterName.Insert(1,
"@"), objUpdate.OleDbType, objUpdate.Size, objUpdate.SourceColumn)
Next ixPar
daLoads.UpdateCommand = cmdUpdateDBase
cb.Dispose()
daLoads.Fill(dsLoads)

bla-bla...

*** Sent via Developersdex http://www.developersdex.com ***
date: Fri, 05 May 2006 13:17:58 -0700   author:   John Littlewood

Google
 
Web ureader.com


    COPYRIGHT 2007, YARDI TECHNOLOGY LIMITED, ALL RIGHT RESERVE  |   contact us