help!!

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • isabella o nell
    New Member
    • Jan 2008
    • 6

    help!!

    Hi..

    Im trying to connect a visual studios application to sql server 05 express edition.

    the name of my database is personal_organi ser. I have searched the web for many hours but am just getting more confused. Can some one tell me the correct code and where to put it in my application, is it to go under a public class?? please help! a head wrecked student! :(
  • OuTCasT
    Contributor
    • Jan 2008
    • 374

    #2
    Originally posted by isabella o nell
    Hi..

    Im trying to connect a visual studios application to sql server 05 express edition.

    the name of my database is personal_organi ser. I have searched the web for many hours but am just getting more confused. Can some one tell me the correct code and where to put it in my application, is it to go under a public class?? please help! a head wrecked student! :(

    dim sqlCon as sqlConnection
    sqlCon = new sqlConnection(" sqlconnectionst ring ")
    sqlCon.open
    --commands---
    sqlcon.close

    this code goes in a button click even or if u wanted a sqlcommand to be executed on page load then it would go on your page load event

    Comment

    • OuTCasT
      Contributor
      • Jan 2008
      • 374

      #3
      Originally posted by isabella o nell
      Hi..

      Im trying to connect a visual studios application to sql server 05 express edition.

      the name of my database is personal_organi ser. I have searched the web for many hours but am just getting more confused. Can some one tell me the correct code and where to put it in my application, is it to go under a public class?? please help! a head wrecked student! :(


      Code:
      dim sqlCon as sqlConnection
      sqlCon = new sqlConnection(" sqlconnectionstring ")
      sqlCon.open
      --commands---
      sqlcon.close
      this code goes in a button click even or if u wanted a sqlcommand to be executed on page load then it would go on your page load event

      Comment

      • OuTCasT
        Contributor
        • Jan 2008
        • 374

        #4
        Originally posted by isabella o nell
        Hi..

        Im trying to connect a visual studios application to sql server 05 express edition.

        the name of my database is personal_organi ser. I have searched the web for many hours but am just getting more confused. Can some one tell me the correct code and where to put it in my application, is it to go under a public class?? please help! a head wrecked student! :(


        rememer your import namespaces

        [CODE sql]
        import system
        import system.data.sql Client
        [/CODE]

        Comment

        • isabella o nell
          New Member
          • Jan 2008
          • 6

          #5
          Thanks.. but still very confused.
          this is what i have and its very wrong i know can you please help?

          import system
          import system.data.sql Client



          Public Class frmSelection
          Dim sqlCon As SqlConnection
          sqlCon = new sqlConnection(" sqlconnectionst ring ")
          sqlCon.open
          --commands---
          sqlcon.close
          Data Source=.\SQLEXP RESS;cny200;Ini tialCatalog=per sonal_organiser ;Integrated Security=True

          Comment

          • OuTCasT
            Contributor
            • Jan 2008
            • 374

            #6
            Originally posted by isabella o nell
            Thanks.. but still very confused.
            this is what i have and its very wrong i know can you please help?

            import system
            import system.data.sql Client



            Public Class frmSelection
            Dim sqlCon As SqlConnection
            sqlCon = new sqlConnection(" sqlconnectionst ring ")
            sqlCon.open
            --commands---
            sqlcon.close
            Data Source=.\SQLEXP RESS;cny200;Ini tialCatalog=per sonal_organiser ;Integrated Security=True
            u dont have to put it in a public class, you put this code wherever u want to use the connection to the database.
            say you wanted to register a student, u have a form with like 2 textboxes on it for FirstName and Surname, and a Register button. you would put this code in the button click event so that when u click the button it wld add the info u put in the textboxes to your database.

            Your connectionstrin g is in the wrong place.....
            Data Source=.\SQLEXP RESS;cny200;Ini tialCatalog=per sonal_organiser ;Integrated Security=True
            here is the code u should use

            Code:
            Dim sqlCon as sqlConnection
            sqlCon = New sqlConnection("Data Source=.\SQLEXPRESS;cny200;InitialCatalog=personal_organiser;Integrated Security=True")
            dim sqlCom as new sqlCommand("ur command"),sqlCon) 'u have to refer to the connection
            sqlCon.open
            sqlCommand.executenonquery()
            sqlCon.close

            Comment

            Working...