Re: Connecting to a MySQL database through VB .NET



Cor,
I believe your note is suggesting two things: using fill instead of
setting dgModels.DataSource, and the response.Write to get error
reports. The latter is helpful, even though I'm still in the dark. The
first thing I learned from the error reports was the connection string
wants something like Provider=SQLOLEDB instead of Driver ={MySQL}. So
making that change I have the code:

Try

Dim connectionString As String =
"Provider=SQLOLEDB;Server=localhost;Database=Jags; Uid=ed;Pwd=sioux;"

Dim conn As New OleDb.OleDbConnection(connectionString)

Dim daAllModels As New OleDb.OleDbDataAdapter("Select * from
ModelTable", conn)

daAllModels.Fill(dsAllModels, "ModelTable")

Catch ex As Exception

Response.Write(ex.ToString)

End Try

This gives the following error reports:

System.Data.OleDb.OleDbException: [DBNETLIB][ConnectionOpen
(Connect()).]SQL Server does not exist or access denied. at
System.Data.OleDb.OleDbConnectionInternal..ctor(OleDbConnectionString
constr, OleDbConnection connection) at
System.Data.OleDb.OleDbConnectionFactory.CreateConnection(DbConnectionOptions
options, Object poolGroupProviderInfo, DbConnectionPool pool,
DbConnection owningObject) at
System.Data.ProviderBase.DbConnectionFactory.CreateNonPooledConnection(DbConnection
owningConnection, DbConnectionPoolGroup poolGroup) at
System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection
owningConnection) at
System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection
outerConnection, DbConnectionFactory connectionFactory) at
System.Data.OleDb.OleDbConnection.Open() at
System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset,
DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String
srcTable, IDbCommand command, CommandBehavior behavior) at
System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32
startRecord, Int32 maxRecords, String srcTable, IDbCommand command,
CommandBehavior behavior) at
System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, String
srcTable) at JagModelsWeb.WebForm1.Page_Load(Object sender, EventArgs
e) in c:\inetpub\wwwroot\JagModelsWeb\SelectModelsForm.aspx.vb:line 62

So it looks like it now connects but says the SQL Server doesn't exist
or is being denied. It must be the latter since Task mamager shows
both mysqld.exe and sqlserver.exe running, and mysql runs in a Windows
console. On the other hand, I am not at all confident that
Provider=SQLOLEDB is correct.

Ed


"Cor Ligthert[MVP]" <Notmyfirstname@xxxxxxxxx> wrote in message
news:%23uQBBA%23vJHA.3848@xxxxxxxxxxxxxxxxxxxxxxx
Ed,

See inline
'I assume that here was a try
Dim connectionString As String =
"Driver={MySQL};SERVER=localhost;DATABASE=Jags;USER=ed;PASSWORD=sioux"

Dim conn As New OleDb.OleDbConnection(connectionString)

'conn.Open()

Dim daAllModels As New OleDb.OleDbDataAdapter("Select * from
ModelTable", conn)
try
daAllModels.Fill(dsAllModels,"ModelTable")
catch
Catch ex as exception
response.Write(ex.ToString)
end Catch


dgModels.DataSource = dsAllModels.Tables("ModelTable")

dgModels.DataBind()

' Catch ex As Exception

' Trace.Write("Exception was thrown")

' End Try

Cor


.



Relevant Pages

  • Re: Snapshot to pdf code
    ... I am producing them in .snp format. ... reports and the rtf output does not retain the original format. ... Dim strDocName As String ...
    (microsoft.public.access.reports)
  • RE: Multi List Box help
    ... of the list box and build a string you can use as the Where argument of the ... Dim varItem As Variant ... Dim strWhere As String ... MsgBox "Select Employee for Individual Reports.", vbOKOnly, ...
    (microsoft.public.access.gettingstarted)
  • RE: Cycle through reports and export to XML
    ... Dim aob As AccessObject ... Dim sRpt As String, sXML As String, sXSL As String ... For Each aob In CurrentProject.AllReports ... > databases objects (Reports in particular) and have these reports exported as ...
    (microsoft.public.access.modulesdaovba)
  • RE: Multi List Box help
    ... of the list box and build a string you can use as the Where argument of the ... Dim varItem As Variant ... Dim strWhere As String ... MsgBox "Select Employee for Individual Reports.", vbOKOnly, ...
    (microsoft.public.access.gettingstarted)
  • RE: Multi List Box help
    ... of the list box and build a string you can use as the Where argument of the ... Dim varItem As Variant ... Dim strWhere As String ... MsgBox "Select Employee for Individual Reports.", vbOKOnly, ...
    (microsoft.public.access.gettingstarted)

Loading