DdoubleD 315 Posting Shark

Check the command text/query pass into the SqlCommand , which is what it is complaining about, but error doesn't show until you execute the command with ExecuteNonQuery :

//
        // Summary:
        //     Initializes a new instance of the System.Data.SqlClient.SqlCommand class
        //     with the text of the query and a System.Data.SqlClient.SqlConnection.
        //
        // Parameters:
        //   cmdText:
        //     The text of the query.
        //
        //   connection:
        //     A System.Data.SqlClient.SqlConnection that represents the connection to an
        //     instance of SQL Server.
        public SqlCommand(string cmdText, SqlConnection connection);
DdoubleD 315 Posting Shark

Not a problem! Please mark as solved--thanks!

DdoubleD 315 Posting Shark

Problem is that in your string ("22.925507, 0.0000000, 0.0000000, "), the Split has created a last item equal to a " " (space char), which the Convert.ToDouble(" ") yields the exception.

To correct, remove the trailing (last) comma.

As an alternative, change line 20 (or similar check for spaces) to be:

if (num != null && num.Trim().Length > 0)

You might also want to put your index increment for numline ("i++") to be inside the if block so it only gets incremented when your num is actually put into the numline array:

if (num != null && num.Trim().Length > 0)
                    {
                        numline[i] = Convert.ToDouble(num);
                        i++;
                    }
DdoubleD 315 Posting Shark

Sorry, I got distracted before I could correct the last post... This should work:

public static void Test()
        {
            int[] intAry = { 1, 2, 3 };
            string[] strAry = { "1", "2", "3" };
            double[] dblAry = { 1.0, 2.0, 3.0 };
            ProcessArrays(intAry, strAry, dblAry);
        }
        public static void ProcessArrays(params object[] v)
        {
            // for each array in variable arguments...
            foreach (Array ary in v)
            {
                // for each item in this array...
                foreach (object o in ary)
                {
                    Console.Write(o);
                    Console.Write(",");
                }
                // Separate each array with newline:
                Console.WriteLine();
            }
        }
DdoubleD 315 Posting Shark

?Is it possible to use it to pass an unspecified number of arrays of objects?
Yes you can do this.

void methodName(params object []v){
   ...
  }

adatapost pretty much gave you the way to do this. Here is an example of manipulating the variable arguments of object should you pass a variable number of arrays:

void methodName(params object[] v)
        {
            // treat each (variable) argument as an array...
            foreach (object[] ary in v)
            {
                // process the current array argument...
                foreach (object o in ary)
                {
                    Console.Write(o);
                    Console.Write(","); // delimiter for each item "o" in array...
                }
                // Separate each array with newline:
                Console.WriteLine();
            }
        }

I didn't actually test the above code, but it does compile.

EDIT: there is a casting exception with the above....

DdoubleD 315 Posting Shark

You can try the following link , it shows the basics of sending date paramter to Crystal Reports in C#.

http://csharp.net-informations.com/crystal-reports/csharp-crystal-reports-date-parameter.htm

Follow the link yang gave you above. I would:
1) create two date parameter fields for the begin and end dates, then
2) use the Record Selection Formula Editor to create a "Comparisons" selection criteria based on the DB date Field and the two params from step 1, then
3) set the date parameters from your c# code at runtime:

public static void SetParameterDescreteValue(ReportDocument crDoc, string paramFieldName, object discreteValue)
            {
                // Retrieve the parameber field we are setting...
                ParameterFieldDefinition crParamField = crDoc.DataDefinition.ParameterFields[paramFieldName];

                // Create an object type crystal understands to pass in the value...
                ParameterDiscreteValue crParamDiscreteValue = new ParameterDiscreteValue();
                crParamDiscreteValue.Value = discreteValue;

                // create a new collection of parameter values and add value passed in...
                ParameterValues crParamValues = new ParameterValues();
                crParamValues.Add(crParamDiscreteValue);

                // finally, set the parameter's new value collection...
                crParamField.ApplyCurrentValues(crParamValues);
            }

The code in the link yang gave will do the job, but I compacted what I needed into the method above, which you can call once each for begin and end dates. I have not tested it with anything but string objects passed in, but I think it should be fine with dates too.

Cheers!

DdoubleD 315 Posting Shark

When does this error happen? Are you catching the MySqlException?

private static string BuildConnectionStr(string server, string db, string user, string pwd)
        {
            return string.Format(connParams, server, db, user, pwd);
        }

        const string connParams = "Data Source={0};;database={1};username={2};password={3}";

        public static MySqlConnection MySqlConnectionExample()
        {
            string server = "LOCALHOST";// if local machine...
            string database = "YOUR CATALOG NAME"; // catalog name...
            string user = "YOUR USERNAME";
            string pwd = "YOUR PASSWORD";

            string connStr = BuildConnectionStr(server, database, user, pwd);

            MySqlConnection conn = new MySqlConnection(connStr);

            try
            {
                conn.Open();
            }
            catch (MySqlException ex)
            {
                Console.WriteLine("Exception: {0}\r\n   Stack Trace: {1}", ex.Message, ex.StackTrace);
            }
            
            return conn;
        }
DdoubleD 315 Posting Shark

If you intend to parse or convert the byte[] into its string equivalents, the StreamWriter should work fine as long as long as it does not need to be thread safe. For thread safety, look at TextWriter .

If you just want to write the byte[] to a file, look at FileStream class.

If you intend to parse the byte[] array into various types, consider using the BinaryWriter class.

Geekitygeek commented: clear and concise :) +1
DdoubleD 315 Posting Shark

I'll take a peek at that link. What kind of output are you expecting from this library? Does it already write the output to a file?

DdoubleD 315 Posting Shark

I tested that code to insert the sheet data into the Access table, and I didn't find a problem with it. I made some minor modifications to make it a little more flexible and to provide a more accurate error message on failure.

This method combines the SELECT from the Excel sheet and INSERT into the Access table into one command:

public static void ImportSpreadsheet(string fileName, string sheetName)
            {
                string excelConnStr = "Provider=Microsoft.Jet.OLEDB.4.0;"
                    + @"Data Source=" + fileName + ";"
                    + "Extended Properties=Excel 8.0;";

                // set the Access table name to import the sheet into...
                string tableName = sheetName;

                using (OleDbConnection conn = new OleDbConnection(excelConnStr))
                {
                    try
                    {
                        conn.Open();

                        using (OleDbCommand cmd = new OleDbCommand())
                        {
                            cmd.CommandText = @"SELECT * INTO [MS Access;Database="
                                + accessDatabase + "].["
                                + tableName + "] FROM ["
                                + sheetName + "$]";

                            cmd.Connection = conn;

                            cmd.ExecuteNonQuery();
                        }
                    }
                    catch (DbException ex)
                    {
                        Console.WriteLine("Exception: {0}\r\n   Stack Trace: {1}", ex.Message, ex.StackTrace);
                    }
                    finally
                    {
                        conn.Close();
                    }
                }
            }

Give it a try and mark the thread as solved if there is no problem.

DdoubleD 315 Posting Shark

The first thing you need is a database--do you have one? Then, you need to build a proper connection string to connect to it with: http://www.connectionstrings.com/. How you proceed from here depends on the database type, but the basic, most common stuff, involves:

1) Opening a connection
2) Building a SQL command
3) Executing the command

There are infinite examples on the web, but if you cannot find some really "basic" examples for your database type, let us know what DB you are using and I'm sure we can point you to a few.

Cheers!

ddanbe commented: informative +5
DdoubleD 315 Posting Shark

Good morning avirag (for me at least). Things are never quick and easy with you my friend. Anyway...

I wrote an ADO COM interface earlier this morning to dynamically build the Access table from a DataTable that I loaded from my spreadsheet data using the method I supplied you with yesterday. Typical morning of fun for me I suppose because I hand't tried doing this with ADO COM before. I already have a database wrapper that builds the SQL commands dynamically to do this, but I was curious about any shortcuts using ADO COM. I got it to work with a few field types, but for it to be complete, I would need to build a wrapper around it too. So, I decided to further my search...

While beginning a search to find other ways this could be done, I found that code you are using to create your Access database in your example code you gave:

Link: http://www.dotnetspider.com/forum/187304-Using-C-how-import-excel-file-into-ms-access-database-dynamic-table.aspx

Remaining code from link you are missing in your example code:

OleDbCommand _command = new OleDbCommand();

                _command.Connection = _connection;

                try
                {

                    _command.CommandText = @"SELECT * INTO [MS Access;Database=C:\Book.mdb].[Sheet1] FROM [Sheet1$]";

                    _connection.Open();

                    _command.ExecuteNonQuery();

                    _connection.Close();

                    MessageBox.Show("The import is complete!");

                }

                catch (Exception)
                {

                    MessageBox.Show("Import Failed, correct Column name in the sheet!");
                }

Why didn't you use that remaining code to SELECT the SHEET into the database? Does it not work or something?

DdoubleD 315 Posting Shark

Sorry.. all
it's now work... because i kill my event and using

DG1.DataSource = "Material";

thank you everybody.. if any question i will asking again ;]

OK, for my own sanity and anyone else looking at this thread, what we really mean is (and correct me if I am wrong):

DG1.DataSource = ds;
    DG1.DataMember = "Material";
DdoubleD 315 Posting Shark

Ignorant of the subject am I (definately not my forte) , but it sounds like you might need to write your own device driver to emulate the device. I might not be giving you any information here you haven't already considered; however, I ran across these links and figured I would pass them on:

Forced FeedBack...

Capture directinput device...

What you might also look for is a keyboard/joystick emulator, that could provide more insight into directly communicating with and emulating the driver interface.

DdoubleD 315 Posting Shark

The SaveFileDialog facilitates the selection of filename and path to save the file, but you must perform the actual write of the data. See How to: SaveFileDialog.

DdoubleD 315 Posting Shark
DdoubleD 315 Posting Shark

can't select or can't see,after datasource bind the data

DG1.DataSource=ds;DG1.DataSource="Material";DG1.DataSource=ds;
DG1.DataSource="Material";
DG1.DataBind();

In the above, your DataSource will contain the last object set:

DG1.DataSource=ds;DG1.DataSource="Material";DG1.DataSource=ds;

will result in:

DG1.DataSource=ds;

which is back to your original code...

Try:

DG1.DataSource=ds.Tables[0];

And, for programmatically selecting rows, use a currency manager:

// local to form...
                DataView dv;
                DataSet ds;
                CurrencyManager CM;


                    // in form's load after loading DataSet...
                    dv = new DataView(ds.Tables[0]);
                    CM = (CurrencyManager)dataGridView1.BindingContext[dv];
                    CM.Position = 1; // position the row pointer...

NOTE: I took the CurrencyManager code from a DataGrid (not DataGridView ) I had, so I'm not sure but I think it will work...I have to run and don't have time to test it.

Cheers!

DdoubleD 315 Posting Shark

I haven't run into this problem. Have you checked to ensure there is no exception being thrown? I was about to shutdown my browser and thought I would pass on this similar blog I found related to deployment, which may or may not help you:

App writing to system log...

DdoubleD 315 Posting Shark

It would be a little difficult to explain ALL your options without knowing more about the C++ module and what you are supposed to do for this project...

Here is some blogs with similar discussions: accessing C++ from C# gui...
Calling exported C functions...
C++/CLI library...

DdoubleD 315 Posting Shark
DdoubleD 315 Posting Shark

What is the code you have so far for writing to your Access table?

EDIT: Did you test the code I gave you to determine it satisfies your import of the worksheet?

DdoubleD 315 Posting Shark

I searched my registry and found the following key, which returned 1.6.0_15 on my machine:

RegistryKey rk = Registry.LocalMachine;
            RegistryKey subKey = rk.OpenSubKey("SOFTWARE\\JavaSoft\\Java Update\\Policy");
            string currentVerion = subKey.GetValue("InstalledJREVersion").ToString();

EDIT: If using the above, just concatenate the currentVersion to the "Jdk version: " text: Text = "Jdk version: " + currentVersion;

DdoubleD 315 Posting Shark

It is not clear to me what you are doing with this line and how you want it to expand and shrink. Can you provide the code with comments, or some images that represent the desired outcome?

DdoubleD 315 Posting Shark

avirag, this will import your excel data into a DataSet. If you need additional help writing the DataSet to Access table, please create another thread. Play with this and see if it works for you...

// NOTE: adaptor always returned error without full path of .xls file
                string connStr = "Provider=Microsoft.Jet.OLEDB.4.0;" +
                    @"Data Source=c:\ExcelData\stockdata.xls;" +
                    "Extended Properties=Excel 8.0;";
                
                // Metals is the sheetname...
                string query = "SELECT * FROM [Metals$]";

                DataSet ds = new DataSet();

                using (OleDbConnection conn = new OleDbConnection(connStr))
                {
                    try
                    {
                        conn.Open();

                        using (OleDbDataAdapter cmd = new OleDbDataAdapter(query, connStr))
                        {
                            cmd.Fill(ds, "StockData");
                            return ds;
                        }
                    }
                    catch (OleDbException ex)
                    {
                        Console.WriteLine("Exception: {0}\r\n   Stack Trace: {1}", ex.Message, ex.StackTrace);
                    }
                    finally
                    {
                        conn.Close();
                    }
                }
DdoubleD 315 Posting Shark

Wow is right! As Ryshad suggested, you could do this without the array altogether. However, if you must use an array as part of the requirements, I would suggest using an array to represent the monetary denominations instead of a 1 to 1 representation of 0.00 - 1.00. For example:

int[] denominations = 
            {
                1, // pennies
                2, // two pence
                5, // five pence
                10, // ten pence
                20, // twenty pence
                50 // fifty pence
            };

You could then incorporate that array with the modulo loop that Ryshad suggested to allocate each of the denominations.

Also, and as a side note, if you were to incorporate this array design and pass it into a method that uses the modulo loop design with the given array, your coin buckets could be made to be country/coin independent. However, you might need to make some adjustments to your form to make it independent as well. I wouldn't worry about this right now, but a way of thinking you can ponder a little...

Cheers!

DdoubleD 315 Posting Shark

Not sure if this is your problem, but the documentation indicates you should create the event source during installation of the application:

Create the new event source during the installation of your application. This allows time for the operating system to refresh its list of registered event sources and their configuration. If the operating system has not refreshed its list of event sources, and you attempt to write an event with the new source, the write operation will fail.

excerpted from: http://msdn.microsoft.com/en-us/library/k2976wx2.aspx

DdoubleD 315 Posting Shark

First of all, use CODE tags:
[code=csharp]
...code here....
[/code]

Secondly, how is this a C# question, as your title suggests, when the code you have included is VB?

DdoubleD 315 Posting Shark

You edited your post after I provided a solution to a potential problem, which makes this thread more confusing...

Why did you use s.Length to allocate the array instead of just new int[s] in your constructor? You are looping through "n", or "s" in this case, not the length of an "int"!

Also, include the error message you are getting, which will help narrow down your problem too...

EDIT: You also introduced a new error by trying to access int s as an array in your posted change:

arr[i] = Convert.ToInt32(s[i] - 48);
DdoubleD 315 Posting Shark

Why do you want to reuse these id's once deleted--why does it matter? I would suggest that if your code is dependent upon id's being in consecutive order and gap free, that you might have a design flaw to begin with.

If you are insistent upon pursuing this, check out this blog: http://blog.sqlauthority.com/2009/04/01/sql-server-reseed-identity-of-table-table-missing-identity-values-gap-in-identity-column/

DdoubleD 315 Posting Shark

You didn't mention the actual error, but at first glance, it appears you never allocate your array, arr , before attempting to assign the values inside your constructor. Try allocating it first in the constructor:

arr = new int[s];
DdoubleD 315 Posting Shark

I ended up figuring this one out! Thanks a lot.

That's great! Can you share your solution so that I and others might benefit? Please mark as solved also.

DdoubleD 315 Posting Shark

In this example, the CellValueChanged event is used to examine the cell when the value is changed. For your question, extract the code you need and just substitute the row and column indexes to refer to the known cell, which will allow you to "get" or "set" the Value property to be true or false (checked or unchecked).

// Occurs when the value is changed...
                private void dataGridView1_CellValueChanged(object sender, DataGridViewCellEventArgs e)
                {
                    int iCol = e.ColumnIndex;
                    int iRow = e.RowIndex;
                    if (iRow > -1 & iCol > -1)
                    {
                        if (dataGridView1.Rows[iRow].Cells[iCol].ValueType == typeof(bool))
                        {
                            bool bChecked = (bool)dataGridView1.Rows[iRow].Cells[iCol].Value;
                        }
                    }
                }
DdoubleD 315 Posting Shark

It sounds like you want to start with very basic examples of creating a project/application. Try searching the web for keywords like:

"hello world c#"
"DB tutorial c# .NET" where DB is the type you are interested, such as "SQL Server" or "Access"

There are many websites out there that have tutorials for getting started. In addition, check out CodeProject.com, which is a huge repository of projects that demonstrate many facets of old and new technologies too. Try to find the simplest projects first so you are not overwhelmed when looking for specific examples.

As far as how you organize your project(s) and file(s) into specific categories or libraries and other separations, it depends on the size and purpose of the application IMO. It wouldn't make sense to advise you to break it apart into 3, 4, or even more specific functional libraries if the code needed to accomplish your overall goal will be very small and compact.

Your forethought in these matters is a good thing. However, if you are starting out with some basic DB interface or FileStream stuff with a Windows Form or something, I would advise keeping it all in one application for now and just name your files to whatever makes sense to you--you can always reorganize things as it becomes clearer there is a need to do so.

Some starter links:
Create a windows form...
Beginner developer learning center...
Project …

DdoubleD 315 Posting Shark

Hey buddy, I tried to change the parameters (InputData form): Gravity(5) and Height(.5) and got an exception... I tried it with other parameters before that though and it's kind of cool!

EDIT: P.S. I noticed this snippet this morning, but didn't have time to download and play with it. Anyway I was daydreaming about simulating the bounce in real (relative) time...LOL--you are the math man, think you could do it?

DdoubleD 315 Posting Shark

First of all, I have noticed that you later reposted this problem you are having, which is not proper to do. I provided you with a reply in that repost about what I saw as a problem.

Secondly, see my comments regarding your posts below:

actually storing the byte array to access database is not a problem
its gets stored the only thing is when i try to retrieve the same byte array from access database i am getting only 25bytes

WHY IS THAT SO

In the above, you have made a FALSE assumption that you are correctly inserting your byte array, which is proven by the code snippet you provided following! Had you tried to understand what adatapost was showing you in the snippet he provided to you, your problem might already be solved!

FileStream fs = new FileStream("encrypted.txt", FileMode.Open);

            byte[] buff = null;
            BinaryReader br = new BinaryReader(fs);
            long numBytes = new FileInfo("encrypted.txt").Length;
            buff = br.ReadBytes((int)numBytes);

           mycon.Open();
           OleDbCommand cmd = new OleDbCommand("INSERT INTO song VALUES('1','" + buff + "')", mycon);
            cmd.ExecuteNonQuery();
            mycon.Close();
            fs.Close();
// above code is inserting part 

//below code is extracting part 
           byte[] temp = new byte[200000000];
           mycon.Open();

           OleDbCommand cmd = new OleDbCommand("select file from song", mycon);
           System.Data.OleDb.OleDbDataReader dr;
           dr = cmd.ExecuteReader();
           dr.Read();
           temp = (byte[])dr["file"]; //only 25 bytes i am getting
           int len = temp.Length; //25 length 

           FileStream fs = new FileStream(@"C:\Documents and Settings\SHREESHILA1\Desktop\dummy.txt", FileMode.Create);
           fs.Close();

           BinaryWriter br = new BinaryWriter(File.Open(@"C:\Documents and Settings\SHREESHILA1\Desktop\dummy.txt", FileMode.Open));


           br.Write(temp);

           //br.Write(temp);
           br.Close();  

now check the …

kvprajapati commented: Well said! +6
DdoubleD 315 Posting Shark

In building your command ( OleDbCommand cmd = new OleDbCommand("INSERT INTO song VALUES('1','" + buff + "')", mycon); ), you are implicitly converting "buff" (a byte array) to a string, which is not how you handle binary data and even if the cast was able to convert your entire byte array to a string, I'm pretty sure you would exceed the limits of building a command string that way.

I would suggest you use parameterized SQL to build your DbCommand object.

For example:

OleDbCommand cmd = new OleDbCommand("INSERT INTO song (ColumnName) VALUES(@ColumnName)", mycon);

                int len = ((byte[])buff).Length;
                OleDbParameter p = new OleDbParameter("@ColumnName", OleDbType.LongVarBinary, len);
                p.Value = buff;
                cmd.Parameters.Add(p);

NOTE: I don't recall what the max length of the LongVarBinary type is, so you need to be sure you are using the type that corresponds to the DBTYPE needed...

DdoubleD 315 Posting Shark

thanks everyone.
string s = string.Format("{0}\r\n{1}\r\n{2}\r\n", ary.ToArray());
MessageBox.Show("My ArrayList contains:\r\n\r\n" + s);

these lines seem intresting but how would you do it for an index - which can constantly get bigger by the users input? . for example 3 values one time , 4 values another time or X values another time.

it has to be in an array or arraylist which is kinda of a shame as list<> is easier no dought.
-----------------------------------------------------------------

You could use a loop to build the string. In the following example, notice that the loop resolves each item to an object type before casting it to a string . This is because ArrayList is not a "strongly typed" container and treats its items simply as object types. Unfortunately, this also means you could store mixed types in the array, which would cause an error if you try to cast it to the wrong type.

string s2 = string.Empty;
                foreach (object oString in ary)
                    s2 += (string)oString + "\r\n";
                MessageBox.Show("My ArrayList contains:\r\n\r\n" + s);
brightsolar commented: Wow, Practically a Posting Shark = True lol. +1
DdoubleD 315 Posting Shark

i managed to add the node and move around one to another, now i am suppose to update the node but really don't have clue how to do that with GUI

How is your "node" defined? We cannot really tell you how to interface it with the GUI without knowing this...

DdoubleD 315 Posting Shark

As you have already learned by now, naming conventions are completely voluntary unless you are constrained to adhering to a standard. IMO, and until you find yourself confined to such constraints, continue learning and adopting naming techniques as you go along.

I would like to point out that consistency can be more important than adhering to any one particular set of naming rules because if you have ever tried to walk through code that has been touched by several different programmers where each programmer had their own way of defining/expressing code meaning/behavior, it can be more difficult to follow and understand. When working with large projects/solutions/workspaces (whatever), it is best to add and/or modify existing code files and libraries by keeping consistent with conventions already in place.

ddanbe commented: Well said! +5
DdoubleD 315 Posting Shark

As pointed out, I believe you are looking for the OpenFileDialog given the VB name you specified. Here is the basic setup and call for dialog:

string fileName;

            using (OpenFileDialog ofd = new OpenFileDialog())
            {
                ofd.Title = "Select File";
                ofd.InitialDirectory = "c:";
                ofd.FileName = "";
                ofd.Filter = "All Files (*.*)|*.*";
                ofd.Multiselect = false;

                if (ofd.ShowDialog() == DialogResult.OK)
                    fileName = ofd.FileName;
            }

You may wish to refer to documentation for further options and details.

Cheers!

DdoubleD 315 Posting Shark

Here is an example for your messagebox question in which the ArrayList is cast to an Array, which the string.Format method can then use to format a string with individual placeholders (eg. {0}, {1}, etc.):

ArrayList ary = new ArrayList();
                ary.Add("one");
                ary.Add("two");
                ary.Add("three");
                string s = string.Format("{0}\r\n{1}\r\n{2}\r\n", ary.ToArray());
                MessageBox.Show("My ArrayList contains:\r\n\r\n" + s);

In order to sort the array: ArrayList.Sort . If you need to sort complex items, you need to provide an IComparer .

You may wish to consider using List<> (eg. List<int>) instead of an ArrayList in the future.

DdoubleD 315 Posting Shark

sayjay092, I don't know if you noticed, but you have been asking questions to a thread going back to 2006? I didn't realize this when I first responded to a more recent question, or I would have said then what I say here...

Please create your own thread (new post/thread) with your question as this is the appropriate use of the forum and it is not appropriate to ask/piggyback questions in someone else's thread.

Cheers!

DdoubleD 315 Posting Shark

That's interesting, yesterday when I looked at this post the code was broken up into several blocks, but now it's all together?--weird.

Anyway, I was wondering if you made any headway on this? Having never worked with the MP API and plugin, I hacked around a little and noticed that when I had wired several other events that the metadata information would be updated by the time the CdromMediaChange event got fired. In addition, when I "unwired" all of the other events (your original code), if I ejected and reinserted the cd, the metadata would be updated by then (second time around).

I looked around for a while trying to figure out how to force the player to update the metadata via an API call, but didn't find out anything before having to "shelf" it.

I am rather surprised that nobody in here has hinted at an answer or direction for you yet. Perhaps it is due to the multiple code blocks as I encountered yesterday.... At any rate, should you find a "cure", please share it with the community.

Cheers!

DdoubleD 315 Posting Shark

If you look inside the form's designer.cs file using the view code option in Solution Explorer, you will find somthing similar to the following, which is where it adds those label controls to the Controls list:

this.Controls.Add(this.label3);
            this.Controls.Add(this.label2);
            this.Controls.Add(this.label1);
DdoubleD 315 Posting Shark

No problem. The foreach loop is iterating through the form's control list, which is maintained by the designer every time you add or remove controls to/from your form. Then, we are checking the name of the control (c.Name) to find the labels: label1 - label3, based on what you said you would like. If the label control's name matches the current control, then we are setting it's Visible property (c.Visible) to true.

Geekitygeek commented: a good answer and a clear explaination :) +1
DdoubleD 315 Posting Shark

This will loop through all of the form's controls searching for the name of the control....

private void button2_Click(object sender, EventArgs e)
        {
            for (int i = 1; i <= 3; i++)
                foreach (Control c in this.Controls)
                    if (c.Name == "label" + i)
                        c.Visible = true;
        }
DdoubleD 315 Posting Shark

Example of create table and ALTER table using the MySqlClient already mentioned:

public static void AlterTableExample()
        {
            string connStr = DbWrapper.TestDbWrapper.BuildConnectionString(DbWrapperType.MySql);
            string createStatement = "CREATE TABLE Test (Field1 VarChar(50), Field2 Integer)";
            string alterStatement = "ALTER TABLE Test ADD Field3 Boolean";

            using (MySqlConnection conn = new MySqlConnection(connStr))
            {
                conn.Open();

                // create the table...
                using (MySqlCommand cmd = new MySqlCommand(createStatement, conn))
                {
                    cmd.ExecuteNonQuery();
                }

                // alter table to add another column...
                using (MySqlCommand cmd = new MySqlCommand(alterStatement, conn))
                {
                    cmd.ExecuteNonQuery();
                }
            }
        }
DdoubleD 315 Posting Shark

Thanks--I'll look into this.

DdoubleD 315 Posting Shark

This method of assigning a TreeNode to TreeView.selectedNode does not work, TreeView.selectedNode is read-only (it cannot be assigned to).

I guess you are using the WebControls version of the TreeView. Look at the MSDN documentation for setting selection: Select node...

DdoubleD 315 Posting Shark

Okay probably a newb question, but what value is it returning? A bool?

Also, the instance I want to happen is when enter is pressed a message box pops up.

Display messagebox...

private void textBox1_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (e.KeyChar == 13)
                MessageBox.Show("RETURN key pressed");
        }