none
Connect textbox to save in database in VB?

    Question

  • Hi! I wonder how I should do to save an input from a textbox to a database for (as example: customers.mdf). How do I do?

    Happy for a fast answer.

    Wednesday, August 16, 2006 11:24 AM

Answers

  • I think you need to think a little more on this one.  You want to save the contents of a textbox to a database - is this only a single record you want to create or are you wanting to create multiple records.   Creating one each time you enter something in this textbox and click a save button.  If so you will need to have some way of retrieving them - saving them is only one part of the problem.

    You would need to design a table layout to support this.   Maybe a simple two field table with an two fields ID and TextContents would suffice but how much text are we talking here as this would be used to determine the field size.

    I think that you may want to look at databinding and a nice free ebook with some good data centric application walkthrough is at

    http://msdn.microsoft.com/vbasic/learning/introtovb2005/

    This has a good walkthrough which you should look at and try to follow.    This should point you in one direction.  

    A simple web search on VB + Data binding will reveal a good number of URL's

    Alternatively you can simply write ADO.net code to save data to a database.    The exact code would depend upon you database type (Access, SQL Server, Oracle ..... ) , design table design, implementation (SQL code, Queries or Stored Procedures)  but ultimately would simply involve an ADO.Net  command object with a connection to a database, the command object would take parameters which would be set using the textbox text property.

    A simple web search on ADO.NET + Insert + Command will reveal a good number of URL's

    Hope these point you in the right direction - you question was just so general and wide that its difficult to give you any specific code without better understanding what your really trying to achieve and what your using.

     

    Wednesday, August 16, 2006 7:51 PM

All replies

  • I think you need to think a little more on this one.  You want to save the contents of a textbox to a database - is this only a single record you want to create or are you wanting to create multiple records.   Creating one each time you enter something in this textbox and click a save button.  If so you will need to have some way of retrieving them - saving them is only one part of the problem.

    You would need to design a table layout to support this.   Maybe a simple two field table with an two fields ID and TextContents would suffice but how much text are we talking here as this would be used to determine the field size.

    I think that you may want to look at databinding and a nice free ebook with some good data centric application walkthrough is at

    http://msdn.microsoft.com/vbasic/learning/introtovb2005/

    This has a good walkthrough which you should look at and try to follow.    This should point you in one direction.  

    A simple web search on VB + Data binding will reveal a good number of URL's

    Alternatively you can simply write ADO.net code to save data to a database.    The exact code would depend upon you database type (Access, SQL Server, Oracle ..... ) , design table design, implementation (SQL code, Queries or Stored Procedures)  but ultimately would simply involve an ADO.Net  command object with a connection to a database, the command object would take parameters which would be set using the textbox text property.

    A simple web search on ADO.NET + Insert + Command will reveal a good number of URL's

    Hope these point you in the right direction - you question was just so general and wide that its difficult to give you any specific code without better understanding what your really trying to achieve and what your using.

     

    Wednesday, August 16, 2006 7:51 PM
  • i have the same problem, i need to save the text from the input text into my database...but it has 6 fields, one of them is the password field, and i need to save the input text content into the password field...i am working with access database!
    Tuesday, October 10, 2006 6:39 PM
  • i have the same problem.
    it just cant save the password field.

    if i remove the password field, it work nicely.
    the error occur on Insert and Update Query.
    Friday, March 12, 2010 2:49 AM