在delphi中建立一"library IDSAC;",同時添加一個DataModule(DM1),在其上添加ADOConnection1、ADOQ,ADOConnection1主要是連接一Sql Server服務器,測驗中用本地SQL,Dll創建完成后,在SQL server 中執行相應的操作,出現“未能找到存盤程序”。詳見程式清單
1、delphi部分
function IDSC(a,b:integer):integer;stdcall;
begin
try
CoInitialize(nil);
DM1 :=DM1.create(application);
dm1.ADOConnection1.ConnectionString:='Provider=SQLOLEDB.1;Password=sa;Persist Security Info=True;User ID=sa;Initial Catalog=test;Data Source=.;Use Procedure for Prepare=1;Auto Translate=True;';
dm1.ADOConnection1.Connected:=TRUE;
dm1.ADOQ.SQL.Text:='insert into test(a,b) values('+inttostr(a)+','+inttostr(b)+')';//a、b列為integer型別
dm1.ADOQ.ExecSQL;
result := 1;
except
result :=0;
end;
freeandnil(DM1);
end;
exports
IDSC name 'ids';
2、Sql Server查詢分析器部分
exec sp_addextendedproc 'IDSAC','c:\test\IDSAC.dll'
EXEC IDSC 1,2
出現如下錯誤:
服務器: 訊息 2812,級別 16,狀態 62,行 1
未能找到存盤程序 'IDSC'。
uj5u.com熱心網友回復:
把dll作為資料庫的存盤程序,要求此dll有一定的介面、格式的吧不是任何dll都可以的吧
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/143612.html
標籤:數據庫相關
