数据库链接问题
我想在数据库中存放某个图片的路径,然后将那个图片作为我窗体的背景图片,代码如下:
var
m,n,picpath:string;
begin
{ SetMainFormBackForm.Show;
MainForm.Enabled:=false;
}
openpicturedialog1.Execute;
m:=ExtractFileDir(OpenpictureDialog1.FileName);
n:=ExtractFileName(OpenpictureDialog1.FileName);
// showmessage(m+'\'+n);
if(m<>'')and(n<>'')then
begin
image1.Picture.LoadFromFile(m+'\'+n);
picpath:=m+'\'+n;
// showmessage(picpath);
adoquery1.Close;
adoquery1.SQL.Clear;
adoquery1.SQL.Add('update backpic set picpath="'+picpath+'" where picnum="1"');
adoquery1.ExecSQL;
showmessage('修改背景图片成功!');
end;
现在遇到的问题是:我在配置的adoconneciton的属性的时候,connectionstring的配置要是配置成绝对路径,也就是类似于:e:\Myprogram\database\data.mdb,选择images目录下面的某一图片的时候,程序就可以正常运行,而当我配置成相对路径,也就是直接写上database\data.mdb 的时候,程序就会运行出错了,提示找不到e:\Myprogram\images\database\data.mdb,很奇怪怎么会出来这么一个路径哪?????
按说,按照我的第二个方法链接数据库也没有什么问题的啊,以前写别的程序的时候就是按照相对路径来连接的,这次为什么不行了哪?