Results 1 to 7 of 7

Thread: [RESOLVED] add data programmatically to sql table vs 2015

  1. #1

    Thread Starter
    Junior Member
    Join Date
    May 2016
    Posts
    31

    Resolved [RESOLVED] add data programmatically to sql table vs 2015

    I'm really sorry to ask this newbie question, but I just need a kick start...

    hypothetically speaking:

    Let say I have Table1 with Rows.... Name , Address

    I just want to click a button and have "Tom", "123 Blank St." added to the Row programmatically.

    Thanks in advance!

  2. #2
    Code Monkey wild_bill's Avatar
    Join Date
    Mar 2005
    Location
    Montana
    Posts
    2,993

    Re: add data programmatically to sql table vs 2015

    That is the very essence of human beings and our very unique capability to perform complex reasoning and actually use our perception to further our understanding of things. We like to solve problems. -Kleinma

    Does your code in post #46 look like my code in #45? No, it doesn't. Therefore, wrong is how it looks. - jmcilhinney

  3. #3
    PowerPoster
    Join Date
    Sep 2005
    Location
    Modesto, Ca.
    Posts
    5,195

    Re: add data programmatically to sql table vs 2015

    The problem is there are many ways to accomplish this. It really depends on what method your using to connect/retrieve the data, how are you displaying the data. Google "visual basic add data to database", you'll see lots of answers.

  4. #4
    Frenzied Member HanneSThEGreaT's Avatar
    Join Date
    Nov 2003
    Location
    Vereeniging, South Africa
    Posts
    1,492

    Re: add data programmatically to sql table vs 2015

    No need to apologize for asking a question...
    There are literally a gazillion ways to accomplish this, it all depends as rightfully mentioned by wes4dbt, how you will be approaching this. Do you have any coding so far?
    VB.NET MVP 2008 - Present

  5. #5

    Thread Starter
    Junior Member
    Join Date
    May 2016
    Posts
    31

    Re: add data programmatically to sql table vs 2015

    Thanks Hannes. I watched a few videos and found how to add a database and create the table in vs 2015, and so I tried this code to no avail:

    Code:
                            TlbLogViewBindingSource.AddNew()
    
    			Dim rNewRow As DataRow
                            Dim nDate As System.DateTime = System.DateTime.Now
    
                            nDate = Now
    
                            rNewRow = TlbLogViewBindingSource.AddNew
    
                            rNewRow.Item("DATE") = nDate
                            rNewRow.Item("NAME") = "Joe"
    
                            TlbLogViewBindingSource.Add(rNewRow)
    
                            TlbLogViewBindingSource.EndEdit()
                            TableAdapterManager.UpdateAll(DsHHLogView)
    
                            MessageBox.Show("It worked!")

  6. #6
    Frenzied Member HanneSThEGreaT's Avatar
    Join Date
    Nov 2003
    Location
    Vereeniging, South Africa
    Posts
    1,492

    Re: add data programmatically to sql table vs 2015

    OK, do you get any errors?

    Here are a few articles I wrote which I hope might be helpful to ou:

    Exploring the Data Controls in Visual Basic.NET
    http://www.codeguru.com/columns/vb/e...-basic.net.htm

    Doing Data Extraction with Visual Basic.NET
    http://www.codeguru.com/columns/vb/d...-basic.net.htm

    Using Parameterized Queries and Reports in VB.NET Database Applications
    http://www.codeguru.com/columns/vb/u...plications.htm

    Using SQL Stored Procedures with VB.NET
    http://www.codeguru.com/columns/vb/u...ith-vb.net.htm

    Doing SQL Transactions with Visual Basic
    http://www.codeguru.com/columns/vb/d...ual-basic.html
    VB.NET MVP 2008 - Present

  7. #7

    Thread Starter
    Junior Member
    Join Date
    May 2016
    Posts
    31

    Re: add data programmatically to sql table vs 2015

    Thanks so much! I got it to work for what I was trying to accomplish.

    I just needed to use:

    Code:
    Table1TableAdapter.Insert(nDate, "Joe")
     Table1TableAdapter.Fill(DatabaseName)
    Thanks to all of you guys for the help!!

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