Results 1 to 3 of 3

Thread: Asp.net code for database connection

  1. #1
    HallMiller is offline Senior Member
    Join Date
    Dec 2009
    Posts
    251
    Rep Power
    3

    Default Asp.net code for database connection

    Hi. I am new in development world. I want to connect my database in asp.net with SQL server 2005 or ms access 2007? Please anybody solve my query. If you are having any codes then reply me. It can helpful to me. Thanks in advanced.

  2. #2
    AllenBrown is offline Senior Member
    Join Date
    Dec 2009
    Posts
    240
    Rep Power
    3

    Default

    Try out the following code which is helpful for you.

    Code:
    <%@ Import Namespace="System.Data.OleDb" %>
    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

  3. #3
    ScottWright is offline Senior Member
    Join Date
    Dec 2009
    Posts
    243
    Rep Power
    3

    Default

    The following example instantiates and SqlConnection, sets some of its parameters in the connection string, and opens the connection.

    Code:
    SqlConnection myConn = new SqlConnection ( );
    myConn.ConnectionString = "user id=sa; password=admin;" +
       "data source=myServer; initial catalog=northwind;"
    myConn.Open ( );

Similar Threads

  1. Database .NET
    By Izaiah Lopez in forum Download Tools and Softwares
    Replies: 0
    Last Post: 10-20-2010, 06:54 PM
  2. Database Normalization in SQL Database
    By Millerjames in forum Programming
    Replies: 1
    Last Post: 01-23-2010, 03:17 PM
  3. Database
    By adlina in forum Everything Else
    Replies: 0
    Last Post: 03-23-2009, 11:21 AM
  4. Database
    By MACONAQUEA77 in forum Everything Else
    Replies: 0
    Last Post: 03-21-2009, 09:51 AM
  5. DataBase
    By niks54 in forum Everything Else
    Replies: 0
    Last Post: 01-21-2009, 12:26 PM

Bookmarks

Posting Permissions

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48