Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //RDB TO SQL FOR db_creaturefarm by Gr4ph0s
- //RELEASE ON EPVP
- #include <iostream>
- #include <fstream>
- using namespace std;
- struct db_creaturefarm {
- char rate;
- char form;
- char enhance_level;
- char ticket_count;
- };
- int main()
- {
- int nbloop; //var for count number of loop
- ifstream RDB; //stream for read rdb
- ofstream SQL; //stream for write sql
- RDB.open("db_creaturefarm.rdb", ios::in | ios::binary); //open RDB file
- if(!RDB)//if the file can't be open
- {
- cout << "Cannot open file.\n";
- return 1;
- }
- SQL.open("db_creaturefarm.sql"); //open SQL file
- RDB.seekg(128, ios::beg); //We go over the header(128empty bit)
- RDB.read((char *) &nbloop,4);//we read 4bit(int) corresponding to the nb of line
- db_creaturefarm data[nbloop];//create array who will contening each information
- for(int i=0; i<nbloop; i++) //loop for read all data
- {
- RDB.read((char *) &data[i], sizeof(db_creaturefarm));//put each data from structure into
- }
- RDB.close(); //close RDB
- if(!RDB.good()) //If error durring reading(some time because you try to read more than you can)
- {
- cout << "A file error occurred.\n";
- return 1;
- }
- //Wrinting Drop & create for CreatureFarmResource
- SQL << "USE [Arcadia]\nGO\n/****** Object: Table [dbo].[CreatureFarmResource] Script Date: 18/11/2012 16:55:03 ******/\nDROP TABLE [dbo].[CreatureFarmResource]\nGO\n\nSET ANSI_NULLS ON\nGO\nSET QUOTED_IDENTIFIER ON\nGO\nCREATE TABLE [dbo].[CreatureFarmResource](\n [rate] [int] NOT NULL,\n [form] [int] NOT NULL,\n [enhance_level] [int] NOT NULL,\n [ticket_count] [int] NOT NULL\n) ON [PRIMARY]\n\nGO\n\n" ;
- for(int i=0; i < nbloop; i++)
- {
- SQL << "INSERT INTO [Arcadia].[dbo].[CreatureFarmResource]\n" << //Wrinting each data in SQL files
- "([rate] "<<
- ",[form]" <<
- ",[enhance_level] "<<
- ",[ticket_count]) "<<
- "\nVALUES\n"<<
- "(" <<
- (int)data[i].rate << "," <<
- (int)data[i].form << "," <<
- (int)data[i].enhance_level << "," <<
- (int)data[i].ticket_count << ")" <<
- "\nGo\n\n";
- }
- SQL.close(); //close SQL
- return 0; //exit
- }
Advertisement
Add Comment
Please, Sign In to add comment