我通過DbLINQ使用LINQ to SQL(PostgreSQL)。使用DbLINQ時LINQ to PostgreSQL錯誤
我在LINQ到PostgreSQL時遇到問題。我用dbmetal成功生成了.dbml和.cs文件,我想我得到了所有的引用,代碼編譯。 參考文獻:
DbLinq
DbLinq.PostgreSql
DbLinq.SqlServer
Npgsql
using DbLinq.PostgreSql;
我得到一個異常:
{"A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)"}
內部異常:
{"The system cannot find the path specified"}
連接字符串:
server=127.0.0.1;database=xxxxx;user id=postgres;password=xxxxx;
ili
server=localhost;database=xxxxx;user id=postgres;password=xxxxx;
如果我嘗試使用NpgsqlConnectionStringBuilder我得到:
HOST=localhost;PORT=5432;PROTOCOL=3;DATABASE=xxxxx;USER ID=postgres;PASSWORD=xxxxx;SSL=False;SSLMODE=Disable;TIMEOUT=15;SEARCHPATH=;POOLING=True;CONNECTIONLIFETIME=15;MINPOOLSIZE=1;MAXPOOLSIZE=20;SYNCNOTIFICATION=False;COMMANDTIMEOUT=20;ENLIST=False;PRELOADREADER=False;USEEXTENDEDTYPES=False;INTEGRATED SECURITY=False;COMPATIBLE=2.0.12.0;APPLICATIONNAME=
與異常{"Keyword not supported: 'host'."}
我在SquirrelSQL和JDBC驅動程序成功地連接上的Win7 64位,Postgres的9.2 64位
編輯: 這是好的
xxxxxDC dc = new xxxxxDC("server=127.0.0.1;database=xxxxx;user id=postgres;password=xxxxx;DbLinqProvider=PostgreSql;");
var q = from r in dc.xxxxx
select r;
但我得到一個錯誤
dataGridView1.DataSource = q
現在我知道這是因爲查詢沒有立即執行。但問題依然存在。 「服務器未找到或無法訪問」
F1!
LP
我試過了,沒有運氣。 我不知道是什麼問題。我怎麼才能測試連接字符串? – user1941235
你是怎麼嘗試的?如果代碼生成器運行它必須已連接到有限程度 –
我試圖修改連接字符串到服務器= 127.0.0.1:5432;數據庫= xxxxx;用戶id = postgres;密碼= xxxxx 服務器=本地主機:5432;數據庫= xxxxx ; user id = postgres; password = xxxxx server = 127.0.0.1; port = 5432; database = xxxxx; user id = postgres; password = xxxxx 最後一個不起作用(不受支持的關鍵字「端口」) – user1941235