none
Write to a table on SQL server 2005 from visual studios 2005 RRS feed

  • Question

  •  

    1)I have a mobile application that I am working on.  I am trying to have it so when I click the submit button, that I created, it should send all the data in a list box, that has been populated, to a table, that I created, in sql.  Now I was able to figure out how to connect to my databse using visual studios and edit it.  But I just have no clue as in what code to insert so that I can fill this table. 

     

    2)The next thing that I would want to know is that the data in the listbox is seperated in by colons but I want it so when the submit button is press that the information gets seperated by those colons for example:

     

    list box has multiple lines of....

    last name: first name: ssn: address: telephone #: etc......

     

    I want the table to be populated like

     

    last   first   ssn   address   phone  .........

    .       .       .        .              .

    .       .       .        .              .

    .       .       .        .              .

    .       .       .        .              .

    .       .       .        .              .

     

    Well I guess first things first is I just want to be able to send something to my table then if it's possible is there a way to send information in a more organized fashion and not just one big string in my database table?

     

    Monday, July 30, 2007 3:58 PM

Answers

  • Well there's no point in manually writing all the plumbing to get data in and out of the database. I've posted here about some ways to get this created automatically for you.

    If you've got 20 or fewer tables then Foundation is free to use, and it will even create a WinForm or WebForm app for you that's already wired-up to use the generated objects. A couple of the other options are free no matter how many tables you have.


    As for question 2 you have a few options. The best solution is to use a third-party listbox that allows multiple columns of data. I know that the Infragistics listbox allows this, but you can't just buy the one control unfortunately, you have to buy the entire WinForm suite. I'm sure there are other third-party listboxes that offer the same functionality, and some of them may be free.

    Or you could display the information in the way you described but store it behind the scenes as separate fields on your generated objects, be they Foundation objects, typed datasets or whatever. Then you just save the objects, which is all taken care of for you.

    Another option would be to do some manual coding to split the text into the separate fields, you can use the String.Split methos to do this very easily. It's messy though, and could be fragile, i.e. easily broken.

    By the way does it have to be a listbox? It sounds as though you'd be better off using a grid.

    Regards,

    Sean
    Monday, August 6, 2007 9:15 PM

All replies

  • Hi ELEV,

    I am moving this thread from Visual Studio Extensibility forum to the .NET Framework Data Access and Storage forum, since the issue is related to programming with SQL server. There are more ADO.net experts in the .NET Framework Data Access and Storage forum.

    Thanks for your understanding!

    Monday, August 6, 2007 9:50 AM
  • Well there's no point in manually writing all the plumbing to get data in and out of the database. I've posted here about some ways to get this created automatically for you.

    If you've got 20 or fewer tables then Foundation is free to use, and it will even create a WinForm or WebForm app for you that's already wired-up to use the generated objects. A couple of the other options are free no matter how many tables you have.


    As for question 2 you have a few options. The best solution is to use a third-party listbox that allows multiple columns of data. I know that the Infragistics listbox allows this, but you can't just buy the one control unfortunately, you have to buy the entire WinForm suite. I'm sure there are other third-party listboxes that offer the same functionality, and some of them may be free.

    Or you could display the information in the way you described but store it behind the scenes as separate fields on your generated objects, be they Foundation objects, typed datasets or whatever. Then you just save the objects, which is all taken care of for you.

    Another option would be to do some manual coding to split the text into the separate fields, you can use the String.Split methos to do this very easily. It's messy though, and could be fragile, i.e. easily broken.

    By the way does it have to be a listbox? It sounds as though you'd be better off using a grid.

    Regards,

    Sean
    Monday, August 6, 2007 9:15 PM