Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. connectivity with database

connectivity with database

Scheduled Pinned Locked Moved C#
csharpdatabasevisual-studio
11 Posts 7 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S shubham salwan

    hi, i am using visual studio 2008 and making project in c#. i had created web application form but i am not able to connect it with database. em using sqlserver2005 as database

    shubhi

    A Offline
    A Offline
    Abhinav S
    wrote on last edited by
    #2

    If you are having a problem with connections, this[^] would be your best bet.

    Build your own survey - http://www.factile.net

    1 Reply Last reply
    0
    • S shubham salwan

      hi, i am using visual studio 2008 and making project in c#. i had created web application form but i am not able to connect it with database. em using sqlserver2005 as database

      shubhi

      D Offline
      D Offline
      Dave Kreskowiak
      wrote on last edited by
      #3

      What do you mean by "not able to connect it with database"?? What does you code look like that does the connection and query work?? What are the error messages you're getting?? Just saying "it doesn't work" doesn't help you.

      A guide to posting questions on CodeProject[^]
      Dave Kreskowiak

      S 1 Reply Last reply
      0
      • D Dave Kreskowiak

        What do you mean by "not able to connect it with database"?? What does you code look like that does the connection and query work?? What are the error messages you're getting?? Just saying "it doesn't work" doesn't help you.

        A guide to posting questions on CodeProject[^]
        Dave Kreskowiak

        S Offline
        S Offline
        shubham salwan
        wrote on last edited by
        #4

        i am not able o make connection con

        L 1 Reply Last reply
        0
        • S shubham salwan

          i am not able o make connection con

          L Offline
          L Offline
          Lost User
          wrote on last edited by
          #5

          shubham salwan wrote:

          i am not able o make connection con

          You do realize that we cannot see your code, or have your project available, or read your mind. If you expect to get help for your problems, you have to show the code that you are having trouble with and share the errors you are getting. We cannot possibly help you resolve issues if you do not give us the information that is needed to help you! Do you call your mechanic and tell him that your car is "broke" and expect that they should know eactly what you mean the problem is?

          Why is common sense not common? Never argue with an idiot. They will drag you down to their level where they are an expert. Sometimes it takes a lot of work to be lazy Please stand in front of my pistol, smile and wait for the flash - JSOP 2012

          S 1 Reply Last reply
          0
          • L Lost User

            shubham salwan wrote:

            i am not able o make connection con

            You do realize that we cannot see your code, or have your project available, or read your mind. If you expect to get help for your problems, you have to show the code that you are having trouble with and share the errors you are getting. We cannot possibly help you resolve issues if you do not give us the information that is needed to help you! Do you call your mechanic and tell him that your car is "broke" and expect that they should know eactly what you mean the problem is?

            Why is common sense not common? Never argue with an idiot. They will drag you down to their level where they are an expert. Sometimes it takes a lot of work to be lazy Please stand in front of my pistol, smile and wait for the flash - JSOP 2012

            S Offline
            S Offline
            shubham salwan
            wrote on last edited by
            #6

            private void button1_Click(object sender, EventArgs e)
            {
            string connString = "Data Source=shubhi-PC;Initial Catalog=employee;uid=sa;pass=abc;Integrated Security=True"; SqlConnection conn = new SqlConnection(connString);
            conn.Open();
            String sql = "INSERT INTO emp_detail(empid,empname,empadd,empsal) values ('" + textBox1.Text + "','" + textBox2.Text + "','" + textBox3.Text + "','" + textBox4.Text + "')";

                    cmd.ExecuteNonQuery();
            
                    conn.Close();
                    textBox1.Text="";
            

            i want to save data to sqlserver2005 ... bt itz not working

            L P 2 Replies Last reply
            0
            • S shubham salwan

              private void button1_Click(object sender, EventArgs e)
              {
              string connString = "Data Source=shubhi-PC;Initial Catalog=employee;uid=sa;pass=abc;Integrated Security=True"; SqlConnection conn = new SqlConnection(connString);
              conn.Open();
              String sql = "INSERT INTO emp_detail(empid,empname,empadd,empsal) values ('" + textBox1.Text + "','" + textBox2.Text + "','" + textBox3.Text + "','" + textBox4.Text + "')";

                      cmd.ExecuteNonQuery();
              
                      conn.Close();
                      textBox1.Text="";
              

              i want to save data to sqlserver2005 ... bt itz not working

              L Offline
              L Offline
              Lost User
              wrote on last edited by
              #7

              shubham salwan wrote:

              bt itz not working

              Of course it's not working. Your connection string has a user name a password and you are telling it to use integrated security. Not to mention that you did not bother even defining a command object. You do realize that this won't even compile don't you?

              Why is common sense not common? Never argue with an idiot. They will drag you down to their level where they are an expert. Sometimes it takes a lot of work to be lazy Please stand in front of my pistol, smile and wait for the flash - JSOP 2012

              P 1 Reply Last reply
              0
              • L Lost User

                shubham salwan wrote:

                bt itz not working

                Of course it's not working. Your connection string has a user name a password and you are telling it to use integrated security. Not to mention that you did not bother even defining a command object. You do realize that this won't even compile don't you?

                Why is common sense not common? Never argue with an idiot. They will drag you down to their level where they are an expert. Sometimes it takes a lot of work to be lazy Please stand in front of my pistol, smile and wait for the flash - JSOP 2012

                P Offline
                P Offline
                Paul Conrad
                wrote on last edited by
                #8

                Shhhhhhhh.... Don't tell him his code is subject to SQL Injection attacks either :rolleyes:

                "Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon

                L 1 Reply Last reply
                0
                • P Paul Conrad

                  Shhhhhhhh.... Don't tell him his code is subject to SQL Injection attacks either :rolleyes:

                  "Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon

                  L Offline
                  L Offline
                  Lost User
                  wrote on last edited by
                  #9

                  I figure he has enough trouble without throwing gasoline on the bonfire.

                  Why is common sense not common? Never argue with an idiot. They will drag you down to their level where they are an expert. Sometimes it takes a lot of work to be lazy Please stand in front of my pistol, smile and wait for the flash - JSOP 2012

                  1 Reply Last reply
                  0
                  • S shubham salwan

                    private void button1_Click(object sender, EventArgs e)
                    {
                    string connString = "Data Source=shubhi-PC;Initial Catalog=employee;uid=sa;pass=abc;Integrated Security=True"; SqlConnection conn = new SqlConnection(connString);
                    conn.Open();
                    String sql = "INSERT INTO emp_detail(empid,empname,empadd,empsal) values ('" + textBox1.Text + "','" + textBox2.Text + "','" + textBox3.Text + "','" + textBox4.Text + "')";

                            cmd.ExecuteNonQuery();
                    
                            conn.Close();
                            textBox1.Text="";
                    

                    i want to save data to sqlserver2005 ... bt itz not working

                    P Offline
                    P Offline
                    PIEBALDconsult
                    wrote on last edited by
                    #10

                    Don't make your SQL statements that way -- use a parameterized query.

                    1 Reply Last reply
                    0
                    • S shubham salwan

                      hi, i am using visual studio 2008 and making project in c#. i had created web application form but i am not able to connect it with database. em using sqlserver2005 as database

                      shubhi

                      B Offline
                      B Offline
                      Bernhard Hiller
                      wrote on last edited by
                      #11

                      When you use "Integrated Security=True" in your connection string, the user and password given there are ignored - the current Windows user is used for login to the database instead.

                      1 Reply Last reply
                      0
                      Reply
                      • Reply as topic
                      Log in to reply
                      • Oldest to Newest
                      • Newest to Oldest
                      • Most Votes


                      • Login

                      • Don't have an account? Register

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • World
                      • Users
                      • Groups