Jump to content
Xtreme .Net Talk

Gladimir

Avatar/Signature
  • Posts

    60
  • Joined

  • Last visited

Everything posted by Gladimir

  1. If the school has a license to use Microsoft Access allowing them to view, edit, and modify Access databases in your absence and the absence of your program, then I would stick with the Access engine. If the school will not be able to view the database without your application, in other words they don't have a license to use Access, then I would recommend taking a look at MySQL. I think a good place to start would be Databound Controls. Does that ring a bell?
  2. Solution... The problem was created when I used a canned Data Adapter that I dragged and dropped from the Data Toolbox. The size property of all Text type parameters for the Update and, more importantly, the Insert commands are set to 50 by default. When I set the size property for the 'name' parameter to 100, the problem was corrected.
  3. I have a function that reads data from fields in one table and populates fields in a second table. Specifically, a new row is added to the second table if the value of field n of the current row from the first table cannot be found in the second table. However, when I add the new row to the second table, the data from one particular field (the comparison field) is truncated to 50 characters. I am using tables from two separate access databases, but I have examined the table design properties and the widths for the correlating fields and all are 100 characters wide. Do Column objects have a default field-width of 50 characters? Before: Windows 2000 Hotfix (Pre-SP2) (See Q280838 for more information) After: Windows 2000 Hotfix (Pre-SP2) (See Q280838 for mor Relative Code Snippet: foreach (DataRow row in drc) { // does software already exist in deployed list? strSoftware = row["Software"].ToString().Trim(); string strSelect = "name = '" + strSoftware + "'"; DataRow[] foundRows = ds1.Tables["deployed"].Select(strSelect); // if software does not exist - add it if (foundRows.Length < 1) { DataRow newrow = ds1.Tables["deployed"].NewRow(); newrow["name"] = strSoftware; ds1.Tables["deployed"].Rows.Add(newrow); } }
  4. I'm just getting into ADO.NET and C# from VB6 and decided my latest project would be a good place to jump into the water. The first deliverable of the project was due yesterday and thanks to the people here, I mailed it out at 10 PM last night. I will tell you that I received much better help here than on the microsoft.public. usenet groups or on the C# Corner message boards. So, in lieu of sending you all a cut of the check, I'm offering my most sincere appreciation and praise. ;) Now, on to my XML question? As I work my way through various C# and ADO books, I'm seeing the cool things XML can do for typed database design, but why would I ever go through the trouble of documenting my code with XML?
  5. I got it... Ok, this was a case of the absent-minded professor. The assetID field had a 10 character constraint on it, which was fine before I changed the rules about what I would accept as an assetID. Everything should work fine now.
  6. Thanks... One More... Thanks, that worked! Now I have another problem. I am using OleDbCommandBuilder to automatically generate my update string when I do use the OleDbDataAdapter.Update method. During my pass, I successfully add 7872 records to the asset table using the Adapter.Update with OleDbCommandBuilder. During a second pass, I load the existing 7872 records in DataSet ds1, add another 1846 new records to ds1, and attempt to update the source. When I call the OleDbDataAdapter.Update method (still using OleDbCommandBuilder), I get a "string too long" error telling me I am trying to add too many records. I've included a very basic code snippet below: // create dataset and populate with tables DataSet ds1 = new DataSet(); ds1.Tables.Add("scsdComputer"); ds1.Tables.Add("asset"); // setup connection using my dbConnection class dbConnection masterDb = new dbConnection(); OleDbConnection mdb = masterDb.m_mdb; // create the adapter and command objects OleDbDataAdapter scsdComputerAdapter = new OleDbDataAdapter(strscsdComputerSelect, mdb); OleDbCommandBuilder scsdComputerCommand = new OleDbCommandBuilder(scsdComputerAdapter); OleDbDataAdapter assetAdapter = new OleDbDataAdapter(strassetSelect, mdb); OleDbCommandBuilder assetCommand = new OleDbCommandBuilder(assetAdapter); // populate the tables in the dataset scsdComputerAdapter.Fill(ds1, "scsdComputer"); assetAdapter.Fill(ds1, "asset"); try { // do a bunch of stuff then update source scsdComputerAdapter.Update(ds1, "scsdComputer"); assetAdapter.Update(ds1.GetChanges(), "asset"); } The error is generated by the scsdComputerAdapter.Update line. Any ideas would be greatly appreciated.
  7. I'm having a little trouble getting with DataRows and DataRowCollections. The primary question is at the bottom of this post. Here is a code snippet that is working well: // code is truncated for brevity; DataRowCollection drcComputer = ds1.Tables["scsdComputer"].Rows; foreach (DataRow row in drcComputer) { // search for assetID from computer table in asset table string strrowSelect = "assetID = '" + strassetID + "'"; DataRow[] foundRows = ds1.Tables["asset"].Select(strrowSelect); // if assetID does not exist in asset table, then add it if (foundRows.Length < 1) { // add new row DataRow newRow = ds1.Tables["asset"].NewRow(); newRow["assetID"] = strassetID; ds1.Tables["asset"].Rows.Add(newRow); } else { // NOTE: this is where I am having problems } } The above code pulls assetID from the scsdComputers table and searches for it in the asset table. If the assetID is not found in the asset table, the assetID is added to the asset table in the if-block. The trouble comes in the else-block. If the assetID does exist in the asset table, then I want to edit a value in the row returned by the Select method used one line above the if-block. However, I noticed there seems to be some difference between DataRow[] and DataRow, and that seems to be what I need to know. I cannot add 'foundRows.BeginEdit()' to my else-block because the BeginEdit method does not exist for 'DataRow[] foundRows'. Do I have to create a new DataRowCollection and re-run my Select method in the else-block using DataRow?
  8. Worked... The Application.DoEvents worked perfectly. Good advice on disabling unnecessary controls, but this is a status form for my own benefit; I can screw my programs up quite well without buttons. ;)
  9. I have a fairly long loop as I process records in a database table. In that loop, I update the Text properties of a few labels controls, but I only get to see the updates made for the last record when all the processing is done. How do I go about refreshing/updating the controls on Form1?
  10. Hello everyone, I'm slowly working way around c-sharp and am trying to figure out what the C# equivalent to VB's Right function might be. I want to grab the right-most 8 characters of a string, but the best way I can see to do it is to use the string.Remove method with the string.Length property. Is that the easiest best or is there a better way that I don't know about?
×
×
  • Create New...