Jump to content
Xtreme .Net Talk

bwgc

Members
  • Posts

    15
  • Joined

  • Last visited

1 Follower

bwgc's Achievements

Newbie

Newbie (1/14)

0

Reputation

  1. Thanks for your suggestions. Actually, in this particular instance, I ended up doing a "union select all", then writing a simple (4 lines of code) routine (after the table is returned) to combine totals and delete the dupicate date rows in the datatable. I thought I was missing an easy way to do this with some sort of "join", but obviously not. Thanks - Geoff
  2. Never used "joins" much, but if I do: select table1.date, sum(table1.amount), sum(table2.amount) join on table2.date = table1.date Group by 1 ...I get totals overstated by a multiple of the number of records in table2 Again, I apologize for my lack of knowledge with joins and if this is the wrong forum - I apologize for that also, but the forum description does read "Topics include: ADO.NET, SQL, XML structures and schemas, Crystal Reports, and other reporting tools". Thanks - Geoff
  3. Ok, I have two database tables with... column 1 a date field, and column 2 an amount field. I'd like to write a query which will combine and sum the two tables by date giving me one table with a date field and combined total for that date. I can do a "union all" query, but that gives me two rows for each date (if both tables have amounts for the same date). I suppose I could write two queries and end up with two datatables, then combine the two datatables - but I don't see an easy way to do that. I've been thinking too much about this - can someone offer a suggestion? Thanks - Geoff
  4. As you requested, I am posting an example. I am by no means an expert at this - there may be many things wrong with it, but it seems to work. In this example, we're trying to get textBox3.Text to refresh automatically as the value of a variable changes. ===================================================== //OK, here's the class... public class BoundText { public delegate void TextUpdatedEventHandler(object sender, EventArgs e); public event TextUpdatedEventHandler TextUpdatedEvent; private string _strVal; public BoundText() { StrVal=""; } public BoundText(string p_StrVal) { StrVal = p_StrVal; } public string StrVal { get{return _strVal;} set { _strVal = value; OnBoundTextChanged(); } } protected virtual void OnBoundTextChanged() { if(TextUpdatedEvent!= null) TextUpdatedEvent(this, EventArgs.Empty); } } //In your code where you instantiate the new object boundText1 = new BoundText(); boundText1.TextUpdatedEvent +=new BoundText.TextUpdatedEventHandler(boundText1_TextUpdatedEvent); //then somewhere define your event private void boundText1_TextUpdatedEvent(object sender, System.EventArgs e) { textBox3.Text = ((BoundText)sender).StrVal; } ============================================================= Thanks for you feedback - Geoff
  5. I suppose you could also create a class with a "value changed" event, and do it that way. I just thought maybe I was missing an obvious simple solution. Thanks - Geoff
  6. As opposed to binding to a datasource, how do you bind a textbox.text to a private string variable and get it to display the proper text when the value of the string variable changes? I'm doing: string v1="value"; textbox1.Binding.Add("Text",v1,""); //This sets the initial value, just fine. v1 = "value changed"; // does nothing Thanks - Geoff
  7. Trying to refresh the MonthCalendar control after programmatically changing the SelectionRange with the following properties: monthCalendar1.SelectionStart=FirstDay.Value; monthCalendar1.SelectionEnd=LastDay.Value; Have tried .Refresh() & .Update() - neither seems to update the Calendar displayed selected range? Anybody?
  8. I believe you need to change as follows: ...AND (Postcode = ' "+txtPost+" ') ORDER ... I put a space between the single and double quote for readability (you wouldn't do that).
  9. That's not the case. It's a very small dbf. No null values either in the source or destination.
  10. I'm trying to code a custom oledbDataAdapter to update a foxpro table. (The commandbuilder won't work in this instance.) My update code follows: string lcSQL = "UPDATE emp SET emp_name=?, emp_cost=? where emp_id=?"; OleDbDataAdapter1.UpdateCommand = new OleDbCommand(lcSQL,this.oleDbConnection1); oleDbDataAdapter1.UpdateCommand.Parameters.Add("@emp_name", OleDbType.Char, 35,"emp_name"); oleDbDataAdapter1.UpdateCommand.Parameters.Add("@emp_cost", OleDbType.Numeric, 10,"emp_cost"); oleDbDataAdapter1.UpdateCommand.Parameters.Add("@emp_id", OleDbType.Char, 4,"emp_id"); When I "oleDbDataAdapter1.Update" with the dataset, I get a "Object Reference Not Set to an instance of an object". If I omit the "emp_cost" field, I don't get the error. I've tried changing the OleDbType.Numeric length to -0- (I read somewhere), but still the same thing. Anybody?
  11. Actually both methodologies work. The problem was in my report - I had changed datasources and the detail line has disappeared. But thanks - now I have an alternative!
  12. Trying to get Crystal Reports to work with Windows forms with a dataset. Here's my form_load event: sqlDataAdapter1.Fill(dataSet11); //Pass the dataset to the report rpt11.Database.Tables[0].SetDataSource(dataSet11.Tables[0]); crvMain.ReportSource = rpt11; //Confirm that I have some data... MessageBox.Show(dataSet11.Tables[0].Rows[0][1].ToString()); ...I get a report with headings, but no data. Anybody???
  13. (From "Windows Forms FAQs" above) The DataGrid class does not have a property that controls whether a new row can be added. But the DataView class does have such a property (along with some others such as AllowEdit and AllowDelete). Here is code that will turn off the append row by getting at the dataview associated with the datagrid. string connString = @"Provider=Microsoft.JET.OLEDB.4.0;data source=C:\northwind.mdb"; string sqlString = "SELECT * FROM customers"; // Connection object OleDbConnection connection = new OleDbConnection(connString); // Create data adapter object OleDbDataAdapter dataAdapter = new OleDbDataAdapter(sqlString, connection); // Create a dataset object and fill with data using data adapter's Fill method DataSet dataSet = new DataSet(); dataAdapter.Fill(dataSet, "customers"); // Attach dataset's DefaultView to the datagrid control dataGrid1.DataSource = dataSet.Tables["customers"]; //no adding of new rows thru dataview... CurrencyManager cm = (CurrencyManager)this.BindingContext[dataGrid1.DataSource, dataGrid1.DataMember]; ((DataView)cm.List).AllowNew = false;
  14. OK, I found that you can use the "leave" event, check my "cancel" button for focus, then change the textbox "CausesValidation" property to false. Thanks...
  15. I'm validating a textbox control and want to "force" the user to enter valid info before moving on to the next control. I'm using e.Cancel=true in the validating event to accomplish this. But, if I want the user to be able to cancel out of the form altogether (let's say press a cancel) button, how do I programatically get out of the validating event - with invalid text still in the text box? TIA
×
×
  • Create New...