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.

Syntax for connecting a database

Discussion in 'C#' started by seobit, Feb 24, 2010.

  1. #1
    Syntax for connecting a database in sql server with an asp page?:)
    SEMrush
     
    seobit, Feb 24, 2010 IP
    SEMrush
  2. sauravmandhotra

    sauravmandhotra Peon

    Messages:
    22
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    go in web config
    <connection string><add name="connectionstringname" connectionstring="server=servername;database=databasename;uid=sa;pwd=password"
     
    sauravmandhotra, Jul 31, 2010 IP
  3. andrei10

    andrei10 Member

    Messages:
    40
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    43
    #3
    andrei10, Aug 2, 2010 IP
  4. pom4ik

    pom4ik Greenhorn

    Messages:
    31
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    16
    #4
    Dim strSQL As String = ""
    Dim strConn As New SqlConnection(ConfigurationManager.ConnectionStrings("CONNECTIONAME").ConnectionString)
    Dim dr As SqlDataReader = Nothing
    Dim cm As New SqlCommand
    strSQL = "SELECT * FROM USERS"
    strConn.Open()
    cm.CommandType = CommandType.Text
    cm.Connection = strConn
    cm.CommandText = strSQL
    dr= cm.ExecuteReader()
     
    pom4ik, Aug 4, 2010 IP
  5. razet93

    razet93 Greenhorn

    Messages:
    38
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    16
    #5
    I have used that code for connectivity this is also given error...
     
    razet93, Aug 11, 2010 IP
  6. nagarajang

    nagarajang Peon

    Messages:
    20
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    what error occurs..could you elaborate?
     
    nagarajang, Aug 12, 2010 IP
  7. dodolls

    dodolls Well-Known Member

    Messages:
    282
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    108
    #7
    Dim database_connection
    Dim rsconn
    Dim query_string

    Set database_connection = Server.CreateObject("ADODB.Connection")
    Set rsConn = Server.CreateObject("ADODB.Recordset")

    database_connection.Open "Driver={SQL Server};UID=***;password=**;server=*;database=*;"

    query_string = "Select * From table"
    rsconn.open query_string,database_connection


    Been using this connection string for my ASP and VB projects...
     
    dodolls, Aug 12, 2010 IP
  8. Lucas Rodrigues

    Lucas Rodrigues Peon

    Messages:
    20
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #8
    try to use a separate include for the connection so that you save some time
     
    Lucas Rodrigues, Aug 23, 2010 IP
  9. nagarajang

    nagarajang Peon

    Messages:
    20
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #9
    Does it occur for first time when done...
     
    nagarajang, Aug 25, 2010 IP