» Pat Posted May 31, 2009 Author Report Posted May 31, 2009 I read it but my pizza was about to burn, lol. Haven't had time to reply. It's a great help, though. I'd need the code I already have to provide you with info so it'll take a few days. Thanks for the help. (8 Oh& I liek abstract classes. They r0x.
Kusanagi Posted June 1, 2009 Report Posted June 1, 2009 shit... I could understand all above there but I would never be able to just write it outta nowhere like.... seriously you wrote it on posting page? xD Damn.... Im no good at database working =/. Where did u learned Nick? o.o
Nick Posted June 1, 2009 Report Posted June 1, 2009 Idk. Experience I guess. :/ And yeah I did just write that out..
Kusanagi Posted June 1, 2009 Report Posted June 1, 2009 jaja I just experiment with dream weaver and Visual Basic (why it sucks .__.?), yet im not as good as to tell the whole code just by remembering.
Nick Posted June 1, 2009 Report Posted June 1, 2009 There isn't any practical difference between C#.NET and VB.NET since they both get compiled into the exact same bytecode using the exact same libraries. We're talking about VB.NET though which is different in nature to VB. (Basically standard VB but with the .NET library and stuff, which is what OP was talking about). And loldreamweaver I use Notepad++
Nick Posted June 2, 2009 Report Posted June 2, 2009 HEY IT'S FUCKING TUESDAY WHERE'S THE MOTHERFUCKING CODE HUH? oh and I actually tested my code now. Fixed some typos but otherwise works like a charm. Heh. Here's my entire working code, feel free to copy/paste into an empty .cs file and run. using System; using System.Collections.Generic; using System.Text; namespace DatabaseTesting { public class MyDatabase { public List<TableStruct> Tables; public MyDatabase() { this.Tables = new List<TableStruct>(); } public void AddTable(TableStruct table) { this.Tables.Add(table); } } public struct TableStruct { public List<ColumnStruct> Columns; public List<RowStruct> Rows; public TableStruct(int numCols) { this.Columns = new List<ColumnStruct>(numCols); this.Rows = new List<RowStruct>(); } } public struct ColumnStruct { public string Name; public ColumnType Type; public int MaxLength; public ColumnStruct(string name, ColumnType type, int length) { this.Name = name; this.Type = type; this.MaxLength = length; } } public struct RowStruct { public List<object> Fields; public RowStruct(params object[] data) { this.Fields = new List<object>(); this.Fields.AddRange(data); } } public enum ColumnType { TINYINT, SMALLINT, MEDIUMINT, INT, BIGINT, FLOAT, DOUBLE, DOUBLE_PRECISION, REAL, DECIMAL, NUMERIC, DATE, DATETIME, TIMESTAMP, TIME, YEAR, CHAR, VARCHAR, TINYBLOB, TINYTEXT, BLOB, TEXT, MEDIUMBLOB, MEDIUMTEXT, LONGBLOB, LONGTEXT, ENUM, SET } class Program { private static MyDatabase db; static void Main(string[] args) { db = new MyDatabase(); // Then do something like this in a foreach loop through your xml content: TableStruct curtab = new TableStruct(2); curtab.Columns.Add(new ColumnStruct("id", ColumnType.SMALLINT, 65535)); curtab.Columns.Add(new ColumnStruct("str", ColumnType.VARCHAR, 255)); curtab.Rows.Add(new RowStruct(0, "hello")); curtab.Rows.Add(new RowStruct(1, "world")); curtab.Rows.Add(new RowStruct(2, "lol")); db.AddTable(curtab); // Output content StringBuilder outstr = new StringBuilder(); foreach (TableStruct tab in db.Tables) { foreach (RowStruct row in tab.Rows) { foreach (object ob in row.Fields) { outstr.Append(ob.ToString()); outstr.Append(','); } outstr.Append("\n"); } outstr.Append("----\n"); } string str = outstr.ToString(); } } } It is advisable to set a breakpoint after the "string str =" and look at it, since the program itself just exits right away. Of course, the struct-based implementation is rather case-specific. If you want I can make a far broader database lib that supports a variety of formats etc. using a nice class-based system with functions etc. next time I get bored.
» Pat Posted June 2, 2009 Author Report Posted June 2, 2009 Should I have mentioned we're talking about VBA instead of .net? LOL. Sorry 4got. qq Option Explicit On Option Strict On Option Compare Text Imports System Imports System.Data Public Class Form1 Private dsDaten As New DataSet Private Sub cmdOpenFile1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdOpenFile.Click With dlgÖffnen .CheckFileExists = True .ShowReadOnly = False .Filter = "XML Files (*)|*.xml" .FilterIndex = 2 If .ShowDialog = DialogResult.OK Then DataSetEinlesen(.FileName) End If End With End Sub Private Sub DataSetEinlesen(ByVal dateiName As String) dsDaten.ReadXml(dateiName) TabellenFüllen() End Sub Private Sub TabellenFüllen() With cmbTabellen .BeginUpdate() With .Items .Clear() For Each tbl As DataTable In dsDaten.Tables .Add(tbl.TableName) Next End With .EndUpdate() End With End Sub Private Sub cmbTabellen_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmbTabellen.SelectedIndexChanged If cmbTabellen.SelectedIndex < 0 Then Exit Sub Dim tabelle As String = cmbTabellen.Items(cmbTabellen.SelectedIndex).ToString SpaltenFüllen(tabelle) End Sub Private Sub SpaltenFüllen(ByVal tableName As String) With lstSpalten .BeginUpdate() With .Items .Clear() For Each dc As DataColumn In dsDaten.Tables(tableName).Columns .Add(dc.ColumnName) Next End With .EndUpdate() End With End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click If Not lstSpalten.SelectedItem Is Nothing Then lstAdded.Items.Add(lstSpalten.SelectedItem) lstSpalten.Items.Remove(lstSpalten.SelectedItem) Else MsgBox("Bitte wählen sie einen Listeneintrag.") End If End Sub Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click If Not lstAdded.SelectedItem Is Nothing Then lstSpalten.Items.Add(lstAdded.SelectedItem) lstAdded.Items.Remove(lstAdded.SelectedItem) Else MsgBox("Bitte wählen sie einen Listeneintrag.") End If End Sub Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click With dlgfolder .ShowDialog() Dim path As String = .SelectedPath For Each item In lstAdded.Items ' XML ---> CSV code here.;( Next End With End Sub End Class Yeah, it's partially german. It's a tool for our customers, which also have access to the source code so yeah. ;( MESSY SHIT I KNOW. LOL.