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
S

Spawn Melmac

@Spawn Melmac
About
Posts
52
Topics
12
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • How to process multiple commands on CAccessor.
    S Spawn Melmac

    Yes I know it is a Database question but I have not had much luck in that forum so I am looking for a fresh perspective. I am using accessors to perform DB queries which works fine except when I come to do INSERTs. This is the SQL in the accessor

    DEFINE_COMMAND_EX(CDBEvtRawInsert, L" \
    INSERT INTO [RawEvent] ([TimeStamp],[Direction],[Hub],[RawEvent]) \
    VALUES (GETDATE(),? ,? , ?);")

    which works fine with this snippet...

    wcscpy_s(rsEvtRawInsert.f_RawEvent, iSize*2, CA2T(pTmp)); // put it in the accessor
    rsEvtRawInsert.f_Direction = 1; // indicate this is received data
    rsEvtRawInsert.f_HubID = m_pHubDev->m_iHubID; // and from this hub
    hr = rsEvtRawInsert.Open(m_oDB->session); // store it

    However in order to retrieve the ID of the record which has just been inserted I need to add SELECT @@IDENTITY AS RecID to the SQL but this makes it a multiple command accessor which is where my problem is. I have search MSDN and the SDK's but for the life of me I cannot find anything that shows me how to code the accessor properly to deal with the multiple results. I know I can use GetNextResult to move onto the second result set but I cannot get it to work. It has been suggested using ExecuteScalar would be the solution but as I am going to have multiple threads executing the same code I would prefer to use the @@IDENTITY to avoid any possible collisions between the threads. The only other solutions I can think of are to either issue a search to find the record I have just created OR maintain a counter which would track the ID field. Does anyone have any other ideas or point me to a way to get the accessor to process my multiple commands?

    Alan

    C / C++ / MFC database help question tutorial

  • How do I insert escape sequences using SQL Compact.
    S Spawn Melmac

    Ok things are getting even wierder than I thought they were to start with. I have done some testing with my own code and I have observed that INSERT preserves the 0x000D,0x000A when written to the DB but then if I use UPDATE on the same field with the same data I get '?' stored in the DB?!?!?!? Now this smells to me of a bug in the OLEDB... Anway it looks like I am going to have to restructure my code and DB to provide separate fields for each address line. I then have to glue them together when I retrieve them and split them apart when writing. You are still getting hung up on the Contact1/2/3. This is simple the variable names I use within the code so I can easily find all the code dealing with the contacts. In presentation they are Primary, Secondary and Reserve. Simples. :)

    Alan

    Database question c++ database

  • How do I insert escape sequences using SQL Compact.
    S Spawn Melmac

    Well you would be right if that is the way the fields were being used but they are not. There will only be three contacts as these fields hold pointers to entries in a Contact table. I want to use a single ADDRESS field to store a multiline address rather than have 5 separate fields (one for each line). There is no comma between line1 & line2 becuase they are stored as "line1\r\nline2" in the application internals. Now I can do that everywhere else (CString, Registry etc...) so why is it so unreasonable to want the same thing in SQL CE?

    Alan

    Database question c++ database

  • How do I insert escape sequences using SQL Compact.
    S Spawn Melmac

    Simple question I know but I just cannot find a anything that works.

    INSERT INTO [Location] ([id],[TZOffset],[Address],[Tel],[Fax],[Contact1],[Contact2],[Contact3],[Company],[Deleted],[Disabled]) VALUES (8,null,N'line1
    line2
    ',N'',N'',1,2,3,null,null,null);
    GO

    I have tried everything I can find but there is no ESCAPE or CHAR function in SQLCE that I can find. You cannot use Stored Procedures, being CE so it has to be done in a command space. If I store the CRLF in the raw data and push it using MFC then it works fine. Any ideas? Great isn't it. I can use SIN, COT, SQRT but I cannot put CRLF into a string!!?!??!?!

    Alan

    Database question c++ database

  • OLEDB CAccessor with CMultipleResults what am I doing wrong.
    S Spawn Melmac

    The problem: I am using an accessor to INSERT into a table but this does return a value so I am using two commands to find out the ID of what was just inserted or at least that is the idea. I get DB_E_ERRORSINCOMMAND so if anyone can point me to where I am going wrong then you can save both my sanity and my hair... This is the accessor class from the test application I have been troubleshooting against.

    class CDBEvtRawInsert
    {
    public:
    // Data Elements
    int f_Direction;
    int f_HubID;
    TCHAR f_RawEvent[1400];
    LARGE_INTEGER f_RawEventID;

    BEGIN\_COLUMN\_MAP(CDBEvtRawInsert)
    	COLUMN\_ENTRY(1, f\_RawEventID)
    END\_COLUMN\_MAP()
    
    // Parameter binding map
    BEGIN\_PARAM\_MAP(CDBEvtRawInsert)
    	SET\_PARAM\_TYPE(DBPARAMIO\_INPUT)
    	COLUMN\_ENTRY(1, f\_Direction)
    	COLUMN\_ENTRY(2, f\_HubID)
    	COLUMN\_ENTRY(3, f\_RawEvent)
    END\_PARAM\_MAP()
    
    DEFINE\_COMMAND\_EX(CDBEvtRawInsert, L" \\
    						INSERT INTO \[RawEvent\] (\[TimeStamp\],\[Direction\],\[Hub\],\[RawEvent\])	\\
    						VALUES (GETDATE(),?,?,?);SELECT @@IDENTITY AS RawEventID")
    

    };

    This is an extract from the function

    CString szValue = \_T("test");
    HRESULT hr = E\_FAIL;
    CCommand<CAccessor<CDBEvtRawInsert >,CRowset, CMultipleResults > rsEvtRawInsert;
    
    wcscpy\_s(rsEvtRawInsert.f\_RawEvent, szValue.GetLength()\*2, szValue);
    rsEvtRawInsert.f\_Direction = 1;					
    rsEvtRawInsert.f\_HubID = 0;					
    hr = rsEvtRawInsert.Open(theApp.m\_oDB.session);			// <<==== fails here
    if(S\_OK == hr)
    {
    	DBROWCOUNT out;
    	hr = rsEvtRawInsert.GetNextResult(&out);
    

    I know the SQL is ok as I have tested it in SQL Management Studio on the same DB this code is using. Also if I make it a single recordset by removing the SELECT @@IDENTITY that works too. If you have an alternative suggestion which would achieve the same result then I am all ears. Thank you for reading this far.

    Alan

    C / C++ / MFC database wpf wcf help question

  • Best way to merge/process commands on SQLCE
    S Spawn Melmac

    Ok here you go but I should warn you I don't fully understand it myself. I think of an accessor as a wrapper to the SQL like this (which is an extract from working code)...

    class CDBHubDetails
    {
    public:
    // Data Elements
    TCHAR f_LocSub[255];
    int f_HubID; // Input field

    // Column binding map
    BEGIN_COLUMN_MAP(CDBHubDetails)
    COLUMN_ENTRY(1, f_LocSub)
    END_COLUMN_MAP()

    // Parameter binding map
    BEGIN_PARAM_MAP(CDBHubDetails)
    SET_PARAM_TYPE(DBPARAMIO_INPUT)
    COLUMN_ENTRY(1, f_HubID)
    END_PARAM_MAP()

    DEFINE_COMMAND_EX(CDBHubDetails, L" \
    SELECT Hub.SubLoc \
    FROM Location \
    WHERE Hub.id = ?")
    };

    Now this get's used as follows

    CCommand<CAccessor<CDBHubDetails > > rs;
    
    rs.f\_HubID = pHub->m\_iHubID;													// pull the HubID from the CDevice object
    hr = rs.Open(m\_oDB->session);
    

    where I can then walk the recordset. The thing is I have not figured out how to process the additional SELECT command I need to include in the INSERT operation so I can retrieve the ID of the item inserted. Now I know I am being both optemistic, and lazy, but I was hoping that as the INSERT does not return a recordset itself, the SELECT @@IDENTITY would become the result. Silly me... The responses thus far have given me some ideas but finding examples I can learn from is proving difficult. MSDN seems devoid of C++ examples in the documentation (although F# is there!). Thank you for taking the time to look at this for me.

    Alan

    Database help question c++ database oop

  • Best way to merge/process commands on SQLCE
    S Spawn Melmac

    Sorry if this seems a dumb question but could this be integrated into the ACCESSOR class mechanism I am using at present? I have geared everything to use accessor classes which is working fine for everything but the INSERT operations. It is just annoying because I know the insert is working but it does not give me back the ID of the item that was inserting. So when I came across the @@IDENTITY I thought I was sorted and as the INSERT does not return any results it looked like I could bunch the commands into the same accessor. Life is never as simple as I expected it to be :(

    Alan

    Database help question c++ database oop

  • Best way to merge/process commands on SQLCE
    S Spawn Melmac

    Greetings, Apologies if this is a dumb question but I'm afraid my SQL knowledge is a little limited. Anyway I am using SQLCE as I don't need anything bigger at the moment but I have a problem when processing the following command

    INSERT INTO [Contact]
    ([Name]
    ,[Tel]
    ,[Mobile]
    ,[Email])
    VALUES
    (N'Name'
    ,N'Tel'
    ,N'Mobile'
    ,N'Email');
    SELECT @@IDENTITY AS ContactID

    My problem is that although this functions correctly when issued by hand, my encapsulation of OLEDB only seems to permit a single command. Now this is the only occasion when I need to issue multiple commands so it seems a shame to have to mess up my existing code just for this instance. So can anyone suggest how I might merge the above into a single command that INSERTs and gives me the ID of the inserted data? Or is there a simple way with OLEDB & MFC that I can process multiple recordsets without adding too much overhead. Any thoughts or suggestions would be appreciated. Many thanks

    Alan

    Database help question c++ database oop

  • Deadlocked UI need a little help
    S Spawn Melmac

    After a little more digging I have discovered that I am getting stuck in a loop inside CWnd with a WM_GETDLGCODE being passed to all of the controls in my application?|?|? The main dialog consists of

    BEGIN
    CONTROL "",IDC_MNG_TAB,"SysTabControl32",0x0,17,25,248,300
    PUSHBUTTON "Edit",IDC_MNG_EDIT,31,345,51,14,WS_GROUP
    PUSHBUTTON "Apply",IDC_MNG_APPLY,112,345,50,14,WS_DISABLED | WS_GROUP
    DEFPUSHBUTTON "Cancel",IDC_MNG_CANCEL,194,345,50,14,WS_GROUP
    CONTROL "",IDC_MAIN_TREE,"SysTreeView32",WS_BORDER | WS_HSCROLL | WS_GROUP | WS_TABSTOP,299,75,209,250
    CONTROL "",IDC_RPT_TAB,"SysTabControl32",0x0,544,25,248,300
    PUSHBUTTON "Execute",IDC_RPT_EXECUTE,561,345,50,14,WS_GROUP
    PUSHBUTTON "Cancel",IDC_RPT_CANCEL,724,345,50,14,WS_GROUP
    CONTROL 284,IDC_LOGO,"Static",SS_BITMAP,299,329,209,39
    GROUPBOX "Manage",IDC_MNG,7,7,268,369
    GROUPBOX "Monitor",IDC_MONITOR,285,7,237,369
    GROUPBOX "Report",IDC_RPT,532,7,268,369
    GROUPBOX "Status",IDC_ST_STATUS,299,21,209,44
    CONTROL 0,IDC_STATUS,"Static",SS_BITMAP,324,31,159,28
    END

    The group boxes and tab controls are owner drawn. Any help would be appreciated.

    Alan

    C / C++ / MFC design data-structures help lounge

  • Deadlocked UI need a little help
    S Spawn Melmac

    I have what seems to be a random deadlock in my application which I am hoping someone can shed some light on. The occurance of the deadlock is random but the call stack is far from it... below is the stack I am getting.

    0:001> ~0s;kbn
    eax=002f0f60 ebx=00000000 ecx=00000f60 edx=00000f60 esi=0079cc10 edi=0015ec54
    eip=61088bc4 esp=0015ea90 ebp=0015ebd0 iopl=0 nv up ei pl nz na pe nc
    cs=0023 ss=002b ds=002b es=002b fs=0053 gs=002b efl=00000206
    mfc90ud!CWnd::OnWndMsg+0x224:
    61088bc4 335508 xor edx,dword ptr [ebp+8] ss:002b:0015ebd8=00000087

    ChildEBP RetAddr Args to Child

    00 0015ebd0 61088962 00000087 00000000 00000000 mfc90ud!CWnd::OnWndMsg+0x224
    01 0015ebf0 61085d80 00000087 00000000 00000000 mfc90ud!CWnd::WindowProc+0x32
    02 0015ec6c 61086346 0015f884 000b1068 00000087 mfc90ud!AfxCallWndProc+0xf0
    03 0015ec8c 61081a3b 000b1068 00000087 00000000 mfc90ud!AfxWndProc+0xa6
    04 0015ecc8 750c6238 000b1068 00000087 00000000 mfc90ud!AfxWndProcBase+0x5b
    05 0015ecf4 750c68ea 610819e0 000b1068 00000087 USER32!InternalCallWinProc+0x23
    06 0015ed6c 750ccd1a 00000000 610819e0 000b1068 USER32!UserCallWinProcCheckWow+0x109
    07 0015edb0 750ccd81 00c8ba70 00000000 610819e0 USER32!SendMessageWorker+0x581
    08 0015edd4 750e0fb1 000b1068 00000087 00000000 USER32!SendMessageW+0x7f
    09 0015ee00 750e29a2 00cadd90 00000000 00c87810 USER32!xxxRemoveDefaultButton+0x5f
    0a 0015ee30 750dc0cd 00cadd90 00000000 00290b46 USER32!xxxCheckDefPushButton+0x12d
    0b 0015ee68 610eebb3 001e0ada 00000000 f53163fb USER32!IsDialogMessageW+0x156
    0c 0015ee80 6108f76e 0079cbc8 0058cff8 0015eea8 mfc90ud!CWnd::IsDialogMessageW+0x73
    0d 0015ee90 610c730f 0079cbc8 0058cff8 0058cff8 mfc90ud!CWnd::PreTranslateInput+0x6e
    0e 0015eea8 6108afbd 0079cbc8 0058cff8 00190712 mfc90ud!CDialog::PreTranslateMessage+0xef
    0f 0015eebc 611174df 001e0ada 0079cbc8 0015eedc mfc90ud!CWnd::WalkPreTranslateTree+0x8d
    10 0015eed8 61118595 0079cbc8 002f9940 0015eef8 mfc90ud!AfxInternalPreTranslateMessage+0x4f
    11 0015eee8 61117555 0079cbc8 002f9940 0015ef18 mfc90ud!CWinThread::PreTranslateMessage+0x25
    12 0015eef8 61117391 0079cbc8 0015ef14 61081be9 mfc90ud!AfxPreTranslateMessage+0x25
    13 0015ef18 611188ee 002f9940 0015ef30 611173e1 mfc90ud!AfxInternalPumpMessage+0xe1
    0:000> .frame c
    0c 0015ee80 6108f76e mfc90ud!CWnd::IsDialogMessageW+0x73
    0:000> dv
    this = 0x0058cff8
    lpMsg = 0x0079cbc8
    0:000> dt lpMsg -r
    Local var @ 0x15ee88 Type tagMSG*
    0x0079cbc8
    +0x000 hwnd

    C / C++ / MFC design data-structures help lounge

  • So what backup software do you use...
    S Spawn Melmac

    2010 + change I'm used to using NTBackup which may be crude but it did the job and gave the the fexibility of backup type in addition to it being easy to schedule. Is it me or are all the backup suites becoming so much bloatware? Don't even get me started on Backup Exec.. My requirements are quite simple: - Flexible backup options (Whole disk, full and incremental). - Simple naming to allow grandfather, father and child versioning. - Individual file/ folder restore - x64 supported (or at least does not break if it is running on x64) Too much at ask?

    Alan

    IT & Infrastructure sysadmin data-structures collaboration tools question

  • Help with Cisco routing table
    S Spawn Melmac

    You really need to read the RFC's on the subject... specifically RFC 1918[^] and RFC 3330[^] Also RFC 1466[^] I don't mean to be cruel but you should get yourself a few books on IP and read up on the addressing before you embark on this project. P.S. Don't forget about IPv6 too.

    Alan

    IT & Infrastructure help tutorial learning

  • Help with Cisco routing table
    S Spawn Melmac

    WOW! Sorry chap but I really think you are biting more than you can chew here. To walk through each subnet on the Internet is time consuming, dangerous (i.e. your ISP will think you are a hacker) and frankly pointless. Let me try to explain why. IP addresses are assigned by IANA (http://www.iana.com/numbers/[^]) via regional authorities which you can see listed on the link I have included. So if you want to know what IP addresses go to which country just ask IANA via RIPE, ARIN etc... Not sure I exactly understand what it is you want to achieve, other than a list of IP addresses/country, but if you wanted to refocus your efforts then you could look at creating your own WHOIS application. It is not new, there are thousands out there already, but it would prove a useful excercise. Have a look at http://whois.domaintools.com/[^] Hope it helps a little.

    Alan

    IT & Infrastructure help tutorial learning

  • how to know the downloaded data from the net for a PC
    S Spawn Melmac

    You need to be more specific. What 'data'? Where is it stored? Is it part of your application? If you have a more intelligent router connecting you to the Internet then you could use SNMP to pull statistics from the router. Sorry but while you are so vague it is impossible to advise further. P.S. this is more a general IT question.

    Alan

    C / C++ / MFC tutorial question

  • MAC address
    S Spawn Melmac

    Not universally true but yes you could... but how many people even know you can do that? There are so many things that you 'could' do but it does not mean you 'do' do.

    Alan

    IT & Infrastructure help question workspace

  • MAC address
    S Spawn Melmac

    Unless it is removed, every laptop I have ever had has the MAC address written on a label which is stuck to the machine by the OEM. Pick up your managers laptop and show him :)

    Alan

    IT & Infrastructure help question workspace

  • Network Layout Design
    S Spawn Melmac

    Greetings, I can see why you have a confusion but your problem really hinges on the question of 'what are you trying to achieve?'. Personally I think of SBS as the B@s'd child of Windows, Exchange and anthing else that got in there at the time. True it serves the purpose for SME's but there comes a point where you have to ask if you need to grow beyond SBS, which I suspect you might, then maybe full products might be more cost effective in the long run. However if we put that aside for a second, try and think of your infrastructure in terms of the services you need to provide and then slot in the products to suit. As I read what you have said I think you could use the SBS install media to install Windows ONLY and then promote this to a DC within the domain independant of the SBS install process. So my advice would be to re-evaluate what it is you need and then build it. If you don't need all of SBS then don't pay for it, just use a base Windows license. Why not try it, i.e. build up a machine and use the 30 activation period to test. If in doubt call Microsoft? Just make sure you know what you are trying to achieve before you do because if you don't know what you want how is anyone going to be able to help. After all no matter what my good intentions might be my advise is not guarenteed (unless you pay for it ;) ) As for your network. Yes you are getting the idea BUT do you really want to give unfettered access to the internet to your guest wireless? What if the police come knocking and ask you who was downloading 'xXx' material? How do you prove it was not someone in your organisation? So my suggestion would be as follows.

                             (Ext IP addy 1)
    

    {net}-{modem}-{Smoothwall FW}---------------{unmanaged Switch}--{WLAN AP) < Wireless Clients
    || || || ||
    || (Wired Clients) (SBS08) (Win2k3 Backup AD/DNS)
    ||
    ||
    {cheap Wireless Router} < Wireless Guests

    That is put a 3rd network card into the Smoothwall (or alternative) and log EVERYTHING from the guest network. An additional NIC is probably cheaper than a dumb switch and although it is a little more configuration it will pay you dividends in the long run. I have used this scenario for years, admitedly using ISA, on my own desk. Yes I know this is overkill but I do some testing of Malware and this allows me to put anything where your wireless guest will be and be

    IT & Infrastructure sysadmin design business help question

  • Network Layout Design
    S Spawn Melmac

    jwalker343 wrote:

    1. Can we run 2 copies of SBS on the same domain?

    Yes if you have the licenses.

    jwalker343 wrote:

    1a. if not, can SBS2008 be primary DC, and a copy of Server 2003 Standard be Secondary DC?

    Even if you don't use 2 x SBS2008, you can only use 2003 as a DC so long as you are not using any 2008 specific Active Directory features.

    jwalker343 wrote:

    2. Will the proposed network topology be secure/good idea for a Small business?

    check out the following http://technet.microsoft.com/en-us/library/cc527583(WS.10).aspx[^] Personally I would look at firewalling your guest wireless network with ISA server. You could re-use an old PC and run one of the Linux firewall variations (Smoothwall etc..) Good luck.

    Alan

    IT & Infrastructure sysadmin design business help question

  • scan for IP Cameras
    S Spawn Melmac

    I am working on a similar problem at the moment and although it is not an IP camera I suspect that the principles are likely to be the same. The device I am working with has a configuration tool that operates in the same way that you describe. I used Microsoft's Network Monitor, although Wireshark would do just as well, to see how it discovered the device on the network. What I learned from the network trace is that the application sends out a subnet broadcast to a UDP port which the device then responds to. From the response the application then knows the IP address of the device and the initiates a point-to-point TCP connection to configure the device. I am still deciphering the UDP payload the application sends and the response the unit sends but I hope that helps.

    Alan

    IT & Infrastructure sysadmin question

  • So what backup software do you use...
    S Spawn Melmac

    For years I found that the built-in NTBACKUP served my needs very well thank you. It had sufficient flexibility to allow me to script simple backup jobs for Full and Differential quite easily. However since its demise in Vista and W7 I have tried a number of solutions the most recent being Acronis True Image which I came with one of my machines. Now Acronis seemed to be working fine until I decided to implement daily incremental backups a few weeks ago at which point the driver, it uses to access the specially formatted partition, kept hanging my x64 W7 machine daily. I prefer run the backups as my machine starts if it is not alive at the time I scheduled the previous evening. So while I crawl the various bits of advertising and reviews of backup software I wondered what solutions others might be using/recommend. Commercial or Freeware? Full with incremental or just full? Daily, weekly or other? Any lessons learned from past mistakes? I will start the ball rolling with the last one. A few years ago I was responsible for managing the local copy of source code for the team I was part of. Discussions with the local IT they decided that using tape backup was too expensive so they provided us with an alternate server with a 10 disk array. The array was configured as Raid 5 + 'hot standby'. All went well until one of the drives failed after about 4 months but the 'hot standby' drive was automatically activated so all was good. The bad drive was replaced and the array began it's rebuild. Only thing was a few hours later another drive failed while the rebuild was in progress closely followed by a 3rd which caused the array to collapse. I learned that when our IT was building the array for us they purchased 10 new drives. All 10 were from the same batch from the same manufacturer. Lesson learned: If you are building a disk array don't use the disks from the same manufacturer or at least from different batch builds.

    Alan

    IT & Infrastructure sysadmin data-structures collaboration tools 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