291 Posted Topics
Re: DataRow[] rows = yourTable.Select(string.Format("ID='{0}'",cbIDs.Text)); yourLabel.Text = (string)rows[0]["Name"]; | |
Re: ASP or WinForm ? I can help if it is a Window Form... | |
Re: Jugortha has given you the way to get the the current cell into a text box. Have you looked at just binding the Textbox (and other) components to the same BindingSource as the DataGridView... then let the great binding capabiliites handle populating all the controls for you. | |
Re: [code] DataTable tbl = new DataTable(); SqlDataAdapter adapt = new SqlDataAdapter(string.Format("select cust_address,customer_city from customers where customer_id = {0}", customerID), con); adapt.Fill(tbl); if (tbl.Rows.Count > 0) { lblAddress1.Text = (string)tbl.Rows[0]["cust_address"]; lblCity.Text = (string)tbl.Rows[0]["customer_city"]; } tbl.Dispose(); [/code] Just one of many ways of doing this. | |
Re: To use the select, try this: [code] DataRow[] rows = table.Select("[First]='Lance'"); if(rows.Length > 0) { Console.Write("{0} ", rows[0]["ID"]); Console.Write("{0} ", rows[0]["FIRST"]); Console.Write("{0} ", row[0]["AGE"]); Console.WriteLine(); } [/code] // Jerry | |
Re: Maybe posting the rest of the code (or entire project) will help. The adapter.table is a bit of a mystery. The acceptchanges is not really needed until later after the rows have all been added. I think the use of the adapter object in the for loop may be at … | |
Re: If you are referring to licensing the software application on the target machine, you may want to checkout this website: [url]http://www.eziriz.com/intellilock.htm[/url] I use this product, and it is very nice, plus it will prevent others from reverse engineering it. The target machine will need dot net, and you can put … | |
Re: honeybits, Let me apologize for my colleague’s answers. Often times it is easy to forget that this forum has many students and new-bees. Do not let them discourage you from asking questions here. [code] static void Main(string[] args) { string _countStart; string _countEnd; string _oddEven; int _iStart; int _iEnd; string … | |
Re: try making the class static as well: public static class GlobalVariables | |
Re: Place an Applicaiton.DoEvents(); inside of the loop so that the main thread has a chance to service its message queue and this should allow your label to update. // Jerry | |
Re: estimatorDataSet.QuoteCalcHeader["estimateno"]. <<== is estimateno correct ? does the QuoteCalcHeader accept a string as the indexer ? What is QuoteCalcHeader ? (Type?) You can ignore the code below, I think your problem is with indexing that QuoteCalcHeader object, but the formatting below might help you after resolving that issue, so I … | |
Re: Why do you think this is an error. Your timer is on a 1000 ms loop, and the TryEnter has a max wait time of 1ms. It should always return true, because there was nothing preventing it (IOW nothing else locking the object for more than 1001ms. Try having another … | |
Re: Does the button have a BackColor property ? button.BackColor = Color.Red; | |
Re: Are you saying that when you change rows, you want to know how to set the radio buttons to have the correct one checked ? The BindingSource has an event for position change. Setup a BindingSource for this table, and attach an event handler to its PositionChanged event. // Jerry | |
Re: Have you checked your reference properties for the DLL, and make sure it is not set to version specific ? | |
Re: Make sure your DateTime value is enclosed in single quotes. You might find it easier (to read and build) if you assemble the string using the string.Format() method. [code] SqlConnection conn = new SqlConnection(); SqlDateTime sTime = new SqlDateTime(DateTime.Now); SqlCommand command = new SqlCommand( string.Format("INSERT INTO Sensors VALUES ('{0}','{1}',{2},'{3}' )" … | |
Re: There is a good example at: [url]http://support.microsoft.com/kb/308507[/url] If this is a clean Select statement to get the data from the databaes, then this works (SqlCommandBuilder). If your data comes from multiple joins you may want to manually post the data back using your own T-SQL code, or a stored procedure. … | |
Re: You can search for C# XPATH on Google for tons of information on this subject. I am not sure you will find exactly what you are looking for. There may be a better alternative, or atleast worth your time to look at, and that is to use the existing power … | |
Re: Maybe this link wil help you understand linked lists. [url]http://www.c-sharpcorner.com/UploadFile/jeradus/UsingLinkedListInCS11102005005525AM/UsingLinkedListInCS.aspx[/url] Too bad they are still teaching these prehistoric methods. Since Generics were introduced, link lists are pretty much useless in the real world. // Jerry | |
Re: Simple... Just set e.Handled to true When e.Handled is set to true, then the keypress event stops there, otherwise it is passed up the chain to the TextBox. // Jerry | |
Re: I may be wrong, but I think you are asking on how to make a static class that all other classes can use. You can change your classGlobal.cs to be static by changing the class definition to public static class classGlobal. You will need to set your public properties and … | |
Re: First, you should decide if you are going to use the Wizard created class or stick with your own connection objects. Personnally I hate the wizard created class, it is more trouble than it is worth. Storing the location of the Access data file and the connection string can be … | |
Re: Maybe this link will help [url]http://www.csharpfriends.com/Forums/ShowPost.aspx?PostID=1[/url] It includes some C# examples, and reasons for the different type declarations. | |
Re: As Scott said, use YourStringVariable.IndexOf("Value to Search") and then use the SubString method to extract what you want. | |
Re: External assemblies come in two flavors. Referenced (required at startup), and dynamically loaded at some point when the program wants to use some feature within the external assembly. Dynamically loading and managing assemblies is not automatic. You have to write code to manage these external assemblies. If this isn't very … | |
Re: I have read about this is several books, and it appears that you will need to build a method that will take the array as a parameter, move all the elements except for the one you want to delete and return the new array. Something like this where you want … | |
Re: Something like this: [code] static void Main(string[] args) { string text = "bobby crossed the road and fell on the road"; //File.ReadAllText("C:\\SomeFile.txt"); char[] separator = new char[1] { ' ' }; string[] textData = text.Split(separator, StringSplitOptions.RemoveEmptyEntries); Array.Sort(textData); textData = DoWordCounts(textData); foreach (string str in textData) Console.WriteLine(str.ToLower()); Console.ReadKey(); } private string[] … | |
Re: Lets first clean up the sql statement so you can easily view it with the debugger and see which item is null... [code] string sql = string.Format("INSERT INTO [Issue] (Sl_no,Date,NamePrdOrRep,NameOfDepartment,TitleOfProduction" +",TapeType,PurposeShooting,PurposePreview,QuantityOfTape,BoxNo,BoxName,TapeNo,IssueOrReturn) " + "Values( '{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}',{8},'{9}','{10}','{11}','{12}' )" ,issue.Sl_no.Replace("'", "''") ,issue.Date ,issue.NamePrdOrRep.Replace("'", "''") ,issue.Department.Replace("'", "''") ,issue.TitleOfProduction.Replace("'", "''") ,issue.TapeType.Replace("'", "''") ,issue.PurposeShooting.Replace("'", "''") ,issue.PurposePreview.Replace("'", … | |
Re: Code Project just got a new Chat project added this week, suggest you check that out. If your chat works on the network, then is should work in the internet as well unless it is just a UDP client. [url]http://www.codeproject.com/KB/miscctrl/SimpleMessenger.aspx[/url] | |
Hello, I typically hang out in the C# forum, however I hope someone here can help. I am converting a C++ program to C#, and I need to know how to handle a couple things: IOW I know almost nothing about C++, and this code is coming from a non … | |
Re: Your interface should have a few more properties, such as the server, database name, credentials. Besides that if may either subclass the writer to handle a Filename in the place of the server. Then in your writeMsg method, you would append the text to the specified filename. | |
Re: Check out: [url]http://www.codeproject.com/KB/cs/hard_disk_serialno.aspx[/url] This should get you on the right track. // Jerry | |
Re: What value of time does the integer represent ? Seconds, miliseconds ? You should be able to create a DateTime for the epoch, then add to this the integer in the integer time value as AddSeconds, or AddTicks, etc. to get the value, then as far as displaying it in … | |
Re: Andy, other than a couple small errors, it worked for me. Here is the code I used with corrections: [code] private void savetxt() { // Got rid of "try" because it did not have the rest of it in your sample. //m_stockInfolist is nothing but the listview control name //string[] … | |
Re: Not exactly sure what you are asking for, but it is just a string, so you can concat the other textbox values into a single label using the (+) operator. [code] lblResult.Text = txtName.Text + " " + nextTxtName.Text + " "; // and so on... [/code] If this is … | |
Re: MJV, Ramy has provided the excepted and standard way to do this. If you are looking for something a little more extreme, then check out : [url]http://www.codeproject.com/KB/combobox/multicolumncombo.aspx[/url] You may also want to explore the abilty to store tons of data to be associated with each combobox item. The item is … | |
Re: First I would suggest that you create a constructor for Emp_Details just to make it easier. [code] public Emp_Details( string empName, int empId, double empSalary) { _EmpName = empName; _EmpId = empId; _EmpSalary = empSalary; } [/code] Then as you get information from the user, and want to enter it … | |
Re: Simple, the first while loop already read through the entire data reader, so there is nothing left to read by the time you get to the last while loop. Seems that you are going about it the hard way. Why not just use an SqlDataAdapter and fill the dtl table. … | |
Re: Looked at some of the links in this thread, and am surprised on how complicated some of these examples tend to be. I use serialization and deserialization with a Binaryformater to store and retrieve class instances between an SQL database and a Windows form. If you need more information on … | |
Re: Similar to Ramey, assuming that the event handler is only assigned to TextBox controls. [code] private void undotextbox(object sender, EventArgs e) { TextBox textbox = sender as TextBox; if(textbox != null) { string oldValue = textbox.Text; } } [/code] | |
Re: Try using a switch( var.Length ) construct. That should limit you to ten or so case statements. | |
Re: Have you used debug to trace to the actual line that crashes ? I would venture to guess that it is at the line: string isMkv = isMkvTest.Substring(isMkvTest.LastIndexOf(':')); There is no guarantee that isMkvTest is instantiated. Just because you are asking it to readline, does not mean that there is … | |
Re: try this: [code] double AverageCalc = 0; if (dataGridView1.Rows.Count > 0) { foreach (DataGridViewRow row in datagridview.Rows) { double average; if (double.TryParse(row.Cells[2].Value.ToString(), out average)) AverageCalc += average; } AverageCalc /= datagridview.Rows.Count; } txtAverage.Text = AverageCalc.ToString(); [/code] BTW: You didn't post the error you were getting, only that it is broke | |
Re: I don't think you really need to have an array of buttons for this project. Instead set the table to allow drop that way it will allow you to use the drag drop events on the table. Then on the Mouse Move event of the buttons, start a drag operation. … | |
Re: Does the text file contain delimiters other than CRLF ? If not, then you will have to consider using line based parsing. Line 0 = CDid Line 1= Artist Etc. If you can post some code, someone (if not me) will come along and give you some feedback. // Jerry | |
Re: Bob, I take it you are using the Data Source Wizard crap in VS2008. Some people get along with it, but I have been bitten way too many times, and I simply refuse to use it. It has the potential to lose databases, and IMO it is more trouble than … | |
Re: You can set the Modifier property of the DataGridView in the second dialog box to public. Then if the dialog result is Ok, then you can access the selected row of the DataGridView from your first dialog. Hope this helps // Jerry | |
Re: Do you mean that your data actually contains the charcter 'K' in the salary value ? (that would be ugly) Assuming that it is true: [code] UPDATE dbo.Employee SET TAX = ( 1.25 * Convert(int,substring(Salary,1,len(Salary)-1) ) WHERE Salary > '30K' [/code] **free handed, so perform some tests on a temp … | |
Re: Is this a duplicate ? I think you posted this earlier, and I sent you some code to use the DataGridView instead of the DataGrid component. // Jerry |
The End.