Hi I've been having problems trying to connect to my Sybase Database.
The following is my code:
And I get this exception :
I know it says to verify the server name and the port, but I'm sure my port and server are correct. Can the exception come from another reason?
The following is my code:
VB.NET:
Imports System.Data.OleDb
Public Class MyForm
Private connex As OleDbConnection
Private query As OleDbCommand
Private dataAdapt As OleDbDataAdapter
Private strConnex As String
Private Function ViewQueryResult(ByVal sql As String) As DataTable
Try
query = New OleDbCommand(sql, connex)
dataAdapt = New OleDbDataAdapter(query)
dataAdapt.Fill(dataTable)
Catch ex As Exception
MessageBox.Show(ex.ToString)
End Try
Return dataTable
End Function
Private Sub MyForm_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
strConnex = "Provider=Sybase.ASEOLEDBProvider.2;" &_
"Server Name=MyServer;" &_
"Server Port Address=5000;" &_
"Initial Catalog=MyDatabase;" &_
"User ID=username;" &_
"Password=pass;"
Try
connex = New OleDbConnection(strConnex)
connex.Open()
Catch ex As Exception
MessageBox.Show(ex.ToString)
End Try
End Sub
End Class
And I get this exception :
VB.NET:
System.Data.OleDb.OleDbException: Connection login time has expired.
Connection refused. Verify Host Name and Port Number.
à System.Data.OleDb.OleDbConnectionInternal..ctor(OleDbConnectionString constr, OleDbConnection connection)
à System.Data.OleDb.OleDbConnectionFactory.CreateConnection(DbConnectionOptions options, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningObject)
à System.Data.ProviderBase.DbConnectionFactory.CreateNonPooledConnection(DbConnection owningConnection, DbConnectionPoolGroup poolGroup)
à System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection)
à System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory)
à System.Data.OleDb.OleDbConnection.Open()
à ParametrageOTC.paramOTC.paramOTC_Load(Object sender, EventArgs e) dans C:\Appl\GRM\MyProject\MyProject\MyForm.vb:ligne 31
I know it says to verify the server name and the port, but I'm sure my port and server are correct. Can the exception come from another reason?