|
Am I right at saying that each database has different stored procedure syntax ? If so catering for each database is not going to be fun ...
Thanks for the input James.
Regards,
The only programmers that are better that C programmers are those who code in 1's and 0's
Programm3r
My Blog: ^_^
|
|
|
|
|
IME, that depends on how complex the SQL being executed is. For example, the syntax for executing, dropping, and creating a stored procedure is the same on MSSQL 2000, Sybase SQL, and MySQL (I believe), but cursors use different syntax. On every RBDMS that I have worked with, SELECT * FROM ORDERS WHERE ORDER_ID=3 works just fine.
There are also some subtle "issues" with now an identical SQL batch works between different RBDMSes (which is a serious PITA, BTW), but that too is not specific to stored procedures, but the SQL within the stored procedure.
A stored procedure also tends to be easier to update in the field - drop and reinstall it on the DB server, as opposed to building an installer that needs to run on each workstation or manually copying files to each workstation. Using an SP also greatly reduces the risk of having workstations mismatched WRT the SQL that they are using, like if all but two workstations are upgraded, so the un-upgraded ones are still building/using older SQL.
Lastly, if you have a system that never builds dynamic SQL and only uses stored procedures, you can mess around with the DB schema easier because you can change things and just update the SPs or create views for them, quickly update the database and everything continues to work.
So maintenance costs can actually be less with SPs...
Peace!
-=- James Please rate this message - let me know if I helped or not!<HR> If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Avoid driving a vehicle taller than you and remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! See DeleteFXPFiles
|
|
|
|
|
As others mentioned here, using Stored procedures is the best choice. However if you are using MFC with ODBC, you can do this:
CTablePatient derived from CRecordSet
...
CTablePatient tablePatient;
tablePatient.m_strFilter.Format("PK=%ld", atol(m_szPID));
tablePatient.Open();
if (tablePatient.IsEOF())
{
tablePatient.AddNew();
}
else
{
tablePatient.Edit();
}
tablePatient.m_Name = m_szName;
tablePatient.m_Birthday = m_birthday;
...
tablePatient.Update();
tablePatient.Close();
If you want to create a stored procedure and use it in an MFC app either, This tool will save your life:
http://www.codeproject.com/database/spcw.asp[^]
// "Life is very short and is very fragile also." Yanni while (I'm_alive) { cout<<"I love programming."; }
|
|
|
|
|
|
Programm3r wrote: I'm not using MFC
So it's a tough work, mate!
I think you'll need to use CDatabase class. (I think it's not MFC!)
I have an article here In MFC, but Database does not use CRecordSet :
http://www.codeproject.com/miscctrl/CBarChart.asp[^]
In the article I wrote some function that use CDatabase class to execute a query or a stored procedure(With predefined return values). CBarChart::CChartDatabase Is the class.
I wrote these functions that might help:
OpenProc
OpenTable
ExecuteSQL
Close
ExecuteProc
Connect
Prepare
GetRow
MoveNext
IsEOF
I put a sample app and an access database there. You can use the app to see how it works. I hope this will help.
Sorry! This was MFC as well. Just checked MSDN.
-- modified at 11:19 Tuesday 31st July, 2007
-- modified at 11:21 Tuesday 31st July, 2007
|
|
|
|
|
I'm accumulating read text from a database in a CString reading one record at a time. Eventually I need to dump this CString into a file created through CFile.
1) The CString contains characters \r\n for indicating new line.
2) The CFile object is created as below
CFile fileObj( strAbsoluteFileName, CFile::modeCreate | CFile::modeWrite | CFile::shareDenyWrite | CFile::typeBinary);
3) The application is unicode build.
When I see the notepad to see the file created I find the following text
0 = 0 , 3 , 5 4 4 , I D S _ S E M _ D O O R _ O P E N , 0 1
1)Thus I do not get the interpretation of '\r\n' in the file
2) An extra space is coming
3)Not all the contents are copied. It should have one more entry similar to above?
|
|
|
|
|
tom groezer wrote: CFile::typeBinary);
Use CFile::typeText instead.
Prasad
MS MVP - VC++
|
|
|
|
|
Hi
In VC 8.0 I tried
PostThreadMessage(WM_USER + 100,(WPARAM)_T”tablenm”,0);
Function(WPARAM wp,LPARAM lp)
{
CString str;
Str.format(“%s”,wp);
AfxmessageBox(str);
}
No Error It output correct.
But when I trying as
CString str1=”hai”;
CString* str2;
Str2=new CString (str1);
PostThreadMessage(WM_USER + 100,(WPARAM)_T(str2),0);
Function(WPARAM wp,LPARAM lp)
{
CString str;
Str.format(“%s”,wp);
AfxmessageBox(str);
}
Output was wrong some symbols are displaying
Give me the suggestion how to pass String throuh WPARAM and converting WPARAM TO String.
Awaiting for the suggestion
Regards
shakumar
shakumar
|
|
|
|
|
shakumar_22 wrote: Function(WPARAM wp,LPARAM lp)
{
CString str;
Str.format(“%s”,wp);
AfxmessageBox(str);
}
Should be something like,
Function(WPARAM wp,LPARAM lp)
{
CString str;
Str.format("%s",*wp);
AfxmessageBox(str);
}
Prasad
MS MVP - VC++
|
|
|
|
|
I think this was a repost.
Try changing from:
CString str1=”hai”;
To:
CString str1=_T(”hai”);
|
|
|
|
|
sorry, I missed the pointer to str2. solution suggested by prasad should work.
|
|
|
|
|
Thanks for your Reply
As Prasad suggestion it was illegal format,
str.Format("%s",*wp);
Runtime Error.
As mandanani suggestion ,Iagree
CString str1=”hai”;
To:
CString str1=_T(”hai”); its correct
But my programme was Socket Programme so I want to send the OnReceiving Character through WPARAM.
Ireceive the data in TCHAR and converted in to *CString and pass through the WPARAM
CString str1=”hai”;
CString* str2;
Str2=new CString (str1);
PostThreadMessage(WM_USER + 100,(WPARAM)_T(str2),0); /** this is wrong***/
Regards
shakumar
shakumar
|
|
|
|
|
shakumar_22 wrote: PostThreadMessage(WM_USER + 100,(WPARAM)_T(str2),0); /** this is wrong***/
PostThreadMessage(WM_USER + 100,(WPARAM)str2,0) That will pass the "raw" pointer to the message handler for WM_USER+100 . Be sure to delete that pointer when you are done with it.
Peace!
-=- James Please rate this message - let me know if I helped or not!<HR> If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Avoid driving a vehicle taller than you and remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! See DeleteFXPFiles
|
|
|
|
|
Didn't I answer this yesterday?
As I said then - you are allocating a string on the stack. When you leave the function, it is destroyed. Some time later, your posted message is dealt with, the wp now points to junk.
In the first case, you are posting an address of a string built into the data segment of your program, so it will still be valid later.
Iain.
|
|
|
|
|
How to find out the privilege given to a user(admin/limited access..)through coding?
Thanks
-- modified at 6:53 Tuesday 31st July, 2007
|
|
|
|
|
Users from windows or from your application?
Greetings.
--------
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
|
|
|
|
|
Users from windows or from your application? A bit more info would be good
Greetings.
--------
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
|
|
|
|
|
Your question is a bit too vague. What permissions are you referring to?
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
I would guess he's talking about windows ....
The only programmers that are better that C programmers are those who code in 1's and 0's
Programm3r
My Blog: ^_^
|
|
|
|
|
for the windows system(xp and above)
|
|
|
|
|
I want my application to detect whether it runs on a cluster or not. How can i do this using Cluster API ?
BEST REGARDS
|
|
|
|
|
If I compile the code as a UNICODE built , which compilation would it be UTF-8
, UTF-16 or some other .
I mean to say what support it would be UTF-8 or UTF-16.
and If nothing what can be done to make it utf-8 if I am using wcstombs ,_wcslen functions ?
Using MultiByteToWideChar is the solution ?
|
|
|
|
|
Internal a LPCWSTR/CStringW is in UTF-16 LE, a CString also when you compile in UNICODE.
Converting UTF-16 LE to UTF-8 you should use WideCharToMultiByte( CP_UTF8, 0, stringw, BYTE* );
When you want a Unicode file, you should first write an encoding tag.
|
|
|
|
|
I'm using Visual studio 6.0 and MFC.
I add a menu resource to my application and define all required names.
Menu produces its IDs automatically (e.g. ID_HELP_ABOUT) I use class wizard to add a handler for the command message. Every things OK. But when I revisit my menu and decide to add another handler for another item, a few days later, I see all those IDs turned to numbers (e.g. 32792) I then have to find the ID and retype it to be able to use the class wizard to add a handler.
I know how to add a handler manually, but it's a pain in my ...;P
Is there any way to return all IDs back? (I hope it's not deleting .clw file, it's even more pain to reassign all those classes, etc.)
// "Life is very short and is very fragile also." Yanni while (I'm_alive) { cout<<"I love programming."; }
|
|
|
|
|
Actually in your "resources.h" you should have a relation of IDs and assigned int values. But it is the first time I hear about what you are saying. Maybe is there an option somewhere where you choose about seeing IDs in number or in name, but not sure about
Greetings.
--------
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
|
|
|
|