|
someone can show me how to read and write record table (SQL DataBase) with VC++??
--code is better
thanks
Nho'c Ti`
|
|
|
|
|
To Write:::
db.OpenEx("DSN=YOUR DSN;Uid=YOUR USER ID FOR SQL;Pwd=YOUR PASSWORD FOR SQL",CDatabase::noOdbcDialog)
CString query="INSERT INTO Userinfo(Userid,Passw,Name,Address1,Address2,City,Country,Zip,Phone,Email,Pincode,Dateofentry) VALUES ('" + uid + "','" + pwd + "','" + uname + "','" + add1 + "','" + add2 + "','" + ucity + "','" + scountry + "','" + uzip + "','" + uphone + "','" + uemail + "','" + test + "',GetDate())";
db.ExecuteSQL (query);
To Read::
CRecordset rs( &db );
CString check;
check.Format ("SELECT Userid FROM Userinfo WHERE Pincode='" + test +"'");
rs. Open ( CRecordset::dynaset, check, CRecordset::none ) ;
rs.GetFieldValue("your field",CString variable to store);
after this you can convert it to integer or anythine..thats all..hope it helps..
cheers
Himanshu
|
|
|
|
|
hello,
I'm fresh to VC,
I need an example for loading picture to PictureBox(control).
e.g., if I enter the file path, like c:\abc.bmp, then the picture will be loaded into picture(control).
I don't know which is good, using Hbitmap or Cbitmap.
Could anyone give me some example code?
Thanks.
|
|
|
|
|
both of them does the same thing. Its just like if u set the bitmap through resource to any particular bitmap it is static type...There are other times when u need to change the bitmaps from time to time or depending on some conditions...then using HBitmap..and CBitmap are mre or less same..u can use any of them depending on the dialogs u r using..in most of the dialogs u will have to use CBitmap..as HBitmaps are global..and used for globally setting the Bitmaps to maybe other applications...not urs of course..Its just an idea..i am not sure though..Hope it helps
Himanshu
|
|
|
|
|
I'm trying to get a CString representation of _variant_t type VT_CY and VT_DECIMAL. Does anyone know of any classes/code out there that accomplishes this?
RS
|
|
|
|
|
Have you tried using VariantChangeType to convert to a BSTR ?
I'll admit it's not very controllable!
VT_CY doesn't look too bad: "A currency number is stored as 64-bit (8-byte), two's complement integer, scaled by 10,000 to give a fixed-point number with 15 digits to the left of the decimal point and 4 digits to the right." You can therefore work it out as follows:
__int64 unitPart = vt.cyVal / 10000;
UINT fracPart = vt.cyVal % 10000;
CString strValue;
strValue.Format( _T( "%I64d.%u" ), unitPart, fracPart ); Unfortunately, I can't find any documentation for VT_DECIMAL that indicates which bits do what. The document I referenced above ('VARIANT and VARIANTARG' in the Automation section of the Platform SDK) says only "Decimal variables are stored as 96-bit (12-byte) unsigned integers scaled by a variable power of 10. VT_DECIMAL uses the entire 16 bytes of the Variant."
|
|
|
|
|
No I didn't try VariantChangeType - didn't come across it. I was using itoa, ltoa, ultoa and _gcvt (float,double). I will test it out though.
You say that it's not controllable. What problems have you encountered?
Thanks for the currency snippet above. If I run into any anomolies with VariantChangeType I'll revert back to itoa, ltoa... and you currency code.
|
|
|
|
|
When I say 'not controllable', I mean that there's no way to specify how many digits you're going to get (for example, after a decimal point).
|
|
|
|
|
I saw that with my first try. The amount 78.90 became 78.9 - not that nice for display purposes.
|
|
|
|
|
I sent this to myself by accident.
----------------
It seems that I can use
_variant_t vt;
COleCurrency oleCur(vt);
CString strCur = oleCur.Format();
This will work for a date string as well
COleDateTime oleDT(vt);
CString strDT = oleDT.Format();
I have some testing to do.
I also found the DECIMAL conversion in Carlos Antollini's CADORecordset
double val = vtFld.decVal.Lo32;
val *= (vtFld.decVal.sign == 128)? -1 : 1;
val /= pow(10, vtFld.decVal.scale);
str = DblToStr(val); // also define in his class
Thanks,
RS
|
|
|
|
|
It seems that I can use
_variant_t vt;
COleCurrency oleCur(vt);
CString strCur = oleCur.Format();
This will work for a date string as well
COleDateTime oleDT(vt);
CString strDT = oleDT.Format();
I have some testing to do.
I also found the DECIMAL conversion in Carlos Antollini's CADORecordset
double val = vtFld.decVal.Lo32;
val *= (vtFld.decVal.sign == 128)? -1 : 1;
val /= pow(10, vtFld.decVal.scale);
str = DblToStr(val); // also define in his class
Thanks,
RS
|
|
|
|
|
Hi I want to change the name of my dll everytime I build it but dont want to manually edit my workspace each time. I can write a script to automatically edit the dsp file before building the dll, but does not seem to be a good solution. Does any one know of a VC++ option to do this or may be suggest a better solution.
Thanks for your ideas.
|
|
|
|
|
There are two ways (that I know of) of using a VBScript macro to do this:
a) Use the script to directly access the workspace Developer Studio objects and make the necessary changes. or
b) Use the script to modify the workspace file as a text file. This is the method that I normally use because it is then easy to apply search and replace operation to change project names, output names etc in text format. You can then get the macro to load up the workspace/project as usual. As an example, try this:
<br />
ExecuteCommand "SaveCloseAllThings"<br />
Documents.Open "myworkspace.dsw", "Text"<br />
ActiveDocument.Selection.StartOfDocument<br />
blnFound = ActiveDocument.Selection.FindText("ProjectName")<br />
If blnFound = false Then<br />
ActiveDocument.ReplaceText "ProjectName", "NewProjectName"<br />
End If<br />
ActiveDocument.Save<br />
Documents.Open "myworkspace.dsw", "Auto"<br />
whichs opens myworkspace.dsw, finds all instances of "ProjectName" and replaces them with "NewProjectName", saves the changes, and then loads up the file as a normal workspace. The initial "SaveCloseAllThings" has only been included to make sure that all active windows are closed.
|
|
|
|
|
I'm a Maths student. Now I'm having a project that I need to call Maple inside my project and do some calculation. Anyone has experiences on this please help me.
|
|
|
|
|
You could be more specific about your problems. You can use maple routines and data structures in your C/C++ application by using the OpenMaple API and it's easy to find example program listings from the net. Did this help?
- Jussi
|
|
|
|
|
Firstly, Thanks.
I can explain it clearer like this:
+ In my project, I let the user type some text in LaTeX format and I want to let to user do some calculation. For this, I need to call Maple. I don't know how can I do this !!!
Would you please give me some more details???
|
|
|
|
|
I am trying to build a dialog to allow the user to select directory
path as in Visual basic.
|
|
|
|
|
SHBrowseForFolder()
I'm not sure if I get your point.
Rickard Andersson
Here is my card, contact me later!
UIN: 50302279
Sonork: 37318
Interests: C++, ADO, SQL, Winsock, 0s and 1s
|
|
|
|
|
I know that I have asked this, but I need to understand what is going on.
If you create a CRichEditCtrl on the screen (canned width/height), then make the default font 12 point Times New Roman. Enter in a string of characters until it wants to wrap (stop just prior to the wrapping). Now, get the text along with the font information and calculate the width of the string. What I'm finding is that the same string that is to be drawn to the screen is wider than the control! How could that be?
Any help would be appericated.
Larry J. Siddens
Cornerstone Communications
TAME THE DOCUMENT MONSTER
www.unifier.biz
|
|
|
|
|
I guess that I have you guys stumpped!
Larry J. Siddens
Cornerstone Communications
TAME THE DOCUMENT MONSTER
www.unifier.biz
|
|
|
|
|
It's easy to cause an internal compiler in VC6! Just add this class to your project:
class CFoo
{
public:
CFoo();
virtual ~CFoo();
};
CFoo::CFoo() {};
CFoo::~CFoo() {}
/ravi
Let's put "civil" back in "civilization"
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
Every programmer has been generating compiler errors since their "Hello world", what's your point?
|
|
|
|
|
I was just pointing out another instance of how to generate an internal compiler error in VC6. Sorry if my post upset you.
/ravi
Let's put "civil" back in "civilization"
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
I was not upset at all, actually I was a little confused by your purpose about generating internal compiler errors.
|
|
|
|
|
Yeah I saw this in April of 2001. I saved it in a file "Crash The Compiler.txt":
CTextView::CTextView
: CCtrlView( "GC_EditClass", 0 )
{
}
I've spent a lot of time working on various compilers, so I can understand how these cases slip through. I was however, quite proud when I found this one, for some reason.
Chris Richardson
|
|
|
|