WPF- How to save and retrieve details from database

I want to develop an desktop app to save and retrieve details from database, but am having a little hitch
am getting errors in my code, kindly advice below are the required code
xaml
<Grid>
        <TextBox HorizontalAlignment="Left" Height="23" Margin="144,28,0,0" TextWrapping="Wrap" x:Name="TbxId" VerticalAlignment="Top" Width="193"/>
        <TextBox HorizontalAlignment="Left" Height="23" Margin="144,134,0,0" TextWrapping="Wrap" x:Name="TbxFn" VerticalAlignment="Top" Width="193"/>
        <TextBox HorizontalAlignment="Left" Height="23" Margin="144,77,0,0" TextWrapping="Wrap" x:Name="TbxLn" VerticalAlignment="Top" Width="193"/>
        <Label Content="Student ID" HorizontalAlignment="Left" Margin="10,28,0,0" VerticalAlignment="Top" Width="101"/>
        <Label Content="Last Name" HorizontalAlignment="Left" Margin="10,134,0,0" VerticalAlignment="Top" Width="101"/>
        <Label Content="First Name" HorizontalAlignment="Left" Margin="10,77,0,0" VerticalAlignment="Top" Width="101"/>
        <Button x:Name="BtnSave" Content="Save" HorizontalAlignment="Left" Margin="23,206,0,0" VerticalAlignment="Top" Width="75" />
        <Button x:Name="BtnBrowse" Content="Browse" HorizontalAlignment="Left" Margin="149,206,0,0" VerticalAlignment="Top" Width="75" Click="Save"/>
        <Button x:Name="BtnShow" Content="Show" HorizontalAlignment="Left" Margin="294,206,0,0" VerticalAlignment="Top" Width="75"/>
        <WindowsFormsHost Grid.Column="0" Margin="448,28,75,243">
            <wf:PictureBox x:Name="pictureBox1" Height="150" Width="150" SizeMode="StretchImage"/>
        </WindowsFormsHost>
    </Grid>
cs
private void Browse(object sender, RoutedEventArgs e)
            SqlConnection cn = SqlConnection(global::DatabaseApp.Properties.Settings.Default.Database1ConnectionString);
            try
                OpenFileDialog dlg = new OpenFileDialog();
                dlg.Filter = "JPG Files (*.jpg)|*.jpg|GIF Files (*.gif)|*.gif|All Files(*.*)|*.*";
                dlg.Title = "Select Student Picture";
                if (dlg.ShowDialog() == DialogResult.OK)
                    imgLoc = dlg.FileName.ToString();
                    picStu.ImageLocation = imgLoc;
            catch(Exception ex)
                System.Windows.MessageBox.Show(ex.Message);
Thank you
Jayjay john

Hi Joakins,
I think Lloyd has a point here in that all I see there which is really database related is a connection string.
Maybe your question is more general though and you're just asking how to work with a database as a general principle.
Personally, I like entity framework and would recommend that.
You can read a shed load of stuff about it.
https://msdn.microsoft.com/en-gb/data/ef.aspx?f=255&MSPPError=-2147217396
With WPF almost every dev uses MVVM and I'm no exception.
You may find this interesting:
http://social.technet.microsoft.com/wiki/contents/articles/28209.wpf-entity-framework-mvvm-walk-through-1.aspx
The article for the second in the series is only partly written, but the sample is complete:
https://gallery.technet.microsoft.com/WPF-Entity-Framework-MVVM-78cdc204
Hope that helps.
Recent Technet articles: Property List Editing;
Dynamic XAML

Similar Messages

  • How to store and retrieve images from database...

    Hi All
    Anubody tell me plz how to store images in database using jsp.
    and how to retrieve tme.
    Plz reply...
    Anurag

    Exactly
    try the links below may be those might help u in store and retrieval any kind of file.
    http://www.mysqltalk.org/insert-blob-example-vt112861.html
    https://java.sun.com/j2se/1.5.0/docs/guide/jdbc/blob.html
    http://javaalmanac.com/egs/java.sql/GetBlob.html
    http://publib.boulder.ibm.com/infocenter/idshelp/v10/index.jsp?topic=/com.ibm.jdbc.doc/jdbc142.htm
    and a dearly advice friend please query google b4 you post any query out here.

  • How to save and retrieve table column values added via view enhancement

    Hi,
    I want to enhance standard webdynpro component FITE_VC_REVIEW.
    I want to add new column to Fight Info Table and also to Hotel Info table.
    First Approach: I add new fields to Flight Info and Hotel Info structure.
    Create an additional Coolum in Flight Info and Hotel Info Table and Bind it to newly created field in structures.
    Question
    What all changes I have to make to save and retrieve values from database table.
    Kindly guide with Steps
    Second Approach: I create a new table/structure for my requirement and bind table column to these fields.
    Question:
    What all changes I have to make to save and retrieve values from database table.
    Kindly guide with Steps
    And which approach will be good.
    Regards,
    Madhvika
    Moderator message: please have a look in the dedicated "Web Dynpro ABAP" forum.
    Edited by: Thomas Zloch on Feb 16, 2011 3:02 PM

    no ans yet

  • I have a windows 7 desktop with an external hard drive setup on my home network, will i be able to access this on my home network to save and retrieve files from my mac air?

    i have a windows 7 desktop with an external hard drive setup on my home network, will i be able to access this on my home network to save and retrieve files from my mac air?

    Troubleshooting Home Sharing - http://support.apple.com/kb/TS2972

  • How to save and retrieve an excel file as an object into lob column?

    Hi ,
    I need to save and retrieve the whole excel file with 3 or more sheets as an object into the lob column of table.
    For example:
    t_docments
    (doc_id number,
    excel_data clob
    All excel files need to be saved to excel_data column.
    What should I do?
    Thanks

    Did you check the asktom thread posted by Jens?
    http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P1
    1_QUESTION_ID:232814159006
    There's example of varies file types.Yes, I did try some examples.
    Those work for .doc/.pdf/.jpg files, BUT NOT for excel file.
    The following error happened when retrieving excel file(retrieving .doc/.pdf are OK)
    ORA-29285: file write error
    ORA-06512: at "SYS.UTL_FILE", line 18
    ORA-06512: at "SYS.UTL_FILE", line 375
    ORA-06512: at "SYS.UTL_FILE", line 990

  • How to save and retrieve 3D data

    Hi, all:
    I have several 3-D data and each one has a very large and different size. I saved them in 1D using Write to binary file after reshaping the data, and retrieve it after the user key in the size of the data so that my code can reshape the data into a correct size.
    My first question is, is there any way to save the data directly into a 3D format so that the user can retrieve the data without knowing the size? For example, I have the data A in 55(row)x512(column)x500(frame) and the data B in 3(row)x1004(column)x1500(frame). Is there any way to save and retrieve them without the need to know their size in advance?
    My second question is, I will generate several data set like this and save and retrieve them during data collection. I found that it always takes a long time to save the data, and longer time to retrieve the data. Is there any way better than saving in binary to reduce the time?
    I am using LV 8.2. I tried to search the previous posts for the answers but found that some downloaded examples gave me a warning that my current version couldn't support the function.
    I would very appreciate for any suggestion and example code to help me. Thank you in advance.

    By default, LabVIEW will prepend the array size when you write binary data, so all you need to do is wire an empty 3D array of the correct type to the "data type" input when you use "read binary file" and everything will fall into place. Have you tried?
    (Edit: Ahhh, Smercurio... was faster once more. ) 
    Message Edited by altenbach on 09-04-2008 02:32 PM
    LabVIEW Champion . Do more with less code and in less time .
    Attachments:
    3DBinary.png ‏6 KB

  • Get username from session and retrieve records from database wit tat userna

    hello..
    i got a ChangePassword.jsp which i retrieve the username from session using bean to display on e page..
    <jsp:getProperty name="UsernamePassword" property = "username"/>
    but in my servlet, i wan to retrieve records from database with tat username..
    i tot of coding
    String username = (String)request.getSession().getAttribute("UsernamePassword");
    and then use tat username to retrieve records.. but is that e right way? The page did not display and i got a CastingException..
    Please help.

    If you are using the session inside a jsp, you can say "session" without having to declare it.String usernamePassword = (String) session.getAttribute("usernamePassword");However, right after you get this value, check if it is null:
    if(usernamePassword==null)
    // do sth like forward to error page
    else
    // continue processing
    If it is null, then you are probably not setting it right in the first place. Make sure that in your servlet A you create a session, and before you return or forward to a jsp, that you actually set this value in the session like saying
    session.setAttribute("usernamePassword", usernamePassword);
    and it is case sensitive for the key.

  • How to get time specification detail from database

    Dear All,
    How can I get the time specification detail from data base?
    Time specification is a 32 bit hexadecimal no type guid_32.
    Function wfd_timespec_reload provide the modified time specification detail.
    FUNCTION wfd_timespecs_reload
    ""Local Interface:
    *"  IMPORTING
    *"     VALUE(I_LOGSYS) TYPE  LOGSYS
    *"     VALUE(I_AWTYP) TYPE  WFD_AWTYP
    *"     VALUE(IT_TIMESPEC_KEYS) TYPE  WFD_KEY_TAB
    *"  EXPORTING
    *"     VALUE(ET_TIMESPEC_DETAILS) TYPE  WFD_TIMESPEC_TAB
    *"     VALUE(ET_INVALID_TIMESPECS) TYPE  WFD_KEY_TAB
    *"     VALUE(ET_CHANGED_TIMESPEC_KEYS) TYPE  WFD_KEY_TAB
    *"     VALUE(ET_RETURN) TYPE  BAPIRET2_T
    This function take time spec from data base not from cache(buffer) so provide the modified time spec in the same session.
    I need any newly created time specification detail also. So I can show all the time spec detail in my function module for any user in the same session.
    Can anyone provide the sample code for it?
    Thanks,
    Anup Garg

    Yes I can see the pattern.
    When I get the set of numbers from database UI doesn't know what is the the list of numbers database has. I need to choose some next available number that is not in database. In the list that u are talking about next available number is 7. Its something similar to when we try to create any mailid, while registration it gives some default id which is not existing which user can choose to create his mailid. How can I get similar feature?

  • How to save and retrieve an image in JSP/Java and MS SQL/server 2000?

    Hi All,
    I am uploading an image from the JSP page and want to store it in MS SQL server. I have made a column by the name "COMPANY_LOGO" with data type as image MS SQL/server 2000. How do I save the full image in the table and how do I display the thumb nail image on the JSP page???
    Regards,
    Raj

    BEFORE YOU POST A TOPIC HERE: Please be sure your topic is related to features or functionality of this site. This forum is not for general technology questions. Not sure which forum to use? Try searching for your topic in the "Search Forums" element on the left panel.
    Post your question in
    http://forum.java.sun.com/forum.jspa?forumID=45
    or
    http://forum.java.sun.com/forum.jspa?forumID=48
    Do not reply here

  • How to save and restore Music from iTunes without using library ?

    Could yous help me please ?
    I use an 60 giga iPod I started to fill it with my CDs without using library, just directly in it, I delete the Music in the library after record to save place on may computer. I have nearly 7 megas of Music stored. To fill 60 Giga it wille takes at least 6 months on my rest time. At the end if i loose my iPod or if stolen or broken or if i want to buy a new iPod of 80 Giga for example to store more Music ? How can i save Music in my iPod on a Hard Disk or DVD and restore on it or on a new one ? Is it possible or not allowed by iTunes to avoid Music copie ?
    Thank you for your help....

    Frank31,
    Syncing music to the iPod is a one-way street, as discussed in this article:
    http://docs.info.apple.com/article.html?artnum=302155
    If you are concerned about using up your computer's hard drive for music, and are using iTunes 7, you might consider creating your library on an external drive if one is available.
    This article discusses creating an alternate iTunes library in another location, such as another drive:
    http://docs.info.apple.com/article.html?artnum=304447
    Thank you,
    Nathan C.

  • How to save and retrieve jpg/gif format image in db2

    Here am facing problem to insert jpg/gif format image in my database. And at the same time i would like to know how to retrieve that and how to display that image in my html page. So please help me in this matter.

    In future JDBC questions should be posted into the JDBC Forum

  • How to load and retrieve images from Portal. URGENT

    Dear all,
    I've designed a table with an ordsys.ordimage field for images. BIG MISTAKE, because there is no possibility to upload images from a form. I'd like to change it into a BLOB field but an error arises:
    "You cannot modify the column definition for types CLOB, NCLOB, BFILE, BLOBand Intermedia Object types(ORDSYS.ORDIMAGE, ORDSYS.ORDAUDIO, ORDSYS.ORDVIDEO). (WWV-17079)"
    Could I change it anyhow in order not to build a new table? I have a lot of forms referring to that table and I should change these forms too....(and we know it is pretty difficult)...
    I would appreciate any help.
    Tomas

    Tomas,
    Do you have any active constraints on that specific row? If the row is accessed by other forms (tables etc) you would need to disable them (for example foreign key constraints) and update the row (or remove and re-add it).
    Kostas

  • How to load and retrieve images from Portal!!!

    Dear all,
    I've designed a table with an ordsys.ordimage field for images. BIG MISTAKE, because there is no possibility to upload images from a form. I'd like to change it into a BLOB field but an error arises:
    "You cannot modify the column definition for types CLOB, NCLOB, BFILE, BLOBand Intermedia Object types(ORDSYS.ORDIMAGE, ORDSYS.ORDAUDIO, ORDSYS.ORDVIDEO). (WWV-17079)"
    Could I change it anyhow in order not to build a new table? I have a lot of forms referring to that table and I should change these forms too....(and we know it is pretty difficult)...
    I would appreciate any help.
    Tomas

    Tomas,
    Do you have any active constraints on that specific row? If the row is accessed by other forms (tables etc) you would need to disable them (for example foreign key constraints) and update the row (or remove and re-add it).
    Kostas

  • How to parse and retrieve records from xml files into columns in Table

    Hi
    I attached the thing what i tried.
    Table to hold the XML COntent:
    create table xmlfile(xml_con sys.xmltype);
    Inserting Xml file content into the Above table:
    insert into xmlfile values(sys.xmltype.CreateXml('<Root><name>RAM</name><age>23</age></Root>'))
    SQL> select * from xmlfile;
    XML_CON
    <Root>
    <name>RAM</name>
    <age>23</age>
    </Root>
    SQL> select extractValue(xml_con, '/Root/name') content from xmlfile;
    CONTENT
    RAM
    This one works fine
    But if the file content is as below( contains MUltiple Records)
    insert into xmlfile values(sys.xmltype.CreateXml('<Root><Record><name>RAM</name><age>23</age></Record><Record><name>SAM</name><age>23</age></Record></Root>'))
    SQL> select extractValue(xml_con, '/Root/Record/name') content from xmlfile;
    ERROR at line 1:
    ORA-19025: EXTRACTVALUE returns value of only one node
    Can anyone help me 4 this issue-How to extract multiple records from the XML file inthis manner(from PL/SQL without using JAVA)
    OR
    If there is anyother way to do this please tell me?

    SQL> SELECT EXTRACTVALUE (COLUMN_VALUE, '//name') NAME,
           EXTRACTVALUE (COLUMN_VALUE, '//age') age
      FROM TABLE
              (XMLSEQUENCE
                  (EXTRACT
                      (XMLTYPE
                          ('<Root>
                              <Record>
                                <name>RAM</name>
                                <age>23</age>
                              </Record>
                              <Record>
                                <name>SAM</name>
                                <age>23</age>
                              </Record>
                            </Root>'
                       '/Root/Record'
    NAME       AGE      
    RAM        23       
    SAM        23       
    2 rows selected.

  • How to speed up retrieving data from database

    I write some code to get lots of data from mysql to draw many lines in my applet
    but when I run the program ,it run slowly.
    So I think it over to find a method.
    I do it like that:
    Use single Thread to get data from mysql to draw one single line.
    But when I executed my code.
    The error"Operation not allow after ResultSet closed".
    Have you come across such problems.
    I am sorry that my code is not at my hand.
    thanks very much.

    Sorry, it's not clear. Are you saying you're generating many threads, each with their own Resultset? Maybe several resultsets from the same Statement?
    I'm not sure a statement can support more than one Resultset at a time.
    In any case, whereas it probably makes sense to have a thread doing your database retrieval I would suspect multiple threads will actually make things worse, you're limited by the connection spead and how fast mySql can actually deliver the data.
    I think you may need to concentrate on the way that the database is set up and read and to judge that we'd need to see the SQL you're using to retrieve the data, and that for setting up the table you're reading from. You might find that, for example, adding appropriate indexes in the database might help. Or doing the SQL query a different way.

Maybe you are looking for

  • Adobe Acrobat X Bates Stamp Removal

    I have just added Bates numbering to a pdf file, using Adobe Acrobat X Pro. I started the bates numbering on page 1. I want to change this to start on page 18 (for example). When I try to remove the bates numbering I just added, I receive the followi

  • Set sequence to low res, chromakey and then render full res

    I have a sequence (original footage is DV50) and I'm working with stills for background. Everytime I do something, I have to re-render. I'd like to set the sequence to a setting where I can put down all my assets, set ins and outs (with fades and stu

  • A resource assignment for new task during another task MS Project 2010

    I would like to assing a new task during another task. Resource A is assigned Task X from May 12th - May 16th. 5 hours per day. I would like to assing new Task Y for May 14th. It will take 7 hours. So I would like to set up in MS Project 2010 as: May

  • Looking for CPU Fan advice

    Bought my MB in march 07 When i'm running a graphic intensive app like photoshop, after a while the fan gets really loud, i didn't get 3 yr plan like i wanted to, so I would do repair myself. Basically, I am curious as to if I need to replace the CPU

  • Reducing Project Size, Removing unused media

    I just finished a project and now I'd like to reduce the size to free up some hard drive space. I'd like to keep the captured media files that were actually used in case there are any changes from the client, but delete the ones that were not. Is the