To help get this thread started I invite requests for code snippets and I will do my best to provide answers, hopefully others can help too. Only requests for snippets not full applications please, for example How do I detect that the application is running in a Terminal Services session. How do I convert RGB (0-255) Colour values to HLS (Hue, Luminosity, Saturation). Answers at bottom of page. My professional areas of expertise are Windows NT4 to current (all versions), c++, C#, Windows Applications, COM, ASP.Net, MS SQL Server 2000, 2005, 2008. MS CRM Dynamics 4.0 and networking. If we get a good collection it could for the basis of a Knowledge Base section. Snippet code. [C++] How do I detect that the application is running in a Terminal Services session. Code: bool IsTerminalServicesSession() { HANDLE hToken; BOOL bOK = OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY, &hToken); DWORD TokenSessionID = NULL; DWORD dwBufferSize = sizeof(TokenSessionID); GetTokenInformation(hToken, TokenSessionId, &TokenSessionID, dwBufferSize, &dwBufferSize ); CloseHandle(hToken); return (TokenSessionID != 0); } How do I convert RGB (0-255) Colour values to HLS (Hue, Luminosity, Saturation). Code: VOID CHLS::RGBtoHSL(COLORREF rgb, double *H, double *S, double *L) { double delta; double r = (double)GetRValue(rgb)/255; double g = (double)GetGValue(rgb)/255; double b = (double)GetBValue(rgb)/255; double cmax = max(r,max(g,b)); double cmin = min(r,min(g,b)); *L=(cmax+cmin)/2.0; if(cmax==cmin) { *S = 0; *H = 0; // it's really undefined } else { if(*L < 0.5) *S = (cmax-cmin)/(cmax+cmin); else *S = (cmax-cmin)/(2.0-cmax-cmin); delta = cmax - cmin; if(r==cmax) *H = (g-b)/delta; else if(g==cmax) *H = 2.0 +(b-r)/delta; else *H=4.0+(r-g)/delta; *H /= 6.0; if(*H < 0.0) *H += 1; } }
Hi BobSheep, 1. Can you please help me with a snippet that can insert multiple rows from a GridView and insert into a database table under a SINGLE transaction in ASP.NET and SQL Server 2008 ? 2. Also, i got a few interview questions i couldn't answer, if anyone could please help me.. a] how to force a garbage collector to run in .net? b] how to make windows api calls in .net ? Thanks for any help..
Hi. I'll get the info you need today hopefully and I'll add the info to this post. ASP .Net question will be answered later today. a) GC.Collect(); b) At the top of your class [DllImport("User32.dll")] static extern Boolean MessageBeep(UInt32 beepType); in your code MessageBeep(0);
For your ASP.Net question I do not have a code snippet (yet). I think it will be much more than a code snippet too. Normally you would bind the GridView to a Datasource, creating INSERT, DELETE AND UPDATE commands for the DataSource, Enable Edit and Delete buttons for the GridView. Now all you need to do is implement the Insert command in the GridView and this is where it will get more complicated than a "snippet". So to implement this you'd create a DataTable and bind this to the GridView. Now all your automatic editing and delete are no longer available so you would have to implement that your self. You would then add command buttons to the GridView for Edit, Del, Ins and implement the code in their repective events to update the DataTable. When you're ready to commit the changes you would have to start an SQL transaction, iterate the DataTable detecting changes, update/insert/delete and finally commit the changes. To detect the Insert Command you would use event RowCommand of the GridView. I have created a very basic app which while not your complete solution should help you on your way with the other information I have given. http://www.datafilehost.com/download-6d3b06bf.html
If any one needs help with Visual Basic i know a lot about it. (Feel free to ask) if u need a full program and its not too crazy i might be willing to try it but it might take a few days to a few weeks depending how complex.
Why not do a thread like Calistoga did demonstrating how to get started with virtual basic how to install IDE or whatever it uses, etc... Kinda an intro with helpful links and examples, etc...
Sounds good ill start on that soon but i want to get the program i am working on somewhat finished first. u should try it out its Win7 Tweaker.
Thank you very much BobSheep.. i have gone through the code for now and will follow your tips..am a bit busy this week, so will let you know once i arrive at the desired solution.. Again, thanks a lot for your time and effort, i appreciate very much..