|
Sorry.
Omar - VC++ Programmer
|
|
|
|
|
I have an 'image' field that I would like to use to store files. I open the file using a CFile object then read the bytes into a BYTE array. But how do I use that to insert the contents of the byte array. My insert statement would look something like this:
str.Format("INSERT INTO tblFile (name,data) VALUES ('%s',??)","file.txt",??);
the question marks indicate where I don't know what to put. any help would be appreciated. Thanks in advance.
[insert witty comment here]
bdiamond
|
|
|
|
|
One way to do it is to specify the binary data in hex. For instance...
INSERT INTO tblSomething (BinaryColumn) VALUES (0xFF) However, I'd suggest using ADO properties and methods for this to avoid messing with the hex conversions, etc.
Search online for SQL Server and BLOBs and you're bound to find an example or two.
Jeremy Falcon
|
|
|
|
|
You could possibly use a Stored Procedure ang get this to reade the fil directly and then insert it into the database.
store your internet favourites online - www.my-faves.co.uk
|
|
|
|
|
Hello
I use MFC in a DLL. When linking, i get a messinge telling that _DllMain@12 symbol is already defined in a library
nafxcwd.lib and there is a conflict with the symbol defined in my program. Isn't it possible to use MFC in a DLL ? If
possible, how to do it ?
Thank you
|
|
|
|
|
|
Thank you, but I hava already tried this. This is not exactly my problem. In your example, there is a conflict between two libraries, so you have to include them in the right order. For instance ' mfcs42d.lib(dllmodul.obj): error LNK2005: _DllMain@12 already defined in
msvcrtd.lib(dllmain.obj)'
In my problem, the symbol is already defined in prog.obj (which must be the object code associated with my code prog.cpp) :
'msvcrtd.lib(dllmodul.obj) : error LNK2005: _DllMain@12 already defined in prog.obj'
As I'm developping a DLL, I think there is a conflict between my DllMain and the one from the library
|
|
|
|
|
I have (perhaps) solved the problem by including my DllMain in a namespace. The DLL is compiled and linked, but I can't use my dialog :
CDlgParamSynchro* dlg = new CDlgParamSynchro
(CWnd::FromHandle(this->h_fen)) ;
dlg->DoModal() ;
(this->h_fen is a HWND on a window)
The dialog is initialized then display but frozen
|
|
|
|
|
I've solved my problem by including my DllMain in a namespace
|
|
|
|
|
well Im working on clock program...
BOOL CMyDigClockDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// Add "About..." menu item to system menu.
// IDM_ABOUTBOX must be in the system command range.
ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
ASSERT(IDM_ABOUTBOX < 0xF000);
CMenu* pSysMenu = GetSystemMenu(FALSE);
if (pSysMenu != NULL)
{
CString strAboutMenu;
strAboutMenu.LoadString(IDS_ABOUTBOX);
if (!strAboutMenu.IsEmpty())
{
pSysMenu->AppendMenu(MF_SEPARATOR);
pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
}
}
// Set the icon for this dialog. The framework does this automatically
// when the application's main window is not a dialog
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon
// TODO: Add extra initialization here
SYSTEMTIME CurTime;
CString Time, tmp;
GetLocalTime(&CurTime);
bool cPM = false;
if(CurTime.wHour >12) {
CurTime.wHour -= 12;
cPM = true; }
Time.Format("%u:", CurTime.wHour);
if(CurTime.wMinute <= 9)
{
tmp.Format("0%u:", CurTime.wMinute);
Time.Insert(Time.GetLength(),tmp.GetBuffer(tmp.GetLength()));
}
else {
tmp.Format("%u:",CurTime.wMinute);
Time.Insert(Time.GetLength(),tmp.GetBuffer(tmp.GetLength()));
}
if(CurTime.wSecond <= 9)
{
tmp.Empty();
tmp.Format("0%u", CurTime.wSecond);
Time.Insert(Time.GetLength(),tmp.GetBuffer(tmp.GetLength()));
}
else {
tmp.Empty();
tmp.Format("%u",CurTime.wSecond);
Time.Insert(Time.GetLength(),tmp.GetBuffer(tmp.GetLength()));
}
if(cPM == true)
{
Time.Insert(Time.GetLength()," PM");
}
else {
Time.Insert(Time.GetLength()," AM");
}
m_clock.SetWindowText(Time);
SetTimer(55,1000,NULL);
char sIniFile[MAX_PATH];
GetModuleFileName( NULL, sIniFile, MAX_PATH );
strcpy( strrchr( sIniFile, '\\' ) + 1, "reminderclock.ini" );
char getname[MAX_PATH];
char gethour[MAX_PATH];
char getminutes[MAX_PATH];
char getname2[MAX_PATH];
char gethour2[MAX_PATH];
char getminutes2[MAX_PATH];
char getname3[MAX_PATH];
char gethour3[MAX_PATH];
char getminutes3[MAX_PATH];
char getname4[MAX_PATH];
char gethour4[MAX_PATH];
char getminutes4[MAX_PATH];
char getname5[MAX_PATH];
char gethour5[MAX_PATH];
char getminutes5[MAX_PATH];
char getname6[MAX_PATH];
char gethour6[MAX_PATH];
char getminutes6[MAX_PATH];
GetPrivateProfileString("BOX1", "Title", "", getname, sizeof(getname), sIniFile);
GetPrivateProfileString("BOX1", "Hour", "", gethour, sizeof(gethour), sIniFile);
GetPrivateProfileString("BOX1", "Minutes", "", getminutes, sizeof(getminutes), sIniFile);
GetPrivateProfileString("BOX2", "Title", "", getname2, sizeof(getname2), sIniFile);
GetPrivateProfileString("BOX2", "Hour", "", gethour2, sizeof(gethour2), sIniFile);
GetPrivateProfileString("BOX2", "Minutes", "", getminutes2, sizeof(getminutes2), sIniFile);
GetPrivateProfileString("BOX3", "Title", "", getname3, sizeof(getname3), sIniFile);
GetPrivateProfileString("BOX3", "Hour", "", gethour3, sizeof(gethour3), sIniFile);
GetPrivateProfileString("BOX3", "Minutes", "", getminutes3, sizeof(getminutes3), sIniFile);
GetPrivateProfileString("BOX4", "Title", "", getname4, sizeof(getname4), sIniFile);
GetPrivateProfileString("BOX4", "Hour", "", gethour4, sizeof(gethour4), sIniFile);
GetPrivateProfileString("BOX4", "Minutes", "", getminutes4, sizeof(getminutes4), sIniFile);
GetPrivateProfileString("BOX5", "Title", "", getname5, sizeof(getname5), sIniFile);
GetPrivateProfileString("BOX5", "Hour5", "", gethour5, sizeof(gethour5), sIniFile);
GetPrivateProfileString("BOX5", "Minutes5", "", getminutes5, sizeof(getminutes5), sIniFile);
GetPrivateProfileString("BOX6", "Title", "", getname6, sizeof(getname6), sIniFile);
GetPrivateProfileString("BOX6", "Hour6", "", gethour6, sizeof(gethour6), sIniFile);
GetPrivateProfileString("BOX6", "Minutes6", "", getminutes6, sizeof(getminutes6), sIniFile);
m_name = _T(getname);
m_hour = gethour; ----- PROBLEM HERE -----
// m_minutes = getminutes;
UpdateData(FALSE);
return TRUE; // return TRUE unless you set the focus to a control
}
ERROR HERE:
--------------------Configuration: MyDigClock - Win32 Debug--------------------
Compiling...
MyDigClockDlg.cpp
C:\-= My Stuff =-\-= programs =-\-= MY CLOCKS =-\MyDigClockTest\MyDigClockDlg.cpp(268) : error C2440: '=' : cannot convert from 'char [260]' to 'int'
This conversion requires a reinterpret_cast, a C-style cast or function-style cast
Error executing cl.exe.
MyDigClock.exe - 1 error(s), 0 warning(s)
look at the bottom of the code.
m_hour = gethour; is problem.
how could get numbers from ini to load in the edit boxes properly ?
|
|
|
|
|
The problem is that gethour is a string whereas m_hour is (presumably) an int.
Instead of using GetPrivateProfileString(), you could use GetPrivateProfileInt().
store your internet favourites online - www.my-faves.co.uk
|
|
|
|
|
I'm seeing several calls to GetBuffer() without corresponding calls to ReleaseBuffer() . To that end, GetBuffer() is not even necessary in the context in which you are using it. That's what CString 's LPCTSTR operator is for.
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
I have two edit controls A and B(IDC_A,IDC_B). Their member variables are type "double". If I change A, B has automatically change (by the realationship m_myB = 2*m_myA). I have the following code (received from a member of this community)
..
void CYourDialog::OnChangeIDC_A()
{ CString str;
CWnd *pCtrl = GetDlgItem(IDC_A);
if(pCtrl)
{ pCtrl->GetWindowText(str); GetDlgItem(IDC_B)->SetWindowText(str);
}
}
In general, the code works well. That means, that the value of edit control A automatically appear in B.
But : My problem (due to I am new in C++): Where is my function (m_myB = 2*m_myA)to be placed within the code above? The program gets problems because str is a string and the variables are double. Maybe I have to use other function instead of GetWindowText ?
Thanks a lot.
|
|
|
|
|
Use this instead (if you are using MFC):
void CYourDialog::OnChangeIDC_A()
{
UpdateData(TRUE); // Save data from edit box into the variables
m_myB = 2*mmyA;
UpdateData(FALSE); // Print data from the variables into the edit boxes
}
Hope this helps
|
|
|
|
|
ive got a CListCtrl derived control with checkboxes. i want to know when the user checks/unchecks an item.
does anybody know which notification to use?
thanks
Я люблю русский языкь!
|
|
|
|
|
|
Hi!
Don't even know how to put this! So just try to guess what I mean!
In VC++ you can include this line exit(100); etc. And force the program to exit to OS with VC++ reporting, in the EXIT window: programm....exited with code (100) or something like that.
My question is this: Is there a way to tell VC++ to report 100 as say wrong argument for myFuntion(int); instead of just reporting error number?
I only want to know how to make VC report the error with description not the program itself (ie. via a dialog window).
--------------------------------------------------------
DEBUGING IS A BITCH :smiley whith brains blown out:
--------------------------------------------------------
|
|
|
|
|
CreepingFeature wrote:
Is there a way to tell VC++ to report 100 as say wrong argument for myFuntion(int); instead of just reporting error number
No, not a far as I know of.
These so called return code is some sort of the lowest common demnominator of error reporting. They are designed to work on every OS.
All you know is that '0' means 'No Error'. Other codes have to be documented (on Unix, man pages do this, but windows is deficient in this way, too) to be used in eg. batch scripts.
"We trained hard, but it seemed that every time we were beginning to form up into teams we would be reorganised. I was to learn later in life that we tend to meet any new situation by reorganising: and a wonderful method it can be for creating the illusion of progress, while producing confusion, inefficiency and demoralisation."
-- Caius Petronius, Roman Consul, 66 A.D.
|
|
|
|
|
Hello everybody,
I have a big problem, I'm looking for a function on C++, and I can't find it (I'm depressed...I nearly killed my self yesterday...)
Well, here's my problem...I'm looking for a function that will give me the smalest box that contains a set of points...
To be clear, I have a set of point in 3D....and I want the smallest box that contains all the points....
The functiuon has to be the more simple possible....because I will have to change some things...
Please help me PLEASE
Thanks in advance...
|
|
|
|
|
I don't think such a function exists... but why don't you write it yourself ??
You just have to search the minimum and maximum of all the x coordinates and the minimum and maximum of all the y coordinates. This will give you the 4 boundaries of your box. (Of course, you can apply this for 3d so search also the min & max of the z coordinates).
Hope this helps
|
|
|
|
|
You just have to....
thanks cedric, but I need this function during the next 24 hours...so I'm a little bit in a hurry....
|
|
|
|
|
god, it takes ONLY 5 minutes to write ...
one big loop and some comparisons ....
Maximilien Lincourt
Your Head A Splode - Strong Bad
|
|
|
|
|
typedef struct<br />
{<br />
float X;<br />
float Y;<br />
float Z;<br />
} 3DPOINT;<br />
<br />
void Boundary(3DPoint* pPointsArray, int Count, int &XLow, int &XHigh, int &YLow, int &YHigh, int &ZLow, int &ZHigh)<br />
{<br />
XLow = XHigh = pPointsArray[0].X;<br />
YLow = YHigh = pPointsArray[0].Y;<br />
ZLow = ZHigh = pPointsArray[0].Z;<br />
<br />
for (int i=0;i<Count;i++)<br />
{<br />
if (pPointsArray[i].X < XLow)<br />
XLow = pPointsArray[i].X;<br />
if (pPointsArray[i].X > XHigh)<br />
XHigh = pPointsArray[i].X;<br />
<br />
}<br />
<br />
}
Anonymous wrote:
thanks cedric, but I need this function during the next 24 hours...so I'm a little bit in a hurry....
I don't think this takes sooooooooooo much time to do something like that
|
|
|
|
|
ok i see now what you wanted to do....thanks a lot cedric...but I think that your technic is not optimal...
With your technique the bounding box will change if you work in an another reference, do you understand ???
I want a function that will minimize the volume and enclosing the different points .....
|
|
|
|
|
it will never be really optimal, unless the points are already partially sorted.
reference ? what do you mean ? orientation and POV ?
Maximilien Lincourt
Your Head A Splode - Strong Bad
|
|
|
|
|