CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Mar 2011
    Posts
    1

    Database connection in .cs file

    Hi

    I am a beginner in .net.
    I am now trying to do a sample project - Windows application.
    I am trying to connect to a database MySQL.I am having two files - Login.aspx and Connection.cs
    I want the database connection code in .cs file and need to call this .cs file in .aspx page.

    I have added the reference of mysql.

    The class file contains :

    The declared string,connectionstring
    I have also declared mySqlConnection and i used the connectionstring as a parameter in sqlConnection.


    string connString = "Data Source=(local);Initial Catalog=abcd;Uid=abcd;Password=nhjk";
    MySqlConnection connect = new MySqlConnection(connString);

    and then when i proceed further like connect.open() or connect.CreateCommand() , the intellisense is not poping up and is throwing error.

    Can anyone pleasehelp me in ths regd.




    Thanks

  2. #2
    Join Date
    Sep 2008
    Location
    Netherlands
    Posts
    865

    Re: Database connection in .cs file

    What is the error you get?

    Did you reference the MySql.Data.dll into to your project's references?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured