Hi, I'm comming from Delphi world, and learning from 0 the VB 2005 Express. Is it possible to connect this product with DBMSs like PostgreSQL or MySQL, using ODBC or JDBC
Dim oMySqlConn As MySqlConnection = New MySqlConnection() oMySqlConn.ConnectionString = "Data Source=localhost;" & _ "Database=mySQLDatabase;" & _ "User ID=myUsername;" & _ "Password=myPassword;" & _ "Command Logging=false" oMySqlConn.Open()
For all other ODBC Drivers
' VB.NET Dim oODBCConnection As Odbc.OdbcConnection Dim sConnString As String = "Dsn=myDsn;" & _ "Uid=myUsername;" & _ "Pwd=myPassword" oODBCConnection = New Odbc.OdbcConnection(sConnString) oODBCConnection.Open() For more information, see: ODBC .Net Data Provider
Newbie question: DB Connectivity
Dan H.
Hi,
Connecting to MySql DB.
Using C#
using EID.MySqlClient;
MySqlConnection oMySqlConn = new MySqlConnection();
oMySqlConn.ConnectionString = "Data Source=localhost;" +
"Database=mySQLDatabase;" +
"User ID=myUsername;" +
"Password=myPassword;" +
"Command Logging=false";
oMySqlConn.Open();
Using VB.NET
Imports EID.MySqlClient
Dim oMySqlConn As MySqlConnection = New MySqlConnection()
oMySqlConn.ConnectionString = "Data Source=localhost;" & _
"Database=mySQLDatabase;" & _
"User ID=myUsername;" & _
"Password=myPassword;" & _
"Command Logging=false"
oMySqlConn.Open()
For all other ODBC Drivers
' VB.NET
Dim oODBCConnection As Odbc.OdbcConnection
Dim sConnString As String = "Dsn=myDsn;" & _
"Uid=myUsername;" & _
"Pwd=myPassword"
oODBCConnection = New Odbc.OdbcConnection(sConnString)
oODBCConnection.Open()
For more information, see: ODBC .Net Data Provider
Hope it helps
Soham
Do a search in MSDN Help on ADO.NET... if you're interested mainly in ODBC, a sample Visual Basic Express program might look like:
Imports System.Data.Odbc
..
Public Sub ConnectToTheDatabase( ... )
Dim szConnectStr as String
Dim ODBCDataset As New OdbcConnection
... access OdbcConnection members as needed here
End Sub
The direct link to help on the OdbcConnection class can be found at:
http://msdn2.microsoft.com/en-us/library/system.data.odbc.odbcconnection.aspx