Easy Database Question

I'm finding it difficult as a newbie to even grasp the core basics of database programming in VBEE.

I have created a database in my project and done all the necessary table and column creations, but when I create a simple form that contains a textbox with an OK button, I can't for the life of me find what code I need to write when the OK button is clicked to insert the textbox data into the database!

I thought it would be a simple...

Private Sub btnOK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOK.Click
ABCTableAdapter.Insert(ABCTextBox.Text)
Me.Close()
End Sub

But this has proven not to be the case as no data ends up being inserted!

Unfortunately a search for inserting data into a database brings up many SQL query language help pages containing the word INSERT and maybe it seems I will need to learn SQL to make a simple database program that simply inserts, updates and deletes data in VBEE to work.

Am I wrong

Is there actually an easier way in VBEE to do basic database programming

Thanks,

Ryan


Answer this question

Easy Database Question

  • Fang Liu

    Thanks Renee.

    It looks like I'll have to travel down that route.

    Is the coding you are speaking of VBA for Access I have some experience with VBA in Excel, so hopefully it shouldn't be a huge transition.

    Shame that VBEE couldn't do it for me - I was eager to learn a .NET language.

    Oh well.

    Ryan

  • JoelT3

    hi

    no it doesn't erase it but you searching in wrong place, at the top of this forum there is a FAQ thread there is a post there about database update has the answer

    in databases you just connect then select ,insert , update , Delete, the term "save" only needed for the database structure changes

    you said

    because I open the server explorer, navigate to the table, right click and select show table data and all that's in there is NULL values.

    are you sure you use VBEE because there is no server explorer in VBEE

    best regards



  • sroche

    Hi shakalama!

    I entered your code and after running it "i" returned 1.

    When my form closes does it erase the data in the database If that's the case should I have a save database function before closing the form

    I know there's no data in the database after successfully running the form because I open the server explorer, navigate to the table, right click and select show table data and all that's in there is NULL values.

    Thanks for your help.

    Ryan

  • Tom Janssen

    You'll find these free video's of great help,

    http://msdn.microsoft.com/vstudio/express/vb/learning/

    Good luck

    Anthony Cook


  • gopalkrishna

     

    Hi there.

    I know there are people that will disgree with me but.....

    I'm a woman who is an old systems engineer and I'm not fond of databases and certainly don't want the over head of SQL on my system.

    So I use Access databases and I use them in a weird way. I actually write code!!!!

    I use the database as simply as a sophisticated container. Yes I do use the tables but I code my own queries in ADO.Net and I love it.

    So I'd recommend Access databases rather than SQL.

     



  • MrLunch

    hi,

    the easiest way that i know is to use the dataset add new rows and call tableadapter.update

    but how did you know that your database didn't change

    table adapter return integer that represent the number of rows that was affected you use it like

    dim i as integer = mytableadapter.insert(whatever)

    did it return 0 or did it throw exception

    best regards



  • empty mind

    Is the coding you are speaking of VBA for Access I have some experience with VBA in Excel, so hopefully it shouldn't be a huge transition.

    Shame that VBEE couldn't do it for me - I was eager to learn a .NET language.

    Oh well.

    No ... It VB and Ado.Net....

    It looks like this......

     

    For Each ctrow As DataRow In CategoriesTable.Rows

    If ctrow(CategoryTable.csCategories) = Row(DataRecords.csParentCategoryName) Then

    lv.DateCreated = Row(CategoryTable.cdtDateCreated)

    lv.DateModified = Row(CategoryTable.cdtDateModified)

    Exit For

    End If

    Next

    In almost every conceivable way VBEE CAN DOIT and after you get the hang of it.... It's fun although sometimes... boring.

    For the most part it's done with tables and rows instead of recordsets. It was difficult to wrap my head around at first but a row is exactly like a recordset except you allocate it, and intialize it and often append it to a table.

     



  • Easy Database Question