theLizard

theLizard

  • NA
  • 3.5k
  • 427.4k

OleDBConnection - Your Wish List

Dec 7 2009 5:40 PM
I am currently writing an OleDb Connection component to make life a little easier to connect to databases and make life easier to populate TreeView, CheckList, Combo, List Boxes , combo boxes.

So far the syntax to add nodes to a TreeView requires 2 lines of code on the form

//This can be set in the FormLoad event or anywhere a change in connection string is needed.
lizardOleConnection1.ConnectionsString = @"Provider=SQLNCLI;Server=NAME\SQLEXPRESS;Database=odbcClass;Trusted_Connection=yes;";

//after the connection string is set all that is needed is one line of code  to fill TreeViews
lizardOleConnection1.AddTreeNode(treeView1, "SELECT * FROM myTable", "CustomerName" );  //by field name

//Or

      TreeNode node = treeView1.Nodes.Add("Root");
      lizardOleConnection1.AddTreeNode(node, "SELECT * FROM myTable", 1); //by ordinal position of field in database table

//Combo boxes
lizardOleConnection2.FillCombo(comboBox1, "SELECT * FROM myTable", 0);

//Or add items by range of values

      lizardOleConnection1.Connect = true;
      lizardOleConnection1.SQL = "SELECT * FROM myTable";
      if (lizardOleConnection1.Read())
        {
        comboBox1.Items.AddRange(lizardOleConnection1.GetFieldValues());
        // OR this---> listBox1.Items.AddRange(lizardOleConnection1.GetFieldValues());
        //
OR this---> checkedListBox1.Items.AddRange(lizardOleConnection1.GetFieldValues());
        }


//Saving records is just as easy

            lizardOleConnection1.ClearParams();
            lizardOleConnection1.AddParam("a", GetValueFromFunction()");
            lizardOleConnection1.AddParam("b", TextBox1.Text);
            lizardOleConnection1.AddParam("c", "Hello c");
            lizardOleConnection1.AddParam("d", "Hello d");
            lizardOleConnection1.ExecuteSql("INSERT INTO myTable(a, b, c, d) VALUES(?, ?, ?, ?)");

Thats it.

//Deleting records is just as easy

            lizardOleConnection1.ExecuteSql("DELETE FROM myTable WHERE a = 'b'");

After dropping a lizardOleConnection component onto your form, you can set the connection string and a command text and that's it.
 

You can drop as many of these onto a form so you can connect to SQL Server, MySql, Access, Excel just by setting the connection string and an SQL (Command Text) to execute.

You will also be able to load grid views and define a totals row and the format for the columns in the totals row.

What I am looking for is suggestions from you as to what you would like to see in this component (I am also working on an ODBC version as well)