我做了个数据库应用程序,用户要保留旧的数据,但是新版本的应用程序的数据库结构发生了变化,我的解决办法是:1。在安装时先备份旧数据库;2。启动应用程序后按照新库结构自动检测并修改修改备份数据库结构;3。删除新库,将备份数据库更名为新库名。我用的是firebird数据库。我的问题只在第二步。这也是最关键的一步,请大侠们帮帮忙,我也没多少分了。最好是有源码.
解决方案 »
- image控件
- 请问谁有CTI(来电显示)技术开发包文件?
- 一次最多只能散100?Treeview+Grid(or Table/list)
- ⊙⊙ 推荐一下你认为最好的Delphi优秀免费资源,欢迎跟贴!!!⊙⊙
- *******从效率来说SqlServer2000连接用什么方式最好?*******
- delphi和excel 怎么连啊?
- delphi中调用excel表的问题,请指教
- Delphi中的嵌入式汇编语言问题
- 三角函数正弦和余弦函数
- 如何让dbgrid固定不会移动的几列
- cxgridview不绑定数据源,添加数据问题.
- [Fatal Error] Required package 'tee' not found,怎么解决?
能不能给出SQL语句给我看一下!
思想﹕用新結構匹配舊數據
1>先備份一個新結構的數據庫﹐并清空里面的數據
2>遍歷表的結構﹐將舊表按字段名稱對應一一導入新表中
3>執行下面語句可得到執行的語句(將select出來的結構拷貝出來執下即可)
select [name] as TabNm into #A
from sysobjects where [Type]='U'
order by namecreate table #B (sqlstr varchar(2000))
go
delete #Bdeclare @sql varchar(2000), @tabnm varchar(50), @str varchar(2000)
declare #mycur cursor for select tabnm from #A order by tabnm
open #mycur
fetch next from #mycur into @tabnm
while @@fetch_status = 0
begin
set @str=''
select @str=@str+','+b.name from sysobjects a, syscolumns b where a.id=b.id and a.[name]=@tabnm
if left(@str,1)=',' set @str = right(@str,len(@str)-1) set @sql = ''
set @sql = 'insert into '+@tabnm+'('+@str+') select '+@str+' from OtherDatabaseName.dbo.'+@tabnm
insert into #B select @sql
fetch next from #mycur into @tabnm
end
close #mycur
deallocate #mycurselect * from #Bdrop table #B
drop table #A
谢谢你的指点,只是我现在就是不知道如何用DBEXPRESS组件对FIREBIRD数据库结构进行修改!