Board index » delphi » Autoinc field in MySql database using dbexpress delphi 6

Autoinc field in MySql database using dbexpress delphi 6

I am sure this has been answered before, but I could not find it.
What is the proper settings to allow an mysql autoinc field to update
properly using dbexpress and Delphi 6. I have tried every combination I
can think of and I get the message field required. Or with the setup
below I get key violation when I attempt to add a secound record.
Any information would be greatly apprecaited.

Here is my form settings if anyone is interested.
object Form1: TForm1
   Left = 102
   Top = 216
   Width = 696
   Height = 480
   Caption = 'Form1'
   Color = clBtnFace
   Font.Charset = DEFAULT_CHARSET
   Font.Color = clWindowText
   Font.Height = -11
   Font.Name = 'MS Sans Serif'
   Font.Style = []
   OldCreateOrder = False
   PixelsPerInch = 96
   TextHeight = 13
   object DBGrid1: TDBGrid
     Left = 0
     Top = 0
     Width = 688
     Height = 409
     Align = alClient
     DataSource = DataSource1
     TabOrder = 0
     TitleFont.Charset = DEFAULT_CHARSET
     TitleFont.Color = clWindowText
     TitleFont.Height = -11
     TitleFont.Name = 'MS Sans Serif'
     TitleFont.Style = []
   end
   object StatusBar1: TStatusBar
     Left = 0
     Top = 434
     Width = 688
     Height = 19
     Panels = <
       item
         Width = 300
       end
       item
         Width = 50
       end>
     SimplePanel = False
   end
   object ProgressBar1: TProgressBar
     Left = 296
     Top = 360
     Width = 150
     Height = 16
     Min = 0
     Max = 100
     TabOrder = 2
   end
   object DBNavigator1: TDBNavigator
     Left = 0
     Top = 409
     Width = 688
     Height = 25
     DataSource = DataSource1
     Align = alBottom
     TabOrder = 3
   end
   object SQLConnection1: TSQLConnection
     Connected = True
     ConnectionName = 'MSConnection'
     DriverName = 'MYSQL'
     GetDriverFunc = 'getSQLDriverMYSQL'
     LibraryName = 'dbexpmysql.dll'
     LoginPrompt = False
     Params.Strings = (
       'BlobSize=-1'
       'Database=mydatabase'
       'DriverName=MYSQL'
       'ErrorResourceFile='
       'HostName=myhostname.com'
       'LocaleCode=0000'
       'Password=thepassword'
       'User_Name=theusername')
     VendorLib = 'LIBMYSQL.dll'
     AfterConnect = Timer1Timer
     Left = 136
     Top = 136
   end
   object DataSource1: TDataSource
     DataSet = ClientDataSet1
     Left = 224
     Top = 160
   end
   object Timer1: TTimer
     OnTimer = Timer1Timer
     Left = 256
     Top = 120
   end
   object DataSetProvider1: TDataSetProvider
     DataSet = SQLQuery1
     Constraints = True
     ResolveToDataSet = True
     Options = [poIncFieldProps, poAutoRefresh, poPropogateChanges]
     UpdateMode = upWhereChanged
     Left = 120
     Top = 56
   end
   object ClientDataSet1: TClientDataSet
     Active = True
     Aggregates = <>
     Params = <>
     ProviderName = 'DataSetProvider1'
     AfterPost = ClientDataSet1AfterPost
     Left = 160
     Top = 56
   end
   object SQLQuery1: TSQLQuery
     NoMetadata = True
     SQLConnection = SQLConnection1
     Params = <>
     SQL.Strings = (
       'Select * from ContactUsers')
     Left = 64
     Top = 72
     object SQLQuery1id: TIntegerField
       AutoGenerateValue = arAutoInc
       FieldName = 'id'
       ProviderFlags = [pfInKey, pfHidden]
     end
     object SQLQuery1FirstName: TStringField
       FieldName = 'FirstName'
       Required = True
       FixedChar = True
       Size = 50
     end
   end
end

 

Re:Autoinc field in MySql database using dbexpress delphi 6


Darrel ,

welcome to one of the (if not *the*) most frustrating aspects of
trying to merge dbexpress, midas, and RAD into one coherent
subject.  To give you a hint about the depth of quicksand into
which you have just stepped, begin your journey here....

http://bdn.borland.com/article/0,1410,20847,00.html

-paladin

Other Threads