Inbuilt Fucntion

vikram7_dabasvikram7_dabas Member Posts: 611
How can I create Database Back by using In-Built function?My database corrupted and showing me large error box?
Vikram Dabas
Navision Technical Consultant

Comments

  • kapamaroukapamarou Member Posts: 1,152
    Can you post the error box screenshot here?
  • vikram7_dabasvikram7_dabas Member Posts: 611
    The error shows below:


    There is a corrupted area in the database. This type of error occurs if the database file is changed by another program or if the device driver does not function correctly. Warning! This error MUST be corrected before you can continue. Do not use any type of disk utilities on the database. First check the database by clicking File, Database, Test and then click Maximum. If you still get the same error, you should:

    1) Make a backup of the database by copying the database file(s).
    2) Use the built-in function to make a backup.
    3) If this works, create a new database WITHOUT deleting the database that contains the error(s). Restore the backup (made with the built-in backup function) into the new database, and test it by clicking File, Database, Test and then clicking Maximum.

    If this procedure does not work, any changes to the database after the most recent backup will be lost. Restore the most recent backup (made with the built-in backup function) and test it.
    For security reasons, you should save the old database until you have used the new one for a period of time. Contact your system manager if you need assistance.
    OK
    Vikram Dabas
    Navision Technical Consultant
  • BeliasBelias Member Posts: 2,998
    have you got a backup of the day before the problem occurs?
    if so, restore it...your current DB is f****d...
    why?because it happens...an the reasons can be a lot (damaged disk section and other things I don't know)...
    for more info search the forum
    -Mirko-
    "Never memorize what you can easily find in a book".....Or Mibuso
    My Blog
  • Slawek_GuzekSlawek_Guzek Member Posts: 1,690
    If it is in native then you're in quite bad position, but not hopeless.

    You CAN'T use backup to backup your data but...

    You can create a set of dataports one per one table, or one per few tables, and dump the database to the text file(s). The dataport will fail on corrupted table, so you can exclue it from running.

    Then for corrupted table you need to dump your data in packs, nnn records per pack, flushing the file (closing and reopening to append) after every nnn records. Again - it will fail on a single record which is located on corrupted database page.

    Then you need to run the same dataport for the same corrupted table but with descending order, again flushing the file every nnn records. You may start with qute big nnn value, decreasing it when you find in what area your table is broken.

    That way (quite costly in terms of your time) you'll be able to dump almost all your data, except records from corrupted pege(s).

    Then create a new database and dataport everything back in.

    On SQL you're in much more comfortable position - you may use DBCC tool to check and fix a database, or a single table, or a single index, or whatever failed.

    Regards,
    Slawek
    Slawek Guzek
    Dynamics NAV, MS SQL Server, Wherescape RED;
    PRINCE2 Practitioner - License GR657010572SG
    GDPR Certified Data Protection Officer - PECB License DPCDPO1025070-2018-03
  • vikram7_dabasvikram7_dabas Member Posts: 611
    How I woiuld know that which table is corruted?
    Vikram Dabas
    Navision Technical Consultant
  • Slawek_GuzekSlawek_Guzek Member Posts: 1,690
    Quite simple - your export will fail with the same error you've posted when it tries to read from corrupted table :)

    In generall NAV throws an error only when it tries to access corrupted page in the database, which may contain one (rare case) or more records. All other good pages can be accessed and the data can be read.

    Your goal is to read as much as possible. If you read a table one by one and flush your file after each table all good data will be saved into text file.

    If your table records sits in good database pages you may read all of them. If the table has some corrupted pages (it might be only one, or quite a few), NAV still allows you to read the data as long as you don't try to read the record from corrupted page.

    You may write some simple analysis tool using recref variable, opening all of your tables one by one, and reading all the records. Something like that:
    Object.setrange(Type,0); // 0 - TableData, if the re is no data in the table it will not show up in the filtered range
    If object.findset then 
    repeat
      recref.open(object.id);
      if recref.findset then
        repeat 
          i +=1;
          if i > 1000 then begin
            file.write(recref.getposition);
             i := 0;
          end;
        until recref.next=0;
        recref.close;
      until object.next=0;
    
    (You need to test and play a little with the code as wtite it just off the top of my head without testing, and setting proper variables)

    Anyway - when you run the code above it will write you a kind of log in the selected file. When error is thrown just open the file and you will know which table is corrupted, and latest position (table primary key values) which can be read.

    You may then fine tune the procedure, decrease 1000 to 50, set starting filters to values got from log file and run it against suspected table to get latest good record.

    Then you may try to repeat the process but reading table backward from the latest trecord to the first (adding recref.ascending(false); after reref.open(); Finally you should be able to tell the last good record in corrupted table, or the corrupted region range.

    Having all this information you may write a dataport or a set of dataport to read and dump to file all good records from all the tables. Then you may use the same dataports to read the data into fresh newly created database. With developer licence it will not be a problem at all, with user licence you may need to ask your NSC to create a dataport for you as normaly you cannot modify directly any ledgers - a special permissions needs to be set on dataport objects.

    Hope this helps,
    Slawek

    BTW Did you perhaps change codepage on the server/PC holding your database file ? If yes that might be the reason. It happens sometimes when people are using non ASCII characters in CODE fields (like special national characters)
    Slawek Guzek
    Dynamics NAV, MS SQL Server, Wherescape RED;
    PRINCE2 Practitioner - License GR657010572SG
    GDPR Certified Data Protection Officer - PECB License DPCDPO1025070-2018-03
Sign In or Register to comment.