|
Not quite sure what the problem is but perhaps a little bit different approach could be useful to you:
- create a class that represents a table with properties such as table name, create statement, to be created bit (which defaults to true)
- create an instance for all of your tables
- place the created instances to a generic dictionary (
Dictionary<string,> ), place the table name to the key of the dictionary item - after this get the schema
- loop every row found from schema and set the corresponding item in the dictionary to not to create the table
- after this you can loop the dictionary and execute every create statement from the instances where create bit is still true
- the instances can be created based on for example a xml file if you want to add tables without modifying the code (in this case take good care for the seurity issues)
Hope this helps,
Mika
The need to optimize rises from a bad design.
My articles[ ^]
|
|
|
|
|
i used two arrays and rewrote my SQL execute to a function and used two for loops, i might convert the Arrays to XML or store in a config file down the road but for now I have this part 100% done have to move on to the main focus of the solution i am working on parsing a very nested XML file
Thanks for your suggestions
bool create = false;
for (int j = 0; j < NATables.Length; j++)
{
create = true;
for (int i = 0; i < rows.Length; i++)
{
string r = rows[i]["TABLE_NAME"].ToString();
if (r == NATables[j])
{
create = false;
return;
}
}
if (create == true)
{
string strQuery = CTquery[j];
RunSQLQuery(strQuery);
create = true;
}
}
|
|
|
|
|
You're welcome.
The need to optimize rises from a bad design.
My articles[ ^]
|
|
|
|
|
i have three treeviews and they used the same database to but use difrent table to populate.
I have written the code i just dont know how i am going populate the Others.
Please help
This is my code that i have done
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Threading;
using System.Collections;
using System.Data.SqlClient;
namespace Envision
{
public partial class Envision : Form
{
SqlConnection conn = new SqlConnection("Data Source=ICNWS00054;Initial Catalog=EnvisionPlatformDatabase;User ID=sa;Password=3Password5");
SqlDataAdapter dtd;
DataSet ds;
DataView dv;
public TreeNode node;
public Envision()
{
InitializeComponent();
}
//
private void GetData(int EnCid, TreeNode EnNode)
{
dv = ds.Tables[0].DefaultView;
dv.RowFilter = "EnCid=" + EnCid;
int dvC = dv.Count;
if (EnNode == null)
{
int i = 0;
while (i &lt; dvC)
{
dv = ds.Tables[0].DefaultView;
dv.RowFilter = "EnCid=" + EnCid;
TreeNode node = new TreeNode();
node.Text = dv[i]["EnNode"].ToString();
node.Tag = int.Parse(dv[i]["NodeId"].ToString());
this.treeView1.Nodes.Add(node);
GetData((int)node.Tag, node);
i++;
}
}
else
{
int i = 0;
while (i &lt; dvC)
{
dv = ds.Tables[0].DefaultView;
dv.RowFilter = "EnCid=" + EnCid;
TreeNode node = new TreeNode();
node.Text = dv[i]["EnNode"].ToString();
node.Tag = int.Parse(dv[i]["NodeId"].ToString());
EnNode.Nodes.Add(node);
GetData(int.Parse(dv[i]["NodeId"].ToString()), node);
i++;
}
}
}
private void treeView1_AfterSelect(object sender, TreeViewEventArgs e)
{
}
private void Form1_Load(object sender, EventArgs e)
{
ArrayList EnvisionP = new ArrayList();
TreeNode EnNode = new TreeNode("EnNode");
EnNode.Tag = EnvisionP;
dtd = new SqlDataAdapter("select * from [User Panel] order by NodeId", conn);
ds = new DataSet();
dtd.Fill(ds, "User Panel");
GetData(0, null);
}
private void ultraExplorerBar1_ItemClick(object sender, Infragistics.Win.UltraWinExplorerBar.ItemEventArgs e)
{
}
private void treeView1_AfterSelect_1(object sender, TreeViewEventArgs e)
{
}
private void treeView2_AfterSelect(object sender, TreeViewEventArgs e)
{
}
private void ultraListView1_ItemActivated(object sender, Infragistics.Win.UltraWinListView.ItemActivatedEventArgs e)
{
}
private void listView1_SelectedIndexChanged(object sender, EventArgs e)
{
}
}
}
|
|
|
|
|
Hello dear friend,
It's clear that you are new in CP. So read the first post of page1, titled "How to get an answer to your question" by "Chris Maunder", it will guide you how to post your questions. Take a look here[^] and here[^] for more info.
Have a nice journey here in CP
While (true) { Human.isLearnable = true; }
|
|
|
|
|
|
|
Thank You Very Much
|
|
|
|
|
Let's see... not too familiar with sarcasm, aren't we?
|
|
|
|
|
|
Hi Craig,
if you need urgent help d´ont post call 911 instead!!!
nelsonpaixao@yahoo.com.br
trying to help & get help
|
|
|
|
|
Okay...
Personally I would create some sort of a class which contains the data I want to access.
public class MyDataTag
{
public MyDataTag(DataRowView dataRow)
{
itemID = dataRow["NodeId"];
text = dataRow["EnNode"].ToString();
otherInfo = dataRow["OtherInfo"].ToString();
}
public object itemID;
public string text;
public string otherInfo;
}
Then I would replace the tree node creation code with:
TreeNode node = new TreeNode();
MyDataTag dataTag = new MyDataTag(dv[i]);
node.Text = dataTag.text;
node.Tag = dataTag;
And your AfterSelect event handler:
MyDataNode itemData = e.Node.Tag as MyDataNode;
if (itemData != null)
{
string test = string.Format("ID: {0} Other Info: {1}", itemData.itemID.ToString(), itemData.otherInfo);
ListViewItem newItem = listView1.Items.Add(test);
newItem.Tag = itemData;
}
Lea Hayes
|
|
|
|
|
|
I have a Windows Form MDI which 3 treeviews that are separated by a Split Container.
I am trying to make them populate from the same Database but with diffrent tables for each treeview.
So far i have managed to only populate one out the three and could some help me please?
Thank you in advance
|
|
|
|
|
Just treat them as 3 treeviews, the fact they are in split containers should not be relevant. Just bind each one to the appropriate data source.
Bob
Ashfield Consultants Ltd
|
|
|
|
|
Im Sorry Im New to Programming so i dont know how to do it.
Could you please help me ?
|
|
|
|
|
After flooding the forum with no less then 4 near-identical posts, I dont think anyone is going to be in the mood to help you.
|
|
|
|
|
I second that.
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
"Not only do you continue to babble nonsense, you can't even correctly remember the nonsense you babbled just minutes ago." - Rob Graham
|
|
|
|
|
im very sorry for that.
I just wanted a little help
but thank you
|
|
|
|
|
craigMUTOKOKAI wrote:
I just wanted a little help
That's cool. Folks around here can be helpful, just be patient. Since you said you were new, I suggest you look through articles of interest on this site, and become familiar with researching on google
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
"Not only do you continue to babble nonsense, you can't even correctly remember the nonsense you babbled just minutes ago." - Rob Graham
|
|
|
|
|
I have tried to search around but no luck
so my friend told me about this website that people can help you rather you searching on google and finding nothing.
Thank You
|
|
|
|
|
craigMUTOKOKAI wrote: my friend told me about this website
What a good friend you have. Welcome aboard
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
"Not only do you continue to babble nonsense, you can't even correctly remember the nonsense you babbled just minutes ago." - Rob Graham
|
|
|
|
|
Thank You.
I have been trying to this for 3 days now but still no luck.
Do you were i can find a good Example for 3 treeviews that connect to a Sql Server. Using either diffrent Database or the same database using tables inside the same database.
If that Makes any sense
If not then Thank You.
You Guys are Great
I like this Forum
|
|
|
|
|
craigMUTOKOKAI wrote: Do you were i can find a good Example for 3 treeviews that connect to a Sql Server.
You're going about this the wrong way. You're trying to find an example of using 3 treeview with SQL server. What you really have is a single treeview, which you said you already got working, and repeating the same process 3 times.
|
|
|
|
|
Oh okay thank You.
What i was trying to do is to create a class to connect to the Server.
And then use that class in the 3 treevies that i have so that they can connect to the database an populate thier own table.
Like
Treeview 1 = Golf
database table= golf
Treeview 2= tennis
database table=tennis
Treeview 3=Basketball
Database Table = Basketball
An the Database instace will be called Sports.
So i want to connect these Tables to the same Database but to use thier own tables in the database to populate the treeview.
I hope im making sense.
Can you help me create this class and call the class whithin the Treeviews.
i hope im no stressing you out.
If i am very Sorry
|
|
|
|