1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

How to connect asp.net 3.5 to database connectivity with sql

Discussion in 'C#' started by amkeabhi123, Jan 3, 2012.

  1. #1
    My problem is how to connect asp 3.5 with Mysql , i tried many time but not connect please help.
     
    amkeabhi123, Jan 3, 2012 IP
  2. slawek

    slawek Peon

    Messages:
    48
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    slawek, Jan 8, 2012 IP
  3. Modecor

    Modecor Peon

    Messages:
    21
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    hi,
    For sql server conectivity you have to take folloeing steps:
    first step: you have to make "System.Data.OleDb" namespace. We need this namespace to work with Microsoft Access and other OLE DB database providers.
    Second Step:We will create the connection to the database in the Page_Load subroutine. We create a dbconn variable as a new OleDbConnection class with a connection string which identifies the OLE DB provider and the location of the database. Then we open the database connection. ie,code for it
    %@ Import Namespace="System.Data.OleDb" %>

    <script runat="server">
    sub Page_Load
    dim dbconn,sql,dbcomm
    dbconn=New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;
    data source=" & server.mappath("northwind.mdb"))
    dbconn.Open()
    sql="SELECT * FROM customers"
    dbcomm=New OleDbCommand(sql,dbconn)
    end sub
    </script>
    I think this helps you. Goodluck
     
    Modecor, Jan 12, 2012 IP
  4. optionsbinary

    optionsbinary Peon

    Messages:
    31
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Its very simple
    Just go to server explorer , right click in your database and click on connect else
    just drag your table from your server explorer(Control + S) and put into your design part of your webform
    Automatically check in web.config file
    there will be the connection string like this code
    <connectionString name="" Datasource="">

    then in .cs page just write this code
    public SqlConnection con =new SqlConnection(System.Configuration.ConfigurationManager.ConnectionString["str name"].toString());
    con.Open();
    SqlDataAdapter ad=new SqlDataAdapter("Select * from Emp",con);
    Dataset ds=new Dataset();
    ad.fill(ds);
    con.Close();

    This is the code for connect database ..
     
    optionsbinary, Jan 14, 2012 IP