Connection Via DSN in VB.Net
-
in vb.net when we create connection string we want dsn name in the connection string i want connection via sqlserver please suggest me what connection string i write notify i don't want server name and database name in the connection string. please help me :^)
-
in vb.net when we create connection string we want dsn name in the connection string i want connection via sqlserver please suggest me what connection string i write notify i don't want server name and database name in the connection string. please help me :^)
Since a DSN is part of ODBC configuration you need to use the ODBC data provider which will reduce your performance connecting to SQL server. And OLEDB option is to use a UDL file look under Storing Connection Strings on this page http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnbda/html/daag.asp[^]. Anothe option would be to encrypt the server and database name in a string and add the other information in at runtime.
I can imagine the sinking feeling one would have after ordering my book, only to find a laughably ridiculous theory with demented logic once the book arrives - Mark McCutcheon
-
Since a DSN is part of ODBC configuration you need to use the ODBC data provider which will reduce your performance connecting to SQL server. And OLEDB option is to use a UDL file look under Storing Connection Strings on this page http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnbda/html/daag.asp[^]. Anothe option would be to encrypt the server and database name in a string and add the other information in at runtime.
I can imagine the sinking feeling one would have after ordering my book, only to find a laughably ridiculous theory with demented logic once the book arrives - Mark McCutcheon
If you create a DSN called abcd, string myConnectionString ="DSN=abcd;UID=root;PWD=root"; OdbcConnection MyConn; OdbcCommand MyCmd = new OdbcCommand(); MyConn = new OdbcConnection(myConnectionString); MyConn.Open(); MyCmd.Connection = MyConn; StringBuilder SQL = new StringBuilder(); SQL.Append("SELECT "); SQL.Append("*"); SQL.Append("FROM "); SQL.Append("Authors"); MyCmd.CommandText = SQL.ToString(); OdbcDataReader result = MyCmd.ExecuteReader(CommandBehavior.CloseConnection); int nResultCount = 0; while (result.Read()) { ++nResultCount; }
-
If you create a DSN called abcd, string myConnectionString ="DSN=abcd;UID=root;PWD=root"; OdbcConnection MyConn; OdbcCommand MyCmd = new OdbcCommand(); MyConn = new OdbcConnection(myConnectionString); MyConn.Open(); MyCmd.Connection = MyConn; StringBuilder SQL = new StringBuilder(); SQL.Append("SELECT "); SQL.Append("*"); SQL.Append("FROM "); SQL.Append("Authors"); MyCmd.CommandText = SQL.ToString(); OdbcDataReader result = MyCmd.ExecuteReader(CommandBehavior.CloseConnection); int nResultCount = 0; while (result.Read()) { ++nResultCount; }
thanks. :confused:
I can imagine the sinking feeling one would have after ordering my book, only to find a laughably ridiculous theory with demented logic once the book arrives - Mark McCutcheon
-
thanks. :confused:
I can imagine the sinking feeling one would have after ordering my book, only to find a laughably ridiculous theory with demented logic once the book arrives - Mark McCutcheon