Can anybody tell me where i can find the connection string for using on a asp.net form.

I am trying to connect a mysql database to it, and wanted to connect a access database to test the main functions.
But i am having a hard time finding any of these for VB 2010.
I am using Mysql 5 and Access 2010(if its something needed to know)

Dani AI

Generated

Practical, ready-to-use notes for connecting MySQL 5 and Access 2010 from an ASP.NET (VB 2010) web form. — nice that you checked connection-string resources; pointed you in the right direction. Below are concise samples, setup steps and common pitfalls so the connection works both in Visual Studio and when deployed to IIS.

A typical web.config connectionStrings section for each backend looks like this:

<connectionStrings>
  <add name="MySqlConn"
       providerName="MySql.Data.MySqlClient"
       connectionString="Server=localhost;Database=yourdb;Uid=youruser;Pwd=yourpass;Port=3306;" />
  <add name="AccessConn"
       providerName="System.Data.OleDb"
       connectionString="Provider=Microsoft.ACE.OLEDB.12.0;Data Source=|DataDirectory|\mydb.accdb;Persist Security Info=False;" />
</connectionStrings>

Quick VB usage examples (retrieve the string, open a connection):

' MySQL
Imports System.Configuration
Imports MySql.Data.MySqlClient

Dim cs = ConfigurationManager.ConnectionStrings("MySqlConn").ConnectionString
Using cn As New MySqlConnection(cs)
  cn.Open()
  ' execute commands...
End Using

' Access
Imports System.Configuration
Imports System.Data.OleDb

Dim csA = ConfigurationManager.ConnectionStrings("AccessConn").ConnectionString
Using cnA As New OleDbConnection(csA)
  cnA.Open()
  ' execute commands...
End Using

Important notes and troubleshooting:

  • Install MySQL Connector/NET (or add MySql.Data via NuGet) to use MySql.Data.MySqlClient. For Access, install the Access Database Engine so ACE.OLEDB.12.0 is available.
  • On 64-bit hosts either install 64-bit ACE or run the app pool/project as x86; mismatched bitness causes “provider not registered” errors.
  • For Access, place the .accdb in App_Data and give the IIS identity read/write rights; Access is OK for testing but not ideal for many concurrent web users.
  • For MySQL, ensure the user has permissions and port 3306 is reachable (or use localhost for local installs).
  • Never concatenate SQL strings — use parameterized commands. Protect credentials (consider encrypting the connectionStrings section on production servers).

Recommended Answers

All 2 Replies

Have a look here

very helpful site, thank you.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.