Re: Connecting to a MySQL database through VB .NET
- From: "Ed" <jag_manR__EM*-0_V_E653@xxxxxxxxxxxxx>
- Date: Sat, 18 Apr 2009 13:44:15 -0700
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 =try
"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)
daAllModels.Fill(dsAllModels,"ModelTable")
catch
Catch ex as exception
response.Write(ex.ToString)
end Catch
' Catch ex As Exception
dgModels.DataSource = dsAllModels.Tables("ModelTable")
dgModels.DataBind()
' Trace.Write("Exception was thrown")
' End Try
Cor
.
- References:
- Connecting to a MySQL database through VB .NET
- From: Ed
- Re: Connecting to a MySQL database through VB .NET
- From: Cor Ligthert[MVP]
- Connecting to a MySQL database through VB .NET
- Prev by Date: Re: Preloading Business Objects over a Web Service
- Next by Date: Re: how to add node to treeview
- Previous by thread: Re: Connecting to a MySQL database through VB .NET
- Next by thread: A Forum for this group
- Index(es):
Relevant Pages
|
Loading