當前位置:首頁 » 操作系統 » c資料庫連接字元串

c資料庫連接字元串

發布時間: 2022-11-12 22:56:19

① C#中使用遠程的Oracle資料庫的連接字元串

新版本

Driver={Microsoft ODBC for Oracle};Server=myServerAddress;Uid=myUsername;Pwd=myPassword;

舊版本

Driver={Microsoft ODBC Driver for Oracle};ConnectString=OracleServer.world;Uid=myUsername;Pwd=myPassword;

OLE DB, OleDbConnection (.NET)

標准連接

此連接字元串適用了微軟的驅動。

Provider=msra;Data Source=MyOracleDB;User Id=myUsername;Password=myPassword;

受信連接

Provider=msra;Data Source=MyOracleDB;Persist Security Info=False;Integrated Security=Yes;

標准連接

由Oracle提供的驅動。

Provider=OraOLEDB.Oracle;Data Source=MyOracleDB;User Id=myUsername;Password=myPassword;

受信連接

Provider=OraOLEDB.Oracle;Data Source=MyOracleDB;OSAuthent=1;

Oracle.DataAccess.Client.OracleConnection

Data Source=TORCL;User Id=myUsername;Password=myPassword;

標准安全連接

Data Source=TORCL;Integrated Security=SSPI;

使用ODP.NET而不使用tnsnames.ora

Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=MyHost)(PORT=MyPort)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=MyOracleSID)));User Id=myUsername;Password=myPassword;

OracleConnection, Oracle Data Provider, ODP.NET, System.Data.OracleClient.OracleConnection

標准

Data Source=MyOracleDB;Integrated Security=yes;

用於8i RC3及以後的版本

指定用戶名和密碼

Data Source=MyOracleDB;User Id=myUsername;Password=myPassword;Integrated Security=no;

用於8i RC3及以後的版本

忽略tnsnames.ora

另一種不需要使用DSN的連接方式。

SERVER=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=MyHost)(PORT=MyPort))(CONNECT_DATA=(SERVICE_NAME=MyOracleSID)));uid=myUsername;pwd=myPassword;

使用上面的連接字元串可能會導致Visual Studio報告錯誤,如果您在使用中出現了這些問題,請使用下面的這種連接方式。

Data Source=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=MyHost)(PORT=MyPort))(CONNECT_DATA=(SERVICE_NAME=MyOracleSID)));User Id=myUsername;Password=myPassword;

使用連接池

如果連接池服務程序找不到已經存在的連接池,它將根據連接字元串創建一個新的池,否則將循環使用池中已存在的連接。

Data Source=myOracleDB;User Id=myUsername;Password=myPassword;Min Pool Size=10;Connection Lifetime=120;Connection Timeout=60;Incr Pool Size=5;Decr Pool Size=2;

Windows身份驗證

Data Source=myOracleDB;User Id=/;

特權連接

使用SYSDBA

Data Source=myOracleDB;User Id=SYS;Password=SYS;DBA Privilege=SYSDBA;

特權連接

使用SYSOPER

Data Source=myOracleDB;User Id=SYS;Password=SYS;DBA Privilege=SYSOPER;

復制

密碼過期處理過程

當使用一個連接字元串連接資料庫後,出現「密碼已過期」的錯誤時,請執行OpenWithNewPassword命令來提供新密碼。

Data Source=myOracleDB;User Id=myUsername;Password=myPassword;

oConn.OpenWithNewPassword(sTheNewPassword);

Proxy驗證

Data Source=myOracleDB;User Id=myUsername;Password=myPassword;Proxy User Id=pUserId;Proxy Password=pPassword;

Core Labs OraDirect (.NET)

User ID=myUsername;Password=myPassword;Host=ora;Pooling=true;Min Pool Size=0;Max Pool Size=100;Connection Lifetime=0;

MS Data Shape

Provider=MSDataShape.1;Persist Security Info=False;Data Provider=MSDAORA;Data Source=orac;User Id=myUsername;Password=myPassword;

② 用CDatabase中OpenEx直接連接Oracle資料庫,連接字元串該怎麼寫

資料庫編程的思路都是一致的:打開資料庫連接-》執行sql語句-》獲得查詢結果-》關閉資料庫連接,不同的資料庫訪問技術有不同的要求,比如用C API詰問MySql資料庫的時候還得釋放查詢結果集。 ODBC訪問資料庫得配置數據源 配置ODBC數據源:打開控制面板下的「數據源」,彈出「ODBC數據源管理器」,選擇DSN選項卡-》添加->你選擇你的SQL Server選項,單擊完成。如圖然後你再按照向導提示添加。 代碼中用ODBC訪問資料庫你得加上afxdb.h頭文件, 用CDataBase 類連接資料庫、CRecordSet類查詢記錄。 現在在VC訪問資料庫常用的是ADO訪問,你可以找一下我前面的回答有ADO訪問資料庫的步驟。 CDataBase m_cODBCDb; 用CDataBase類的OpenEx()函數打開資料庫連接。連接字元串你自己構造一下。 定義一個與上面資料庫相關的查詢對象 CRecordSet m_cODBCRec(&m_cODBCDb); 用這個查詢對象的open方法就可以執行SQL語句與資料庫交互了; 現在用VC、MFC訪問資料庫常用的技術是ADO,學學這個吧。難點、但很實用! 導入ADO庫 #import "c:\Program Files\Common Files\System\ADO\msado15.dll" no_namespace rename("EOF", "adoEOF")

c語言中怎麼樣將兩個字元串連接起來

1)簡單來,直接用
strcat
函數,需要包含頭文件
string.h2)自己實現的話也不麻煩,但是要考慮一些細節:假設兩個字元串指針為
str1,str2
,現在要講
str1

str2
連接成一個新的字元串。a.考慮指針
str1,str2
是否非空b.如果將str2的內容直接連接到str1的末尾,要考慮str1是否有足夠的剩餘空間來放置連接上的str2的內容。如果用一個新的內存空間來保存str1和str2的連接結果,需要動態分配內存空間。

④ c語言連接字元串

#include<stdio.h>
void main()
{
char a[80],b[40];
int i=0,j=0;
printf("input string1:");
scanf("%s",a); //輸入字元串a
printf("input string2:");
scanf("%s",b); //輸入字元串b
while(a[i]!='\0') //這個while作用是下標i從0開始遍歷數組a直到找到數組a的結束符.
i++;
while(b[j]!='\0') //這個while是將數組b賦值到數組a從結束符開始往後的一塊區域中.
a[i++]=b[j++];
a[i]='\0'; //重新增加一個字元串結束符.
printf("the new string is :%s\n",a);
}

⑤ C語言字元串怎麼連接起來

strcat(a,"~");
strcat(a,b);

⑥ SQL2005資料庫,假如我的資料庫文件是c:\1.mdf,連接字元串應該怎麼寫

1.在webconfig里配置
2.直接引用
sqlconnection
conn
=
new
sqlconnection(data
source=.\sqlexpress;integrated
security=sspi;attachdbfilename=|datadirectory|database.mdf;user
instance=true);
datadirectory默認是appdata文件夾,你把mdf文件放到裡面,改一下文件名(database.mdf)和連接字元串的一樣就行了

⑦ c語言編程將兩個字元串連接起來

//voidfun(charp1[],charp2[])的最後一行
p2[j]='';
//改為:
p1[n]='';
#include<stdio.h>
voidfun(charp1[],charp2[])
{
inti=0,j=0,n=0;
while(p1[i]!=0)
{
i++;
n++;
}
while(p2[j]!=0)
{
p1[n]=p2[j];
n++;
j++;
}
p1[n]='';
}
main()
{chars1[80],s2[40];voidNONO();
printf("Enters1ands2: ");
scanf("%s%s",s1,s2);
printf("s1=%s ",s1);
printf("s2=%s ",s2);
printf("Invokefun(s1,s2): ");
fun(s1,s2);
printf("Afterinvoking: ");
printf("%s ",s1);
//NONO();
}

⑧ 用C語言怎麼將兩個字元串連接起來

這些是宏的功能。
#是將一個參數轉換為字元串。##可以連接字元串
比如這樣:
#include
<stdio.h>
#define
STR(a,b)
a##b
int
main()
{
printf("%s\n",STR("123","456"));
return
0;
}

⑨ C語言編程,實現字元串的連接

voidmy_strcat(char*destination,constchar*source)
{for(;*destination!='';destination++);
for(;(*destination++=*source++)!='';);
}

熱點內容
編輯html源碼 發布:2025-05-16 17:45:45 瀏覽:64
邊的存儲方法 發布:2025-05-16 17:33:16 瀏覽:927
海量伺服器怎麼拆 發布:2025-05-16 17:31:07 瀏覽:211
運行與編譯的區別 發布:2025-05-16 17:25:02 瀏覽:824
c語言for中continue 發布:2025-05-16 17:20:14 瀏覽:648
ftp儲存 發布:2025-05-16 17:04:08 瀏覽:504
家悅3010怎麼看電腦配置 發布:2025-05-16 17:02:38 瀏覽:886
sqlin傳參 發布:2025-05-16 17:02:37 瀏覽:890
python計算md5 發布:2025-05-16 17:02:32 瀏覽:428
看演算法頭疼 發布:2025-05-16 16:56:41 瀏覽:799