急救,如何配置下面的数据源,在odbc中 , BDE中配也可以(100分)

  • 主题发起人 主题发起人 ccweifen
  • 开始时间 开始时间
C

ccweifen

Unregistered / Unconfirmed
GUEST, unregistred user!
在程序中是这么写的
with Database1 do
begin
DatabaseName := 'Backup';
DriverName := 'MSACCESS';
Params.Clear;
Params.Add('DATABASE NAME='+FName); //fname为备份文件 *.mdb的路径
Params.Add('OPEN MODE=READ/WRITE');
Params.Add('LANGDRIVER=');
Params.Add('SYSTEM DATABASE=');
Params.Add('PASSWORD=');
Connected :=true;
end;
程序不能改。
我在ODBC配了好几次运行到connected:=true 时出现以下错误:
General SQL error.
-2147221164
Table
Alias:Backup
怎么解决??
 
可能是你的Backup别名没有在ODBC中创建吧
 
如果你在odbc里配好了
只要给个alias名就行了,然后databasename随便起一个吧做为你的表连接的数据库名称
 
那个alias名就是odbc配置好后在bde中出现的名称
 
程序中Database1的aliasname属性没有设置,空的
现在不能改程序了,怎么解决?
 
BDE的msaccess默认仅仅支持Access97版本的。你的Access文件是高版本的,所以产生这个问题。
DriverName := 'MSACCESS';可考虑使用“Microsoft Access Driver (*.mdb)”
或者,你可以使用Ado进行连接。

两天前在论坛上看见了有一个更改BDE配置连接使用BDE借助Ado连接Access的,忘记那个动态库是什么了。
 
第一可以用ADO解决
第二应该在ODBC中加入DSN数据源,然后在Tdatabase中设置属性就行了。
 
贴段代码可以这样设置:Delphi5+access2000、win98下通过
object Form1: TForm1
Left = 235
Top = 26
Width = 566
Height = 505
ActiveControl = DBEdit1
BorderIcons = [biSystemMenu, biMinimize]
Caption = 'Form1'
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'MS Sans Serif'
Font.Style = []
OldCreateOrder = False
WindowState = wsMaximized
PixelsPerInch = 96
TextHeight = 13
object StatusBar1: TStatusBar
Left = 0
Top = 553
Width = 540
Height = 19
Panels = <>
SimplePanel = False
end
object GroupBox1: TGroupBox
Left = 16
Top = 216
Width = 217
Height = 337
Caption = '数据录入'
Font.Charset = GB2312_CHARSET
Font.Color = clWindowText
Font.Height = -12
Font.Name = '宋体'
Font.Style = []
ParentFont = False
TabOrder = 1
object Label1: TLabel
Left = 9
Top = 34
Width = 48
Height = 12
Caption = '财产名称'
Font.Charset = GB2312_CHARSET
Font.Color = clWindowText
Font.Height = -12
Font.Name = '宋体'
Font.Style = []
ParentFont = False
Transparent = True
end
object Label2: TLabel
Left = 9
Top = 66
Width = 48
Height = 12
Caption = '规格型号'
Font.Charset = GB2312_CHARSET
Font.Color = clWindowText
Font.Height = -12
Font.Name = '宋体'
Font.Style = []
ParentFont = False
Transparent = True
end
object Label3: TLabel
Left = 9
Top = 98
Width = 48
Height = 12
Caption = '使用数量'
Font.Charset = GB2312_CHARSET
Font.Color = clWindowText
Font.Height = -12
Font.Name = '宋体'
Font.Style = []
ParentFont = False
Transparent = True
end
object Label4: TLabel
Left = 9
Top = 130
Width = 48
Height = 12
Caption = '管理部门'
Font.Charset = GB2312_CHARSET
Font.Color = clWindowText
Font.Height = -12
Font.Name = '宋体'
Font.Style = []
ParentFont = False
Transparent = True
end
object Label5: TLabel
Left = 9
Top = 162
Width = 48
Height = 12
Caption = '备注说明'
Font.Charset = GB2312_CHARSET
Font.Color = clWindowText
Font.Height = -12
Font.Name = '宋体'
Font.Style = []
ParentFont = False
Transparent = True
end
object DBEdit1: TDBEdit
Left = 80
Top = 25
Width = 121
Height = 20
DataField = '财产名称'
DataSource = DataSource1
ImeMode = imChinese
ImeName = '中文 (简体) - 微软拼音'
TabOrder = 0
end
object DBEdit2: TDBEdit
Left = 80
Top = 60
Width = 121
Height = 20
DataField = '规格型号'
DataSource = DataSource1
TabOrder = 1
end
object DBEdit3: TDBEdit
Left = 80
Top = 92
Width = 121
Height = 20
DataField = '使用数量'
DataSource = DataSource1
TabOrder = 2
end
object DBEdit4: TDBEdit
Left = 80
Top = 124
Width = 121
Height = 20
DataField = '管理部门'
DataSource = DataSource1
ImeName = '中文 (简体) - 微软拼音'
TabOrder = 3
end
object DBEdit5: TDBEdit
Left = 80
Top = 156
Width = 121
Height = 20
DataField = '备注说明'
DataSource = DataSource1
ImeName = '中文 (简体) - 微软拼音'
TabOrder = 4
end
object BitBtn1: TBitBtn
Left = 16
Top = 201
Width = 49
Height = 24
Caption = 'BitBtn1'
TabOrder = 6
end
object BitBtn2: TBitBtn
Left = 80
Top = 201
Width = 49
Height = 24
Caption = 'BitBtn1'
TabOrder = 7
end
object BitBtn3: TBitBtn
Left = 144
Top = 201
Width = 49
Height = 24
Caption = 'BitBtn1'
TabOrder = 8
end
object DBNavigator1: TDBNavigator
Left = 8
Top = 257
Width = 200
Height = 18
DataSource = DataSource1
Flat = True
TabOrder = 5
TabStop = True
end
end
object DBGrid1: TDBGrid
Left = 0
Top = 0
Width = 540
Height = 209
Align = alTop
DataSource = DataSource1
TabOrder = 2
TitleFont.Charset = DEFAULT_CHARSET
TitleFont.Color = clWindowText
TitleFont.Height = -11
TitleFont.Name = 'MS Sans Serif'
TitleFont.Style = []
Columns = <
item
Alignment = taCenter
Expanded = False
FieldName = '财产名称'
Font.Charset = GB2312_CHARSET
Font.Color = clWindowText
Font.Height = -12
Font.Name = '宋体'
Font.Style = []
Title.Alignment = taCenter
Title.Font.Charset = GB2312_CHARSET
Title.Font.Color = clWindowText
Title.Font.Height = -12
Title.Font.Name = '宋体'
Title.Font.Style = []
Width = 99
Visible = True
end
item
Expanded = False
FieldName = '规格型号'
Font.Charset = GB2312_CHARSET
Font.Color = clWindowText
Font.Height = -12
Font.Name = '宋体'
Font.Style = []
Title.Alignment = taCenter
Title.Font.Charset = GB2312_CHARSET
Title.Font.Color = clWindowText
Title.Font.Height = -12
Title.Font.Name = '宋体'
Title.Font.Style = []
Width = 292
Visible = True
end
item
Alignment = taCenter
Expanded = False
FieldName = '使用数量'
Font.Charset = GB2312_CHARSET
Font.Color = clWindowText
Font.Height = -12
Font.Name = '宋体'
Font.Style = []
Title.Alignment = taCenter
Title.Font.Charset = GB2312_CHARSET
Title.Font.Color = clWindowText
Title.Font.Height = -12
Title.Font.Name = '宋体'
Title.Font.Style = []
Width = 83
Visible = True
end
item
Alignment = taCenter
Expanded = False
FieldName = '管理部门'
Font.Charset = GB2312_CHARSET
Font.Color = clWindowText
Font.Height = -12
Font.Name = '宋体'
Font.Style = []
Title.Alignment = taCenter
Title.Font.Charset = GB2312_CHARSET
Title.Font.Color = clWindowText
Title.Font.Height = -12
Title.Font.Name = '宋体'
Title.Font.Style = []
Width = 135
Visible = True
end
item
Expanded = False
FieldName = '备注说明'
Font.Charset = GB2312_CHARSET
Font.Color = clWindowText
Font.Height = -12
Font.Name = '宋体'
Font.Style = []
Title.Alignment = taCenter
Title.Font.Charset = GB2312_CHARSET
Title.Font.Color = clWindowText
Title.Font.Height = -12
Title.Font.Name = '宋体'
Title.Font.Style = []
Width = 169
Visible = True
end>
end
object DataSource1: TDataSource
DataSet = ADOTable1
Left = 416
Top = 230
end
object ADOConnection1: TADOConnection
Connected = True
ConnectionString =
'Provider=MSDASQL.1;Persist Security Info=False;Data Source=CCHGL' +
';Connect Timeout=15;Extended Properties="DSN=CCHGL;DBQ=c:/CCHGL/' +
'Data/HEZI;DriverId=25;FIL=MS Access;MaxBufferSize=2048;PageTimeo' +
'ut=5;";Locale Identifier=2052;Initial Catalog=c:/CCHGL/Data/HEZI'
LoginPrompt = False
Left = 368
Top = 232
end
object ADOTable1: TADOTable
Active = True
Connection = ADOConnection1
CursorType = ctStatic
TableName = '清产核资'
Left = 320
Top = 232
end
end
 
多人接受答案了。
 
后退
顶部