Esempio n. 1
0
        public void create_table(dbtable t)
        {
            StringBuilder cmd = new StringBuilder("create table " + t.name + "(");

            for (int i = 0; i < t.fields.Length; i++)
            {
                if (i != 0)
                {
                    cmd.Append(',');
                }
                cmd.Append(t.fields [i].name + " ");
                string type_name;
                if (t.fields [i].type == dbfield.types.str)
                {
                    if (t.fields [i].len <= 0)
                    {
                        type_name = "text";
                    }
                    else
                    {
                        type_name = "varchar(" + t.fields [i].len.ToString() + ")";
                    }
                }
                else
                {
                    type_name = type_names [(int)t.fields [i].type];
                }
                cmd.Append(type_name);
            }
            Npgsql.NpgsqlCommand c = new Npgsql.NpgsqlCommand(cmd.ToString(), con);
            c.ExecuteNonQuery();
            table_mapping [t.id] = new table_entry(t);
        }
Esempio n. 2
0
        public void create_table(dbtable t)
        {
            StringBuilder cmd = new StringBuilder("create table " + t.name + "(");

            for (int i = 0; i < t.fields.Length; i++)
            {
                if (i != 0)
                {
                    cmd.Append(',');
                }
                cmd.Append(t.fields [i].name + " ");
                string type_name;
                if (t.fields [i].type == dbfield.types.str)
                {
                    if (t.fields [i].len <= 0)
                    {
                        type_name = "ntext";
                    }
                    else
                    {
                        type_name = "nvarchar(" + t.fields [i].len.ToString() + ")";
                    }
                }
                else
                {
                    type_name = type_names [(int)t.fields [i].type];
                }
                cmd.Append(type_name);
            }
            System.Data.SqlClient.SqlCommand c = new System.Data.SqlClient.SqlCommand(cmd.ToString(), con);
            c.Transaction = trans;
            c.ExecuteNonQuery();
            set_table(t);
        }
Esempio n. 3
0
        public static void Main(string[] args)
        {
            string[] tables = new string[] { "page_visit_log", "buysell", "business" };
            s = new dbserializer(new System.IO.FileStream("tmp.out", System.IO.FileMode.Create));
            db db1 = new mssql_db();

            db1.set_params("cs", "data source=192.167.0.101;initial catalog=vanbusiness;persist security info=False;user id=user1;password=passw0rd!;packet size=32768");
            db1.connect();
            s.write_header();
            for (int i = 0; i < tables.Length; i++)
            {
                dbtable t = new dbtable();
                t.id   = i;
                t.name = tables [i];
                s.put_table(t);
                db1.get_rows(t, process_row);
            }
        }
Esempio n. 4
0
        public void get_rows(dbtable t, row_cb cb)
        {
            string cmd = "select * from " + t.name;

            System.Data.SqlClient.SqlCommand c = new System.Data.SqlClient.SqlCommand(cmd, con);
            c.Transaction = trans;
            System.Data.SqlClient.SqlDataReader r = c.ExecuteReader();
            while (r.Read())
            {
                object[] o = new object[r.FieldCount];
                r.GetValues(o);
                dbrow row;
                row.fields   = o;
                row.table_id = t.id;
                cb(row);
            }
            r.Close();
        }
Esempio n. 5
0
			public table_entry (dbtable t)
			{
				this.t = t;
			}
Esempio n. 6
0
		public static void Main (string[] args)
		{
			string[] tables = new string[]{"page_visit_log","buysell","business"};
			s = new dbserializer (new System.IO.FileStream ("tmp.out", System.IO.FileMode.Create));
			db db1 = new mssql_db ();
			db1.set_params ("cs", "data source=192.167.0.101;initial catalog=vanbusiness;persist security info=False;user id=user1;password=passw0rd!;packet size=32768");
			db1.connect ();
			s.write_header ();
			for (int i=0; i<tables.Length; i++) {
				dbtable t = new dbtable ();
				t.id = i;
				t.name = tables [i];
				s.put_table (t);
				db1.get_rows(t,process_row);
			}
		}
Esempio n. 7
0
		public void put_table (dbtable t)
		{
			formatter.Serialize (s, t);
		}
Esempio n. 8
0
		public void create_table (dbtable t)
		{
			StringBuilder cmd = new StringBuilder ("create table " + t.name + "(");
			for (int i=0; i<t.fields.Length; i++) {
				if (i != 0)
					cmd.Append (',');
				cmd.Append (t.fields [i].name + " ");
				string type_name;
				if (t.fields [i].type == dbfield.types.str) {
					if (t.fields [i].len <= 0) {
						type_name = "text";
					} else {
						type_name = "varchar(" + t.fields [i].len.ToString () + ")";
					}
				} else
					type_name = type_names [(int)t.fields [i].type];
				cmd.Append (type_name);
			}
			Npgsql.NpgsqlCommand c = new Npgsql.NpgsqlCommand (cmd.ToString (), con);
			c.ExecuteNonQuery ();
			table_mapping [t.id] = new table_entry (t);
		}
Esempio n. 9
0
		public void set_table (dbtable t)
		{
			table_mapping [t.id] = new table_entry (t);
		}
Esempio n. 10
0
		public void get_rows (dbtable t, row_cb cb)
		{
			
		}
Esempio n. 11
0
		public void create_table (dbtable t)
		{
			StringBuilder cmd = new StringBuilder ("create table " + t.name + "(");
			for (int i=0; i<t.fields.Length; i++) {
				if (i != 0)
					cmd.Append (',');
				cmd.Append (t.fields [i].name + " ");
				string type_name;
				if (t.fields [i].type == dbfield.types.str) {
					if (t.fields [i].len <= 0) {
						type_name = "ntext";
					} else {
						type_name = "nvarchar(" + t.fields [i].len.ToString () + ")";
					}
				} else
					type_name = type_names [(int)t.fields [i].type];
				cmd.Append (type_name);
			}
			System.Data.SqlClient.SqlCommand c = new System.Data.SqlClient.SqlCommand (cmd.ToString (), con);
			c.Transaction=trans;
			c.ExecuteNonQuery ();
			set_table (t);
		}
Esempio n. 12
0
		public void get_rows (dbtable t, row_cb cb)
		{
			string cmd = "select * from " + t.name;
			System.Data.SqlClient.SqlCommand c = new System.Data.SqlClient.SqlCommand (cmd, con);
			c.Transaction=trans;
			System.Data.SqlClient.SqlDataReader r = c.ExecuteReader ();
			while (r.Read ()) {
				object[] o = new object[r.FieldCount];
				r.GetValues (o);
				dbrow row;
				row.fields = o;
				row.table_id=t.id;
				cb (row);
			}
			r.Close ();
		}
Esempio n. 13
0
 public table_entry(dbtable t)
 {
     this.t = t;
 }
Esempio n. 14
0
 public void put_table(dbtable t)
 {
     formatter.Serialize(s, t);
 }
Esempio n. 15
0
 public void set_table(dbtable t)
 {
     table_mapping [t.id] = new table_entry(t);
 }
Esempio n. 16
0
 public void get_rows(dbtable t, row_cb cb)
 {
 }