為項目增加數據庫連接
用Visual Studio新建一個ASP.Net項目,激活服務器資源管理器的上述連接,用鼠標將該連接拖至新建的Web Form上,則OLE DB需要的連接字符參數全部自動寫入Web Form程序中,上述連接生成的語句如下:
this.oleDbConnection1.ConnectionString = @"Provider=DB2OLEDB;
Cache Authentication=False;
Integrated Security="""";
PassWord=freebsd9;
Persist Security Info=True;
User ID=userid;Initial Catalog=qcdb;
Data Source=qcdb;Mode=ReadWrite;
Extended PropertIEs="""";
APPC Remote LU Alias="""";
APPC Local LU Alias="""";
APPC Mode Name=QPCSUPP;
Network Transport Library=TCPIP;
Host CCSID=37;PC Code Page=1282;
Network Address=172.23.169.1;
Network Port=4444;Package Collection=qcdb;
Default Schema=userid;Alternate TP Name="""";
Process Binary as Character=False;
Units of Work=RUW"
用服務器資源管理器工具生成連接可避免錯寫各種參數,從而可快速地實現數據庫連接。