Results 1 to 6 of 6

Thread: [RESOLVED] [2005] SQL Database

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Aug 2002
    Posts
    133

    Resolved [RESOLVED] [2005] SQL Database

    I need to be able to add / delete / find records using the SQL database from 2005. This needs to be done with all CODE and no controls. Can anyone provide some samples or point me in the right direction? I know what SQL statements I want to use, but the code is different from what i'm used to in VB6

    Thanks

  2. #2
    .NUT jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    105,433

    Re: [2005] SQL Database

    There are numerous tutorials in my signature that have ADO.NET information.

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Aug 2002
    Posts
    133

    Re: [2005] SQL Database

    That explains how I can read data from the data base. Which I can do fine. It's just doing the updating that i'm having a problem with.. Like INSERT INTO and UPDATE tablename, and DELETE from tablename..... The SELECT statements I can do, just everything else it where i'm coming down with the problem.

  4. #4
    Hyperactive Member kayos's Avatar
    Join Date
    Apr 2004
    Location
    Largo, Florida
    Posts
    306

    Re: [2005] SQL Database

    use a command object

    VB Code:
    1. Con = New System.Data.SqlClient.SqlConnection
    2. Con.ConnectionString = "myConString"
    3.  
    4. Cmd = New System.Data.SqlClient.SqlCommand
    5. Cmd.Connection = Con
    6. Cmd.CommandText = "INSERT INTO [Table] VALUES(1,2,3)"
    7.  
    8. Cmd.ExecuteNonQuery()

    Or close to that.

    Same thing with update and delete statements.. just change the command text to whatever you want.


    If this post helps, please RATE MY POST!

    Using Visual Studio 2005 SE

  5. #5
    .NUT jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    105,433

    Re: [2005] SQL Database

    Quote Originally Posted by rjdpa
    That explains how I can read data from the data base.
    I think you'll find that the tutorials will explain all aspects of ADO.NET, including inserting, updating and deleting.

  6. #6

    Thread Starter
    Addicted Member
    Join Date
    Aug 2002
    Posts
    133

    Re: [2005] SQL Database

    Thanks Kayos for that. However, I had to open the connection before doing the execution, then close it afterwords when i'm finished.

Posting Permissions

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



Click Here to Expand Forum to Full Width