Javascript must be enabled in your browser to use this page.
Please enable Javascript under your Tools menu in your browser.
Once javascript is enabled Click here to go back to سیستم عامل جدید ایرانیان v2.88
View Database Structure Using C#

situation in the site

صقحه اصلی Articles DataBase View Database Structure Using C#

Search

Statistics Site

mod_vvisit_countermod_vvisit_countermod_vvisit_countermod_vvisit_countermod_vvisit_countermod_vvisit_counter
mod_vvisit_counterامروز92
mod_vvisit_counterدیروز152
mod_vvisit_counterاین هفته671
mod_vvisit_counterاین ماه1596
mod_vvisit_counterکل بازدیدها40230

Online users

We have 5 guests online

Members of the online

غير فعال
Banner

اخبار ايران

With law enforcement to targeted subsidies were no poor country will not
With law enforcement to targeted subsidies were no poor country will not
تهران - رييسجمهوري با اشاره به اهميت اجراي قانون هدفمند کردن يارانه ها تاکيد کرد : با اجراي اين قانون هيچ فقيري در کشور باقي نمي ماند. Tehran - President pointed out the importance of law enforcement targeted subsidies emphasized: with the implementation of the law of any country remain poor.
به گزارش خبرنگار سياسي ايرنا ،محمود احمدينژاد که روز سه شنبه در ديدار با شرکتکنندگان بيست و يکمين همايش ملي معرفي کارگران و گروههاي کار نمونه کشور سخن ميگفت،افزود :اجراي اين قانون 100 درصد به نفع جامعه کارگري است . According to IRNA political correspondent, Mahmoud Ahmadinejad on Tuesday to meet with participants in the Twenty-first National Conference workers and group work to introduce the country spoke instance, added: "Implementation of this law 100 percent in favor of workers.
وي در بخش ديگري از سخنان خود افزود: بايد مناسبات کاري خود را با فرهنگ کشورمان منطبق کنيم زيرا نميتوان با فرهنگ سرمايهداري و مادي غرب مناسبات کاري کشور را تنظيم کرد. He added that another part of his speech: To be working with our culture because we can not comply with the material culture of the capitalist West relations and the country set to work. کارفرمايان بايد با کارگران براساس فرهنگ کشور خودمان برخورد کنند و در اين امر از کشورهاي غربي الگو نگيرند. Employers should treat workers according to their own country and culture in Western countries, this pattern other users.
احمدينژاد ادامه داد: ماموريت همه ما ساختن ايران است که البته همه هياهوها، اظهارنظرها و حرکتها بايد معطوف به ساختن ايران باشد. Ahmadinejad continued: our mission to make all of the constitutional revolution, of course, the comments should be focused on building the movement in Iran. هر اقدامي که در جهت ساختن ايران نباشد فايدهاي ندارد. Any action to make Iran does not Faydhay.
رييس دولت دهم اولين لازمه ساختن ايران را همدلي دانست و بيان کرد: براي ساختن ايران نيازمند همدلي هستيم که همدلي جامعه کارگري الگويي براي همه اقشار است زيرا اگر به اين موضوع توجه شود، همه کارها با سرعت بيشتري انجام خواهد شد. I needed to make the first head of government of Iran expressed sympathy and said: Iran needs to build empathy empathy that are a model for all strata of society workers because if this is the subject of attention, everything will be done more quickly.
رييسجمهوري در ادامه با تاکيد بر اينکه ما نيازمند نگاه به افقهاي بلندي در کار هستيم، تصريح کرد: ارزيابيها به ما نشان ميدهد ظرفيت پيشرفت در کشور ما سه برابر وضع فعلي است. More President emphasized that we need to look at long horizons we work, emphasized: "Our evaluations show that the capacity to progress in our country is three times the current situation. اگرچه در سالهاي اخير پيشرفت کشور رشد قابل توجهي داشته است اما باز هم ظرفيت کار زيادي در کشور وجود دارد. Although the country's progress in recent years has had significant growth but still a lot of work capacity in countries.
وي افزود: يکي از محورهاي اساسي نظام سلطه براي تسلط بر ملتها، جلوگيري از همدلي آنها است و براي از بين بردن همدلي ميان اعضاي يک خانواده سرمايهگذاري و تلاش بسياري ميکنند. He added: "One of the main axes system of domination for domination over nations, to prevent them sympathy and empathy for the destruction of the members of a family investment and effort are many.
احمدينژاد از نگاه به قلههاي بلند به عنوان دومين لازمه ساختن ايران ياد کرد و خاطرنشان کرد: اگر ملتي همدلي و امکانات داشته باشد اما افقهاي بلندي را وجهه همت خود قرار ندهد، پيشرفت نخواهد کرد. Ahmadinejad to look up as the second peak of construction required to learn and noted: "If a nation is possible, but empathy and long horizons does not face their efforts, progress will not. زيرا افقهاي بلند، همتهاي بلند را برميانگيزاند. Horizons because the long, long Brmyangyzand Hmthay.
وي با تاکيد بر اينکه افق نگاه ملت ما،جهاني است،تصريح کرد: ملتي در دستيابي به اهدافش موفقتر است که بالاترين قلههاي جهاني را مورد نظر خود قرار دهد. He emphasized that looking at the horizon of our nation, world, emphasized: "the most successful nation in achieving its goals is the highest peak in the world are looking to. حتي کساني هستند که افق نگاهشان ساختن جامعه بشري است. Their eyes lock, even those who make the horizon of human society. مطمئنا اين افراد بهتر ميتوانند کشور خود را بسازند. Surely these people can better their own country. بنابراين هرچقدر افقهاي ما بلندتر باشد، همت ما قويتر، مستحکمتر و عميقتر خواهد بود. So no matter how our horizons are longer, our efforts stronger, deeper and stronger will.
احمدي نژاد کار، تلاش و پيگيري را ديگر عامل ساختن ايران دانست و گفت: بسياري از افراد افقهاي بلندي دارند اما اهل کار و تلاش نيستند درحالي که براي رسيدن به افقهاي بلند بايد همت بسيار و کار و تلاش پيدرپي داشت. Ahmadinejad's work, effort and other factors make up the Iran and said: Many people have horizons loudness but not from work and while trying to reach a long horizons should be much effort and work to Pydrpy found.
رييس دولت دهم با بيان اينکه جامعه کارگري در سه بخش همدلي، نگاه بلند و کار و تلاش پيشتاز و پيشگام است، تصريح کرد: در طول دوره انقلاب جامعه کارگري ما در همدلي ممتاز بوده است، بهطوري که در برههاي از زمان گروههاي وابسته به استکبار تلاش کردند در جامعه کارگري فاصله و اختلاف ايجاد کنند اما اين قشر از جامعه همواره به آنها پاسخ منفي و محکم داد. Head of government do with the expression of sympathy workers in three parts, looked up and work to express and Pioneer has emphasized: "During the Revolution of Our workers have been privileged in sympathy, so much so that the lambs from the time-dependent groups of arrogance community workers tried to create distance between segments of society, but they always gave a strong negative response.
احمدينژاد جامعه کارگري را از منسجمترين اقشاري دانست که در جهت خدمت و پيشرفت کشور فعاليت ميکنند و خاطرنشان کرد: جامعه کارگري در همه عرصههاي انقلاب در خط مقدم حرکت کرده است که اوج اين حرکت را در دوران هشت سال دفاع مقدس ديديم. Ahmadinejad Mnsjmtryn strata of society, workers knew that serve and advance the country working and noted: community workers in all fields of revolution has been at the forefront of moves that during the peak of this movement we saw eight years of sacred defense. بسياري از افراد جامعه کارگري به عنوان نيروي داوطلب به جبهه اعزام ميشدند. Many people labor community as volunteers were dispatched to the front. در بخش کار و تلاش هم اين قشر يک لحظه دست از کار و تلاش برنداشته است. In both segments of work to hand in a moment of work and effort has not taken.
وي با اشاره به اينکه بخش مهمي از پيشرفتهاي صنعتي و اقتصادي کشور ما مرهون جامعه کارگري است،بيان کرد: از همه کارگراني که با ابتکار و نوآوري خود موجب شدند هزينههاي بسياري در کشور کاهش يابد تشکر ميکنم و البته اين موفقيت از ايمان، تعهد، پاکي و دلسوزي جامعه کارگري برميآيد. He pointed out that an important part of industrial and economic progress of our country owes the community workers, stated: "all workers with initiative and innovation led to reduced costs in many countries and of course I thank the success of faith, commitment, Worker falls innocence and caring society.
رييسجمهوري درباره مسووليت دولت براي استفاده از ظرفيت کار در کشور خاطرنشان کرد: دولت بايد مقدمات استفاده از اين ظرفيت را فراهم کند. President about government responsibility for the use of labor capacity in the country noted: the primary use of this capacity should provide. همچنين پشتيبانيهاي لازم را انجام دهد که البته بخش عظيمي از اين مسووليت متوجه توليدکنندگان و خدماتدهندگان اعم از کارفرمايان و کارگران است. Pshtybanyhay also necessary to do that of course much of this responsibility and the producers noticed Khdmatdhndgan both employers and workers.
رييس دولت دهم خطاب به کارفرمايان تصريح کرد: همه ما براي ساختن ايران يک خانواده هستيم و با اعتقادات و فرهنگ کشور خود زندهايم. Head of State addressed to employers, I emphasized: "All of us are used to build a family of beliefs and cultures and their countries survive. در فرهنگ ما رسيدگي به حال کارگر بالاترين عبادت و موجب برکت کار است که اين موضوع را دنياي سرمايهداري درک نميکند. In our culture now working to address the highest blessing prayer and led the work on this issue does not understand the capitalist world. بنابراين با توجه به جامعه کارگري بايد موجب برکت شويد. Therefore, workers should lead society bless you.
احمدينژاد افزود: ما در دولت برکت را به خوبي ديدهايم. Ahmadinejad added: "We have seen the blessing as well. به عنوان مثال دولت در سال 88 حقوق کارمندان را 22 درصد، حقوق نيروهاي نظامي و انتظامي را 26 درصد و حقوق بازنشستگان را افزايش داد. For example, in the 88 to 22 percent of workers rights, rights of military and police and 26 percent pension increase. همچنين بخش قابل توجهي از بدهيهاي دولت به سازمان تامين اجتماعي را هم پرداخت کرد. Also, a significant portion of government debt to social security organization also paid. کارهاي عمراني بسياري هم انجام داد، يارانهها را هم کم نکرد اما هنگامي که تفاوت هزينه دولت در سال 88 را نسبت به سال 87 بررسي ميکنيم متوجه ميشويم خرج دولت تنها 2 درصد افزايش يافته است. Many also did construction work, too little subsidies but the difference did not cost the government 88 years than 87 years, we realize we will investigate government spending has increased only 2 percent. اين موضوع نشاندهنده برکت در کار دولت است. This work shows the blessing of government.
وي با انتقاد از کساني که بر شعار "دو بچه کافي است " تاکيد ميکردند، گفت: کساني هستند که فکر ميکنند ذخاير عالم به دست آنهاست، بنابراين از اينکه کسي سه بچه يا بيشتر داشته باشد ناراحت ميشوند و براي مردم قانون ميگذارند و ميگويند حق نداريد سه بچه داشته باشيد. He criticized those on the slogan "Two children are enough" would emphasize, he said: those who think the world of resources available to them, so that one or more children is Tuesday are upset and called for the law and put right Tuesday do not have kids.
رييسجمهور خطاب به اين افراد اظهار کرد: روزي فرزند را خداوند ميدهد. President addressed to the people remarked: One day the child of God. بنابراين اين شعار قابل قبول نيست. Thus, this slogan is not acceptable. حتي آنها موضوع فقر را براي اين شعار مطرح کردند اما خداوند در قرآن ميفرمايد: "از ترس فقر بچههاي خود را نکشيد، ما به آنها با شما روزي ميدهيم." Poverty issue even those raised for this slogan, but the Holy Qur'an states: "their children for fear of poverty, eg, we provided you give them."
احمدينژاد به مقايسه وضعيت مردم در سال 60 با سال 89 پرداخت و خاطرنشان کرد: در سال 60 در روستاها آب، برق و مخابرات نبود و در شهرها هم مردم با چند کوپن زندگي خود را ميگذراندند اما با اينکه امروز جمعيت 75 ميليون نفر يعني دوبرابر شده، وضع مردم بهتر شده است، بهطوري که ميزان دانشجويان کشور 10 برابر شده ، صنعت، کشاورزي و اختراع رشد قابل توجهي داشته است و بيمارستان و مدرسه ساخته شده.بنابراين رشد جمعيت موجب فقر مردم نشده است. Ahmadinejad compared the situation in 60 years with 89 years of payments and noted: in 60 rural water, electricity and telecommunications were also people in cities and a few coupons, but spent his life today that the 75 million population doubled , the situation has improved, so much so that the students of the country by 10 times, industry, agriculture and the invention has considerable growth and built hospitals and schools. Thus, population growth causes poverty, not people.
وي با اشاره به اجراي سياستهاي کنترلي جمعيت از سوي کشورهاي غربي بيان کرد: کشورهاي غربي سياستهايي را براي کنترل جمعيت خود اعمال کردند اما امروز رشد آنها منفي شده است. He pointed out the population control policies expressed by the Western countries: Western countries policies to control its population growth imposed, but today they are negative. بهطوري که از کشورهاي ديگر افراد را براي زندگي به کشور خود ميبرند که اين کار موجب از بين رفتن آن ملت خواهد شد. So much so that people from other countries for life to his country intended that this caused the loss of the nation will be.
رييس دولت دهم با اعلام اينکه جمعيت خانوار در کشور به زير چهار نفر رسيده است، تصريح کرد: تعداد بچههاي يک خانواده در کشور کمتر از دو نفر شده است، اين موجب سقوط يک ملت خواهد شد. Head of Government announced that the tenth of households in the country has been under four, asserted: the number of children in a family has less than two, this will cause the fall of a nation. متاسفانه کساني که شعار کنترل جمعيت را سرميدادند به نتيجه برعکس آن رسيدند. Unfortunately, those who control the slogan Srmydadnd population reached its contrary conclusion. زيرا امروز شاهد آن هستيم که مردم فقير فرزندان بيشتري دارند اما کساني که از امکانات خوبي برخوردارند فرزند کمتر دارند. Because today we are seeing that poor children have more opportunities for those who have a child less good.
رييسجمهوري در بخش ديگري از سخنان خود با تاکيد بر به روز کردن سيستمها و امکانات کار در کشور، خاطرنشان کرد: بايد با مديريت درست از هزينههاي اضافي کم کرد و البته سيستمها را بهروز کرد. President in another part of his speech with an emphasis on updating systems and facilities to work in the country, noted: it must properly manage the additional costs low, and of course, to update systems. همچنين بايد براي ابتکار عمل کارگران پاداشي تعيين شود. You should also reward the workers for the initiative to be determined.
احمدينژاد خطاب به کارگران گفت: در هر کجاي کشور که کار ميکنيد، به ثروت عمومي ملت ايران توجه داشته باشيد. Ahmadinejad addressed the workers said: "anywhere in the country you work, the general wealth of nations note. اگر بازدهي کار شما بالا باشد ميزان اين ثروت عمومي هم افزايش خواهد يافت. If your work is high level of efficiency this will increase the public wealth. بنابراين تا روزي که کار ميکنيد متعهد و دلسوز باشيد. So until the day you work you are committed and compassionate.
وي همچنين خطاب به وزير کار و امور اجتماعي ،اذعان کرد: فضاي کار کشور را به گونهاي اداره کنيد تا اختلافي پيدا نشود. He also addressed to the Minister of Labor and Social Affairs, acknowledged: the country's working environment can somehow manage to not be disputed. شما مامور انجام عدالت هستيد اما عدالت را طوري اجرا کنيد که به سمت جامعه کارگري برود. Your agent do you justice, but justice run so that the community workers go.
رييسجمهوري با انتقاد از فعاليت شرکتهاي ثالث براي تامين نيروي کار تصريح کرد: بايد نقش شرکتهاي ثالث در رابطه ميان کارگر و کارفرما از ميان برود تا منافع بيشتري به کارگران برسد. President criticized the activities of third party companies to provide workforce emphasized: should the role of third-party companies in the relationship between workers and employers eliminating benefits to reach more workers. البته ما چندينبار در دولت براي حل اين مشکل مصوباتي را ابلاغ کرديم اما بسياري از افراد از عملياتي شدن آن جلوگيري کردند. Of course, we Chndynbar government to solve this problem we have delivered Msvbaty but many people were prevented from its operations. البته با پيگيريهايي که انجام شد نشان داده که به غير از بخش حملونقل و فضاي سبز، بقيه بخشهاي دولت نقش شرکتهاي ثالث را براي تامين نيروي کار حذف کردند. Pygyryhayy course that was shown that except for transportation and green space sector, other government departments as third-party companies to provide workforce eliminated.
رييس دولت دهم با اشاره به اقدامات دولت براي حل مشکل بيمه کارگران ساختماني بيان کرد: اقدامات لازم براي حل اين مشکل انجام شده و به زودي وزير رفاه اين موضوع را ابلاغ خواهد کرد. I pointed to the head of government measures to solve the problem of building insurance, workers said: measures necessary to solve this problem done soon and welfare minister will deliver on this issue.
احمدينژاد همچنين بر پيگيري اختصاص سهام عدالت به کارگران تاکيد کرد و گفت: اين موضوع را پيگيري ميکنيم و حتما به نتيجه ميرسانيم. Ahmadinejad also follow up on the shares allocated to workers emphasized justice and said: "We followed up this issue and certainly the result of writing.
وي همچنين گفت: به بنياد نخبگان سفارش ميکنم که براي پذيرفتن ابداعات و اختراعات کارگران با مماشات بيشتري برخورد کند. He also said: "Foundation for the elite order that I accept the innovations and inventions workers to deal with the more appeasement.
سيام**9144**9170 Siam ** 9144 ** 9170

ليگ برتر

Head of the assessment exercise capital derby
"Ali Said Loo" the head of the Physical Education Organization said that "I hope worthy team won the derby capital in the current week."
Sixty right capital derby on Wednesday this week between the two most popular team independence and Perispolis will be held.
The game week in the framework of twenty-sixth premier league Soccer Iran clubs will be held.
The head of the Physical Education Organization on Monday in an interview with IRNA sports reporter also said: "I hope with observance of moral points and technical, every team that can be more appropriate in this meeting is to win.
سعیدلو said: the people of Iran Football to a good and I hope massrs 60 righth righth derby to echelon capital popular with spectators and more appropriate team to three points of the game of it.
He pointed out that in some cases sensitivity and characteristics of a special meeting, managers, technical staff and players to play cautiously and is the subject, to some extent the beauty of the soccer decreases.
The head of the sport of the country said: "I hope in this game, Susceptivity s by the yearneth.
Said Loo stressed that the president of the football federation and two club and Perispolis independence have said that people understand football. By maintaining fair play and observance of moral dimensional on technical issues to focus in the end of this game proud.
8071

At the end news/Islamic Republic news agency (IRNA)/news code 930038
View Database Structure Using C# PDF Print E-mail
Written by مدیر کل سایت   
Thursday, 18 February 2010 15:03
There are no translations available.

DBSpy

Introduction

This article describes an easy approach to examining all of the tables, views, and columns in a database. The article is written to describe an example application that may be used to connect to a database (Oracle, SQL Server, or Microsoft Access), view that database’s tables and views, and drill down into each table or view to generate a list of all of its contained columns. Further, the application will allow the user to examine the definition associated with each column (e.g. its data type, caption, default value, etc.) through a context menu option.

The application does not serve any particular purpose and has only a few key methods associated with it. Whilst the application does not perform any sort of useful task, the application could be used to form the basis for some useful tool, such as one that would map the fields in one database table to the fields in another database table, or it could be used as the basis for a tool that allowed a user to formulate an ad hoc query using a developer defined query builder.

Figure 1: The demonstration application running.
Figure 2: Pulling up information on a specific field.

Getting Started

In order to get started, unzip the included project and open the solution in the Visual Studio 2005 environment. In the solution explorer, you should note these significant files:

  • frmDataDisplay.cs: Containing the main application and most of the code.
  • frmConnect.cs: Containing a dialog used to connect to a database.

Application Properties

The application properties are used to store elements of the connection string as well as the connection string itself. In the project, open up the properties and select the settings tab to see the collection of properties used in this application. The scope of each property is set to “User” which will allow application users to set and save the properties between uses of the application. Each value is set to temp initially. The property names describe the purpose of each specific property; for example ConnString, as you can probably guess, is used to hold the connection string property.

Figure 3: Application Properties.

Connection Dialog

The connection dialog is contained in frmConnect.cs; this dialog is used to capture the variables necessary to create a viable connection to an Oracle, SQL Server, or Microsoft Access database. The dialog contains a tabbed pane with three panels, one for each connection type. Each panel contains all of the controls necessary to generate a connection. The user may test the connections from this dialog, and once the user accepts the dialog, the connection information will be persisted and made available to the application.

Figure 4: Connection Dialog with SQL Server Options Displayed.

The code is pretty simple, if you'd care to open the code view up in the IDE, you will see that the code file begins as follows:

Collapse
using System;
using System.Collections;
using System.Configuration;
using System.ComponentModel;
using System.Data;
using System.Data.OleDb;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

The class begins with the import of the required libraries; most notably the System.Data and System.Data.OleDb libraries are required to interact with the three database types used by the application (Oracle, Access, and SQL Server).

Following the imports, the namespace and class are defined and a default constructor added.

Collapse
namespace DBSpy
{
public partial class frmConnect : Form

{
/// <summary />

/// Default constructor

/// </summary />

public frmConnect()

{
InitializeComponent(); }

Next up is the button click event handler for the button used to save a defined connection to an Oracle database as property settings made available across the application. The handler saves all of the user defined elements of the connection string as well as the formatted connection string itself and also tests the connection string to make sure that it works. The code is annotated to describe what is happening in each section of the code.

Collapse
/// <summary />
/// Store the Oracle settings and test the connection
/// string
/// </summary />
/// <param name="sender" /></param />
/// <param name="e" /></param />
private void btnOracleOK_Click(object sender, EventArgs e)
{
// Future use; if a current data model and database

// type need to be identified and saved with the connect

// string to identify its purpose

Properties.Settings.Default.CurrentDataModel = "MyOracle";

Properties.Settings.Default.CurrentDatabaseType = "Oracle";

// Set the actual connection string properties into

// the application settings

Properties.Settings.Default.ProviderString =

txtOracleProvider.Text;
lt.Password = txtOraclePassword.Text; Properties.Settings.Defa
Properties.Settings.Defa
uult.UserID = txtOracleUserID.Text;
erName = txtOracleDBname.Text;
Properties.Settings.Default.Ser
v// Set the connection string
Properties.Settings.Default.ConnString = "Provider=" +
Properties.Settings.Default.ProviderString +
";Password=" +
Properties.Settings.Default.Password +
";User ID=" +
Properties.Settings.Default.UserID +
";Data Source=" +
Properties.Settings.Default.ServerName;
// Save the property settings

Properties.Settings.Default.Save();

//Test Connection

if (Properties.Settings.Default.ConnString != string.Empty)

{
using (OleDbConnection conn = new

OleDbConnection(Properties.Settings.Default.ConnString))

{
try

{

// test with an open attempt
conn.Open();
this.Dispose();
}
catch (Exception ex)
{
// if the connection fails, inform the user

// so they can fix the properties

MessageBox.Show(ex.Message, "Connection Error");

}

}
}
}

The next section of the code is used to handle the Oracle connection string test; even though attempts to save the connection properties also tests the connection, this method is made available to allow the user to test a connection and view whether or not the connection string passes. Again, the code is annotated to describe each section of the code.

Collapse
/// <summary />
/// Test the Oracle Connection String
/// </summary />
/// <param name="sender" /></param />
/// <param name="e" /></param />
private void btnOracleTest_Click(object sender, EventArgs e)
{
try

{

// Future use; if a current data model and database
// type need to be identified and saved with the connect
// string to identify its purpose
Properties.Settings.Default.CurrentDataModel = "MyOracle";
Properties.Settings.Default.CurrentDatabaseType = "Oracle";
// Set the actual connection string properties into

// the application settings

Properties.Settings.Default.ProviderString =

txtOracleProvider.Text;
lt.Password = txtOraclePassword.Te
Properties.Settings.Defa
uxt; Properties.Settings.Default.UserID = txtOracleUserID.Text;
.Text;
Properties.Settings.Default.ServerName = txtOracleDBnam
e// Set the connection string
Properties.Settings.Default.ConnString = "Provider=" +
Properties.Settings.Default.ProviderString +
";Password=" +
Properties.Settings.Default.Password +
";User ID=" +
Properties.Settings.Default.UserID +
";Data Source=" +
Properties.Settings.Default.ServerName;
// Save the property settings

Properties.Settings.Default.Save();

}
catch (Exception ex)

{
MessageBox.Show(ex.Message, "Error saving connection

information.");

}

//Test Connection

if (Properties.Settings.Default.ConnString != string.Empty)

{
using (OleDbConnection conn = new

OleDbConnection(Properties.Settings.Default.ConnString))

{
try

{

// test the connection with an open attempt
conn.Open();
MessageBox.Show("Connection attempt successful.",
"Connection Test");
}
catch (Exception ex)
{
// inform the user if the connection fails

MessageBox.Show(ex.Message, "Connection Error");

}

}
}
}

The next method is merely used to close the form if the user decides to cancel the operation.

Collapse
/// <summary />
/// Close the form
/// </summary />
/// <param name="sender" /></param />
/// <param name="e" /></param />
private void btnOracleCancel_Click(object sender, EventArgs e)
{
this.Dispose();


}

The next bit of code handles the check changed event for the integrated security check box control found on the SQL Server tab. If the control is checked, the user name and password are not used and the connection string will be formatted to use integrated security.

Collapse
/// <summary />
/// SQL Server
/// Configure for the use of integrated
/// security
/// </summary />
/// <param name="sender" /></param />
/// <param name="e" /></param />
private void cbxIntegratedSecurity_CheckedChanged(object sender,
EventArgs e)
{
// if the user has checked the SQL Server connection

// option to use integrated security, configure the

//user ID and password controls accordingly

if (cbxIntegratedSecurity.Checked == true)

{

txtSqlServerUserID.Text = string.Empty;
txtSqlServerPassword.Text = string.Empty;
txtSqlServerUserID.Enabled = false;

txtSqlServerPassword.Enabled = false;

}

else
{
txtSqlServerUserID.Enabled = true;
txtSqlServerPassword.Enabled = true;
}
}

The next event handler closes the form if the user decides to cancel the operation.

Collapse
/// <summary />
/// Close the form
/// </summary />
/// <param name="sender" /></param />
/// <param name="e" /></param />
private void btnSQLserverCancel_Click(object sender, EventArgs e)
{
this.Dispose();


}

The next section of code is used to test the SQL Server connection string; it functions much the same as does the Oracle connection test with the only exception being that it formats the connection string differently based upon the user’s selection of the Use Integrated Security check box control.

Collapse
/// <summary />
/// Test the SQL Server connection string
/// based upon the user supplied settings
/// </summary />
/// <param name="sender" /></param />
/// <param name="e" /></param />
private void btnSqlServerTest_Click(object sender, EventArgs e)
{
try

{

// Future use; if a current data model and database
// type need to be identified and saved with the connect
// string to identify its purpose
Properties.Settings.Default.CurrentDataModel = "MySqlServer";
Properties.Settings.Default.CurrentDatabaseType =
"SqlServer";
// Set the properties for the connection string

Properties.Settings.Default.ProviderString =

txtSqlServerProvider.Text;
word = txtSqlServerPassword.Text;
Properties.Settings.Default.Pas
s Properties.Settings.Default.UserID = txtSqlServerUserID.Text;
erDBName.Text; Properties.Settings.Defau
Properties.Settings.Default.ServerName = txtSqlSer
vlt.InitialCatalog = txtSqlServerInitialCat.Text;
// configure the connection string based upon the use

// of integrated security

if (cbxIntegratedSecurity.Checked == true)

{

Properties.Settings.Default.ConnString =
"Provider=" +
Properties.Settings.Default.ProviderString +
";Data Source=" +
Properties.Settings.Default.ServerName +
";Initial Catalog=" +
Properties.Settings.Default.InitialCatalog +
";Integrated Security=SSPI;";
}
else
{
Properties.Settings.Default.ConnString =
"Provider=" +
Properties.Settings.Default.ProviderString +
";Password=" + Properties.Settings.Default.Password +
";User ID=" + Properties.Settings.Default.UserID +
";Data Source=" +
Properties.Settings.Default.ServerName +
";Initial Catalog=" +
Properties.Settings.Default.InitialCatalog;
}
// Save the property settings

Properties.Settings.Default.Save();

}
catch (Exception ex)

{
// inform the user if the connection was not saved

MessageBox.Show(ex.Message, "Error saving connection

information.");

}

//Test Connection

if (Properties.Settings.Default.ConnString != string.Empty)

{
using (OleDbConnection conn = new

OleDbConnection(Properties.Settings.Default.ConnString))

{
try

{

// test the connection with an open attempt
conn.Open();
MessageBox.Show("Connection Attempt Successful.",
"Connection Test");
}
catch (Exception ex)
{
// inform the user if the connection test failed

MessageBox.Show(ex.Message, "Connection Test");

}

}
}
}

The following event handler sets the connection string and tests the SQL Server connection as defined by the user’s entries into the form.

Collapse
private void btnSqlServerOK_Click(object sender, EventArgs e)
{
try

{

// Future use; if a current data model and database
// type need to be identified and saved with the connect
// string to identify its purpose
Properties.Settings.Default.CurrentDataModel = "MySqlServer";
Properties.Settings.Default.CurrentDatabaseType =
"SqlServer";
// Set the properties for the connection

Properties.Settings.Default.ProviderString =

txtSqlServerProvider.Text;
word = txtSqlServerPassword.Text;
Properties.Settings.Default.Pas
s Properties.Settings.Default.UserID = txtSqlServerUserID.Text;
erDBName.Text; Properties.Settings.Defau
Properties.Settings.Default.ServerName = txtSqlSer
vlt.InitialCatalog = txtSqlServerInitialCat.Text;
// configure the connection string based upon

// the use of integrated security

if (cbxIntegratedSecurity.Checked == true)

{

Properties.Settings.Default.ConnString =
"Provider=" +
Properties.Settings.Default.ProviderString +
";Data Source=" +
Properties.Settings.Default.ServerName +
";Initial Catalog=" +
Properties.Settings.Default.InitialCatalog +
";Integrated Security=SSPI;";
}
else
{
Properties.Settings.Default.ConnString =
"Provider=" +
Properties.Settings.Default.ProviderString +
";Password=" + Properties.Settings.Default.Password +
";User ID=" + Properties.Settings.Default.UserID +
";Data Source=" +
Properties.Settings.Default.ServerName +
";Initial Catalog=" +
Properties.Settings.Default.InitialCatalog;
}
// Save the property settings

Properties.Settings.Default.Save();

}
catch (Exception ex)

{
// inform the user if the connection information was not

// saved

MessageBox.Show(ex.Message, "Error saving connection

information.");

}

//Test Connection

if (Properties.Settings.Default.ConnString != string.Empty)

{
using (OleDbConnection conn = new

OleDbConnection(Properties.Settings.Default.ConnString))

{
try

{

// test the connection with an open attempt
conn.Open();
this.Dispose();
}
catch (Exception ex)
{
// inform the user if the connection was not saved

MessageBox.Show(ex.Message, "Connection Test");

}

}
}
}

The next event handler closes the form if the user decides to cancel the operation.

Collapse
/// <summary />
/// Close the form
/// </summary />
/// <param name="sender" /></param />
/// <param name="e" /></param />
private void btnAccessCancel_Click(object sender, EventArgs e)
{
this.Dispose();


}

This event handler is used to open an Open File dialog used to allow the user to navigate to and select an Access database.

Collapse
/// <summary />
/// Browse for an access database
/// </summary />
/// <param name="sender" /></param />
/// <param name="e" /></param />
private void btnBrowse_Click(object sender, EventArgs e)
{
OpenFileDialog openFile = new OpenFileDialog();

openFile.Title = "MS Access Database";

openFile.DefaultExt = "mdb";

openFile.Filter = "Access Database (*.mdb)|*mdb";

openFile.ShowDialog();

txtAccessDBname.Text = openFile.FileName;
}

The next bit of code is used to test a connection to an Access database.

Collapse
/// <summary />
/// Test a Microsoft Access database connection
/// </summary />
/// <param name="sender" /></param />
/// <param name="e" /></param />
private void btnAccessTest_Click(object sender, EventArgs e)
{
try

{

// Future use; if a current data model and database
// type need to be identified and saved with the connect
// string to identify its purpose
Properties.Settings.Default.CurrentDataModel = "MyAccess";
Properties.Settings.Default.CurrentDatabaseType = "Access";
// Set the access database connection properties

Properties.Settings.Default.ProviderString =

txtAccessProvider.Text;
assword = txtAccessPassword.Text;
Properties.Settings.Default.
P Properties.Settings.Default.UserID = txtAccessUserID.Text;
ssDBname.Text;
Properties.Settings.Default.ServerName = txtAcc
e// Set the access database connection string
Properties.Settings.Default.ConnString = "Provider=" +
Properties.Settings.Default.ProviderString +
";Password=" +
Properties.Settings.Default.Password +
";User ID=" +
Properties.Settings.Default.UserID +
";Data Source=" +
Properties.Settings.Default.ServerName;
// Save the properties

Properties.Settings.Default.Save();

}
catch (Exception ex)

{
// inform the user if the connection could not be saved

MessageBox.Show(ex.Message, "Error saving connection

information.");

}

//Test Connection

if (Properties.Settings.Default.ConnString != string.Empty)

{
using (OleDbConnection conn = new

OleDbConnection(Properties.Settings.Default.ConnString))

{
try

{

// test the connection with an open attempt
conn.Open();
MessageBox.Show("Access connection test successful",
"Connection Test");
}
catch (Exception ex)
{
// inform the user if the connection failed

MessageBox.Show(ex.Message, "Connection Error");

}

}
}
}

The next event handler is used to persist and test a connection string for a Microsoft Access database.

Collapse
/// <summary />
/// Persist and test an Access database connection
/// </summary />
/// <param name="sender" /></param />
/// <param name="e" /></param />
private void btnAccessOK_Click(object sender, EventArgs e)
{
try

{

// Future use; if a current data model and database
// type need to be identified and saved with the connect
// string to identify its purpose
Properties.Settings.Default.CurrentDataModel = "MyAccess";
Properties.Settings.Default.CurrentDatabaseType = "Access";
// Set the access database connection properties

Properties.Settings.Default.ProviderString =

txtAccessProvider.Text;
lt.Password = txtAccessPassword.Te
Properties.Settings.Defa
uxt; Properties.Settings.Default.UserID = txtAccessUserID.Text;
name.Text;
Properties.Settings.Default.ServerName = txtAccessD
B// Set the access database connection string
Properties.Settings.Default.ConnString = "Provider=" +
Properties.Settings.Default.ProviderString +
";Password=" +
Properties.Settings.Default.Password +
";User ID=" +
Properties.Settings.Default.UserID +
";Data Source=" +
Properties.Settings.Default.ServerName;
// Save the properties

Properties.Settings.Default.Save();

}
catch (Exception ex)

{
// Inform the user if the connection was not saved

MessageBox.Show(ex.Message, "Error saving connection

information.");

}

//Test Connection

if (Properties.Settings.Default.ConnString != string.Empty)

{
using (OleDbConnection conn = new

OleDbConnection(Properties.Settings.Default.ConnString))

{
try

{

// test the database connection string with an open
// attempt
conn.Open();
this.Dispose();
}
catch (Exception ex)
{
// inform the user if the connection failed

MessageBox.Show(ex.Message, "Connection Error");

}

}
} }
} }

The Data Display Form

The main application is contained in the frmDataDisplay.cs class. This form is used to gain access to the connection dialog, and to load the database information into the form’s controls. The form is structured with a menu at the top; this menu contains the options to exit the application, to create a new connection, to view the current connection, and to load the schema information for the current database associated with the connection.

In the main area of the form, there are three group boxes, one contains a list box control used to display the tables contained in the current database, one contains a list box control used to display the views contained in the current database, and one contains a list box used to display the columns contained in any view or table selected from the table or view list box controls.

Figure 5: The Main Form with an SQL Server Connection Active.

The class starts out with the following code used to import the required libraries:

Collapse
using System;
using System.Collections;
using System.Configuration;
using System.ComponentModel;
using System.Data;
using System.Data.OleDb;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

The next section of code declares the namespace, some local variables, and the default constructor. The array lists are used to contain the views and tables displayed on this form.

Collapse
namespace DBSpy
{
public partial class frmDataDisplay : Form

{
#region Declarations
public string mSelectedTable;

private bool mTableSelected;

ArrayList arrViews;

ArrayList arrTables;
#endregion
/// <summary />

/// default constructor

/// </summary />

public frmDataDisplay()

{
InitializeComponent(); }

The next section of code defines a method used to capture and store the table and view names for the database identified by the connection string. The schema is stored in a data table populated with the results of calling the connection’s GetOleDbSchemaTable method. This method is called twice; once to obtain the list of views and once to obtain the list of tables; these items are then added to new instances of the array lists used to hold the view and table lists. The code is annotated and should be pretty straight forward.

Collapse
/// <summary />
/// Populate to arrays with list of all of the tables and views used
/// in the database defined by the current connection string
/// </summary />
public void StoreTableAndViewNames()
{
// temporary holder for the schema information for the current

// database connection

DataTable SchemaTable;

// used to hold a list of views and tables

arrViews = new ArrayList();

arrTables = new ArrayList();

// clean up the menu so the menu item does not

// hang while this function executes

this.Refresh();

// make sure we have a connection

if (Properties.Settings.Default.ConnString != string.Empty)

{
// start up the connection using the current connection

// string

using (OleDbConnection conn = new

OleDbConnection(Properties.Settings.Default.ConnString))

{
try

{

// open the connection to the database
conn.Open();
// Get the Tables

SchemaTable =

conn.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, new
Object[] { null, null, null, "TABLE" });
// Store the table names in the class scoped array

// list of table names

for (int i = 0; i < SchemaTable.Rows.Count; i++)

{
arrTables.Add(SchemaTable.Rows[i].

ItemArray[2].ToString());
}
// Get the Views

SchemaTable =

conn.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, new
Object[] { null, null, null, "VIEW" });
// Store the view names in the class scoped array

// list of view names

for (int i = 0; i < SchemaTable.Rows.Count; i++)

{
arrViews.Add(SchemaTable.Rows[i].

ItemArray[2].ToString());
}
}
catch (Exception ex)

{
// break and notify if the connection fails

MessageBox.Show(ex.Message, "Connection Error");

}

}
}
}

The next method is used to close the main form and terminate the application.

Collapse
/// <summary />
/// Close the form
/// </summary />
/// <param name="sender" /></param />
/// <param name="e" /></param />
private void CloseToolStripMenuItem_Click(object sender, EventArgs e)
{
// dispose of this form

this.Dispose();


}

The next method is used to create an instance of the connection form. Once displayed, the user may define a new connection string.

Collapse
/// <summary />
/// Open a new connection to a database - present the connection
/// string builder
/// form so the user can define a connection
/// </summary />
/// <param name="sender" /></param />
/// <param name="e" /></param />
private void OpenANewConnectionToolStripMenuItem_Click(object sender, EventArgs e)
{
// open an instance the connect form so the user

// can define a new connection

frmConnect f = new frmConnect();

f.Show();
}

This method is used to display the value stored for the connection string in the application’s settings

Collapse
/// <summary />
/// Display the current connection string to the user
/// </summary />
/// <param name="sender" /></param />
/// <param name="e" /></param />
private void ViewCurrentConnectionToolStripMenuItem_Click(object sender, EventArgs e)
{
// display the current connection string

MessageBox.Show(Properties.Settings.Default.ConnString, "Current Connection");


}

Based upon the current connection string, this method will recover the tables and views for the current database connection and will display those items in the form’s table and view list view controls.

Collapse
/// <summary />
/// Get and display the current tables and views contained in the
/// database
/// pointed to by the connection string
/// </summary />
/// <param name="sender" /></param />
/// <param name="e" /></param />
private void LoadDataForCurrentConnectionToolStripMenuItem_Click
(object sender,EventArgs e)
{
// get tables and views

StoreTableAndViewNames();

// clear internal lists

lstTables.Items.Clear();

lstViews.Items.Clear();
// update the lists from the arrays holding the

// tables and views

lstTables.Items.AddRange(arrTables.ToArray());

lstViews.Items.AddRange(arrViews.ToArray());
}

The next method will display the list of columns displayed for the last selected table.

Collapse
private void lstTables_SelectedIndexChanged(object sender, EventArgs e)
{
mTableSelected = true;

string tblName;

try

{

tblName = lstTables.SelectedItem.ToString();
}
catch

{

return;
}
// make sure we have a connection

if (Properties.Settings.Default.ConnString != string.Empty)

{
// start up the connection using the current connection

// string

using (OleDbConnection conn = new

OleDbConnection(Properties.Settings.Default.ConnString))

{
try

{

// open the connection to the database
conn.Open();
lstFields.Items.Clear();
DataTable dtField =
maTable(OleDbSchemaGuid.Columns, new
conn.GetOleDbSch
e
object[] { null, null, tblName });

foreach (DataRow dr in dtField.Rows)

{

lstFields.Items.Add(dr["COLUMN_NAME"].ToString());
}
}
catch (Exception ex)

{
MessageBox.Show(ex.Message, "Connection Error");

}

}
}
else
{
MessageBox.Show("There is no connection string current defined.",
"Connection String");
}
}

The next method will display the list of columns displayed for the last selected view.

Collapse
private void lstViews_SelectedIndexChanged(object sender, EventArgs e)
{
mTableSelected = false;

string tblName;

try

{

tblName = lstViews.SelectedItem.ToString();
}
catch

{

return;
}
// make sure we have a connection

if (Properties.Settings.Default.ConnString != string.Empty)

{
// start up the connection using the current connection

// string

using (OleDbConnection conn = new

OleDbConnection(Properties.Settings.Default.ConnString))

{
try

{

// open the connection to the database
conn.Open();
lstFields.Items.Clear();
// get the schema table

DataTable dtField =

conn.GetOleDbSchemaTable(OleDbSchemaGuid.Columns, new
object[] { null, null, tblName });
// read the column names into the fields list

foreach (DataRow dr in dtField.Rows)

{

lstFields.Items.Add(dr["COLUMN_NAME"].ToString());
}
}
catch (Exception ex)

{
MessageBox.Show(ex.Message, "Connection Error");

}

}
}
else
{
MessageBox.Show("There is no connection string current defined.",
"Connection String");
}
}

This method will display the field information associated with the last selected column for the last selected view or table.

Collapse
/// <summary />
/// Collect and display the field information for a selected column
/// name
/// </summary />
/// <param name="sender" /></param />
/// <param name="e" /></param />
private void GetFieldInformationToolStripMenuItem_Click(object sender, EventArgs e)
{
try

{

using (OleDbConnection conn = new
OleDbConnection(Properties.Settings.Default.ConnString))
{
string sSql = string.Empty;

if (mTableSelected == true)

{

sSql = "SELECT [" +
lstFields.SelectedItem.ToString().Trim() + "] FROM ["
+ lstTables.SelectedItem.ToString().Trim() + "]";
}
else
{
sSql = "SELECT [" +
lstFields.SelectedItem.ToString().Trim() + "] FROM ["
+ lstViews.SelectedItem.ToString().Trim() + "]";
}
OleDbCommand cmd = new OleDbCommand(sSql, conn);

conn.Open();
rdr = cmd.Execut
OleDbDataReade
reReader(CommandBehavior.KeyInfo);
rdr.GetSchemaTable(); StringBuilder sb =
DataTable schemaTable
=new StringBuilder();
foreach (DataRow myField in schemaTable.Rows)

{
foreach (DataColumn myProperty in schemaTable.Columns)

{
sb.Append(myProperty.ColumnName + " = " +

myField[myProperty].ToString() +

Environment.NewLine);
}
// report
MessageBox.Show(sb.ToString(), "Field Information");
// burn the reader

rdr.Close();

// exit

return;

}

}
}
catch
{
MessageBox.Show("Unable to attach to this table with current
user; check database security permissions.", "Field
Information");
}
}
}
}

Summary

This application is intended to demonstrate one approach to building an application capable of viewing the contents of a database dynamically and based strictly upon making a connection to either a Microsoft Access, Oracle, or SQL Server database. It is not the only way to accomplish this task, it is just one way to do it. You can easily modify the approach to use other connection types, or to add new connection types, and you can modify the application to display information that I did not address in this demonstration.

About the Author

salysle


Member

Occupation: Software Developer (Senior)
Location: United States United States
 

Pictures Products

Newsletter

Newsletter with the latest content and changes to your site simply aware










Advertise

poll

IR-WIN site to see how
 

Calendar

 
Friday
2010
Sep
10
 

latest news IT

Satellite, overcoming gravity to ascend hoisted on the sky

confidence-building and satellite, driving engine for the development of other advanced regards is considered to be on the other shows and scientific management can be up in the countries of this technology.

 

According to IRNA, Iranian success researchers hope the satellite with the satellite 2 ambassador last year in the first practical step in its native space technology is considered to be able to name of Iran in the few member countries registered world space club.
Also this year with the unveiling of the national satellite television station, national Mesbah 2 satellite and satellite promise of Science and Industry and also the engine satellite Simurgh that day 14 February with the national day was done space technology, ground for presence of Iran in the arena space has been provided.
Satellite rise can be three years to remain in space, 100 kilograms and height in orbit 500 miles from the ground. The Satellite "Simurgh" You can also shipments weighing 100 kilograms in height 500 km from the earth.
according to experts, for Satellite is necessary many sciences and arts beside each other to such a project to be enforced.
***A satellite how to throw the circuit.
To put to a satellite in orbit of the earth, the force is needed for a lot. This force, ماهواره‌بر (carrying missiles) production. Satellite to be in orbit in high altitude more than 200 miles from the earth's surface above the speed of 29000 kilometers per hour.
Satellite ‌بر‌ها missiles to form a stage, with chemical burning fuel. . .
Read more...
Copyright © 2010 سیستم عامل جدید ایرانیان v2.88. All Rights Reserved.
ChakadCo! CopyRight & PowerBy GNU/GPL License.