Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
C

calhuskerfan

@calhuskerfan
About
Posts
9
Topics
2
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • Bug in DataTable ReadXml causes spaces to be ignored
    C calhuskerfan

    I found this one the hard way, http://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=295677[^]. After writing and testing a bunch of code that relied on reading from persisted DataTables one of our test databases had columns with single spaces. While this post discusses .NET 3.0 I am seeing the behavior in .NET 2.0. I have not tested to see if it is fixed in any later versions.
    However, if I read the same file, which is still persisted with a DataTable object (DataTable.WriteXml()), into a DataSet object instead and use the first DataTable in the DataTableCollection the whitespace is [appears to be, for me anyway] preserved properly in the DataTable

    DataSet someData = new DataSet();
    someData.ReadXml("somepersistedDataTable.xml");
    //
    DoSomethingToDataTable(someData.Tables[0]);
    //
    void DoSomethingToDataTable(DataTable dt)
    {
    }

    Not sure if this is the correct place, or a repost for that matter, but wanted to share just in case someone else was having similar issues.

    .NET (Core and Framework) beta-testing csharp com testing xml

  • DataTable PrimaryKey problem
    C calhuskerfan

    Here is a very quick (and sloppy) example that reproduces the behavior.

    using System;
    using System.Collections.Generic;
    using System.Text;
    using System.Windows.Forms;
    using System.Data;

    namespace ConsoleApplication2
    {
    class Program
    {
    static void Main(string[] args)
    {
    Test1();
    }

        public static void Test1()
        {
            DataTable dt1 = new DataTable();
            //
            dt1.Columns.Add("col0");
            dt1.Columns.Add("col1");
            dt1.Columns.Add("col2");
            //
            dt1.Columns\[0\].DataType = typeof(Int32);
            dt1.Columns\[1\].DataType = typeof(String);
            dt1.Columns\[2\].DataType = typeof(String);
            //
            DataRow dr = dt1.NewRow();
            dr\["col0"\] = 1;
            dr\["col1"\] = "Column 2";
            dr\["col2"\] = "Column 3";
            dt1.Rows.Add(dr);
            //
            dr = dt1.NewRow();
            dr\["col0"\] = 1;
            dr\["col1"\] = "Column 2";
            dr\["col2"\] = "Column 3   ";
            dt1.Rows.Add(dr);
            //
            try
            {
                dt1.PrimaryKey = new DataColumn\[\] { dt1.Columns\[0\], dt1.Columns\[2\] };
            }
            catch (ArgumentException ae)
            {
                MessageBox.Show(ae.Message);
            }
        }
    }
    

    }

    .NET (Core and Framework) database help tutorial question

  • DataTable PrimaryKey problem
    C calhuskerfan

    Sybase SQL Anywhere 10. Thanks.

    .NET (Core and Framework) database help tutorial question

  • DataTable PrimaryKey problem
    C calhuskerfan

    The constraints in the database are fine. They allow the described scenario where 'ABC' and 'ABC ' are considered unique. When I read, with ADO, from the database into a datatable object ADO does not bring along the primary key identified in the database. So it allows at this point the two above rows to exist. When I set the PrimaryKey property on the DataTable object (after the rows have been read) to include the column containing the above data I get the constraint exception. Edit - The exception is actually an ArgumentException stating that the values are not unique.

    .NET (Core and Framework) database help tutorial question

  • DataTable PrimaryKey problem
    C calhuskerfan

    I have a database which has a unique primary key defined key on two columns, in the example below the columns are type and data.

    type

    value

    data

    9

    0

    'ABC'

    9

    0

    'ABC '

    When I read in a datatable and then set the PrimaryKey collection with the designated columns I get an exception saying that 'These columns don't currently have unique values'. So, to me it appears that ADO is ignoring the spaces with respect to determining uniqueness (although the whitespace appears in the rows collection). I started looking into the DataTable and DataColumn object to see if there was anything that jumped out, but nothing so far. Can anyone confirm this behavior and/or offer any assistance? Thanks!

    .NET (Core and Framework) database help tutorial question

  • Because we've always done it this way...
    C calhuskerfan

    http://www.snopes.com/history/american/gauge.htm[^]

    The Lounge ruby business tools question

  • Songs about the Internet
    C calhuskerfan

    Virtuality by Rush

    The Lounge visual-studio com question

  • How to trigger an event at a specified time
    C calhuskerfan

    I am not very familiar with Doc/View. So hopefully you can apply the following as appropriate. What I normally do is create a thread, often times in the class constructor, that passes a this pointer as the thread parameter. The thread then calls back to the function that does the waitable timer. When the waitable timer completes it can set your trigger. A simple illustration... class myclass {   myclass();   long settrigger();   static DWORD WINAPI waitthread();   long waittimer(); }; myclass::myclass() {   HANDLE hThread(NULL);   DWORD dwThreadID;   hThread = (HANDLE)_beginthreadex(NULL, 0,      waitthread,      (LPVOID)this, 0,      &dwThreadID); } DWORD WINAPI myclass::waitthread(LPVOID pParam) {    myclass* ptr = static_cast(pParam);    return(ptr->waittimer()); } long myclass::waittimer() {    /* Do all your work with waitable timer. */    /* If everything is good! */    settrigger();    return 0; } long myclass::settrigger() {    /* Set your trigger */    return 0; }

    C / C++ / MFC database tutorial question

  • How to trigger an event at a specified time
    C calhuskerfan

    Take a look at CreateWaitableTimer and SetWaitableTimer. Below is the example from MSDN. Create a Thread to monitor for your event and then use SetWaitableTimer. When the the timer is signalled you can do what you need. SetWaitableTimer can either be set for an absolute time or a relative time(as in the example). If you use absolute time pay attention to your time local time offset. #include #include int main() { HANDLE hTimer = NULL; LARGE_INTEGER liDueTime; liDueTime.QuadPart=-100000000; // Create a waitable timer. hTimer = CreateWaitableTimer(NULL, TRUE, "WaitableTimer"); if (!hTimer) { printf("CreateWaitableTimer failed (%d)\n", GetLastError()); return 1; } printf("Waiting for 10 seconds...\n"); // Set a timer to wait for 10 seconds. if (!SetWaitableTimer( hTimer, &liDueTime, 0, NULL, NULL, 0)) { printf("SetWaitableTimer failed (%d)\n", GetLastError()); return 2; } // Wait for the timer. if (WaitForSingleObject(hTimer, INFINITE) != WAIT_OBJECT_0) printf("WaitForSingleObject failed (%d)\n", GetLastError()); else printf("Timer was signaled.\n"); return 0; }

    C / C++ / MFC database tutorial question
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups