現有app.ini檔案如下:
[database]
dbname=test
serverip=.
user=sa
password=
問題1:serverip=. .代表默認的SQL Server2000?
目標:通過單擊一個按鈕,實作顯示資料表的內容
procedure TForm1.Button1Click(Sender: TObject);
var
myinifile:Tinifile;
filename,v_u,v_i,v_d,v_p:string;
begin
with ADOQuery1 do
begin
Filename:=ExtractFilePath(Paramstr(0))+'app.ini';
myinifile:=Tinifile.Create(Filename);
v_u:=myinifile.readstring('database','user','');
v_i:=myinifile.readstring('database','serverip','');
v_d:=myinifile.readstring('database','dbname','');
v_p:=myinifile.readstring('database','password','');
adoconnection1.Connected:=false;
adoconnection1.Close;
adoconnection1.ConnectionString:='Provider=SQLOLEDB.1;Persist Security Info=true;User ID='v_u)+';Initial Catalog='+v_i+';Data Source='+v_d+';password='+v_p;
adoconnection1.Connected:=true;
adoquery1.Close;
adoquery1.SQL.Clear;
adoquery1.SQL.Add('select* from test');
adoquery1.Open;
end;
end;
麻煩各位朋友幫我看看
uj5u.com熱心網友回復:
粗看了一下,好像是可以這么做的'select * from test'
ip的“.”,是指本機的sqlserver
uj5u.com熱心網友回復:
編譯 彈出警示對話框 :project xx3 are rasied exception class EOleException with message'無效的授權說明'。Process stopped. Use Step or Run to continueuj5u.com熱心網友回復:
本機的sqlserver的帳號密碼是不是sa+空密碼?或者改為一個非空的密碼試一試?uj5u.com熱心網友回復:
這個提示一般是沒有找到SQL服務器,確認下登陸資料庫的相關資訊有沒有搞錯
uj5u.com熱心網友回復:
SQL Server 除了啟動服務管理器管理,還需要其他方面的設定嚒?uj5u.com熱心網友回復:
adoconnection1.ConnectionString:='Provider=SQLOLEDB.1;Persist Security Info=true;User ID='+v_u+';Initial Catalog='+v_d+';Data Source='+v_i+';password='+v_p;uj5u.com熱心網友回復:
樓主的連接字串構成有問題,應修改為:adoconnection1.ConnectionString:='Provider=SQLOLEDB.1;Persist Security Info=true;User ID='+v_u+';Initial Catalog='+v_i+';Data Source='+v_d+';password='+v_p;
uj5u.com熱心網友回復:
給你一段代碼:ConnectionString:='Provider=SQLOLEDB.1;'+
'Password='+Password+';'+
'Persist Security Info=True;'+
'User ID='+UserName+';'+
'Initial Catalog='+DatabaseName+';'+
'Data Source='+ServerName;
DataModule1.ADOCon.Connected:=False;
DataModule1.ADOCon.ConnectionString:=ConnectionString;
DataModule1.ADOCon.Connected:=True;
uj5u.com熱心網友回復:
檢查一下你的連接字串。。。uj5u.com熱心網友回復:
我已經把這個問題搞定了!~謝謝各位支持!uj5u.com熱心網友回復:
怎么解決的?求方法或代碼!!uj5u.com熱心網友回復:
用戶名不要用系統的sa,重新用自己創建的用戶名就可以了,這個我也碰到過,用自己建立的用戶連接就搞定了轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/146298.html
標籤:數據庫相關
下一篇:Django開發微信公眾號
