Guest User

Untitled

a guest
Jan 23rd, 2018
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.22 KB | None | 0 0
  1. using System;
  2. using DTOLib;
  3.  
  4. namespace dtoTest
  5. {
  6. class Class1
  7. {
  8. [STAThread]
  9. static void Main(string[] args)
  10. {
  11. string compName = null;
  12. string userName = null;
  13. string password = null;
  14. string dbname = null;
  15. string ddflocation = null;
  16. string datalocation = null;
  17. dtoDbFlags dbflags = DTOLib.dtoDbFlags.dtoDbFlagDefault;
  18.  
  19. DTOLib.dtoResult result;
  20. if (args.LongLength < 1)
  21. {
  22. Console.WriteLine("Invalid options.n");
  23. Console.WriteLine("Usage: dtoDBN.EXE <computername> <username> <password> <dbname> <ddf location> <data location> <DBFlage>");
  24. Console.WriteLine("NOTE: locations must be relative to the computer where the PSQL engine is running.");
  25. Console.WriteLine("DB Flags must be passed as integer in this example with these values: ");
  26. Console.WriteLine(" P_DBFLAG_BOUND = 1; (* bound database - must have P_DBFLAG_CREATE_DDF too *)");
  27. Console.WriteLine(" P_DBFLAG_RI = 2; (*relational integrity *)");
  28. Console.WriteLine(" P_DBFLAG_CREATE_DDF = 4; (*create ddf flag *)");
  29. Console.WriteLine(" P_DBFLAG_NA = 2147483648; (*not applicable *)");
  30. Console.WriteLine(" P_DBFLAG_DEFAULT = (P_DBFLAG_BOUND or P_DBFLAG_RI); ");
  31.  
  32. return;
  33. }
  34. if (args.LongLength == 7)
  35. {
  36. compName = args[0].ToString();
  37. userName = args[1].ToString();
  38. password = args[2].ToString();
  39. dbname = args[3].ToString();
  40. ddflocation = args[4].ToString();
  41. datalocation = args[5].ToString();
  42. dbflags = (dtoDbFlags)Convert.ToInt32(args[6]);
  43. }
  44. Console.WriteLine("Create Pervasive Database using DTO and C#");
  45. DtoSession mDtoSession = new DTOLib.DtoSession();
  46. try
  47. {
  48. result = mDtoSession.Connect(compName, userName, password);
  49. if (result != 0)
  50. {
  51. Console.WriteLine("Error connecting to server. Error code:");
  52. }
  53. else
  54. {
  55. //Create a Database name here.
  56. DtoDatabase db = new DtoDatabase();
  57. db.Name = dbname;
  58. db.DdfPath = ddflocation;
  59. db.DataPath = datalocation;
  60. db.Flags = dbflags;
  61. result = mDtoSession.Databases.Add(db);
  62. if (result !=0)
  63. {
  64. Console.WriteLine(string.Format("Error creating the datbase ({0}). Error code: {1}", dbname, result.ToString()));
  65. }
  66. else
  67. {
  68. Console.WriteLine(string.Format("Database ({0}) created. ", dbname));
  69.  
  70. }
  71.  
  72. result = mDtoSession.Disconnect();
  73. Console.ReadLine();
  74. }
  75. }
  76. catch (Exception e1)
  77. {
  78. Console.WriteLine(e1.Message.ToString());
  79. }
  80. }
  81. }
  82. }
Add Comment
Please, Sign In to add comment