|
Hi all,
I am Savtri here.I am having 3 field in table,Slnumber,Name, and PhoneNumber.Slnumber is of type Autonumber, and Name and phonenumber are text.when I add New element then it is incrementing.but when i am deleting it is not decrementing it means if i have 5 values like 1,2,3,4,5.if delete 3rd value then my table cantains 4 values.so please tell me How Shall i do it.I am doing Updation also.But I want ot Update the both the fields name and Phonenumber and in where clause i want to check slnumber.Like SqlString="UPDATE ADDRESBOOK SET name="" AND Phonenumber="" WHERE SlNumber=""";But Not getting How TO GET THAT SLNUMBER FROM THE TABLE into the variable.
PLEASE TELL ME.HELP ME.
Thanks in Advance,
savitri
|
|
|
|
|
savitri wrote: but when i am deleting it is not decrementing
No, it does not work that way. The end. If you want this behaviour, then you need to write your own code to do it, and not use an autonumber. And, that is ridiculous. Imagine you have 6 values. You delete value 4. You have anoher table that references this table ( that's the main thing the autonumbers are used for ). Why would you want to go and change the 5 and 6 to 4 and 5 AND try to change all references to them accordingly ? What if references exist out side the DB ?
It seems to me you have no idea about databases, and should be buying a beginners book and working through it.
Numeric types do not go into quotes.
UPDATE ADDRESSBOOK SET name ='fred' and Phonenumber = '123424243' where slNumber = 1
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
ok thanku.i am taking that slnumber in irec value from the table it is printing correctly.but i am getting how shall i use the iRec variable to slnumber in update query.i am doing like this:
SqlString="UPDATE AddressBook SET Name='"+sCAtID+"' AND PhoneNumber='"+sCAtegory+"' WHERE SlNumber="+iRec+"";
but it is giving error as '+' cannot overloads.
Please tell me how can write this.
HELP ME PLEASE.
THANKS A LOT,
Savitri
|
|
|
|
|
Saviri Ji,
+ cannot concatenate int to string. Convert iRec value into string.
|
|
|
|
|
autonumber is int know.how it is compare with string .please modify my that SQL statement and tell me how can i do it.
thanku,
savitri
|
|
|
|
|
CString strRec = _T("");
strRec.Format(_T("%d"), iRec);
SqlString="UPDATE AddressBook SET Name='"+sCAtID+"' AND PhoneNumber='"+sCAtegory+"' WHERE SlNumber="+strRec+"";
|
|
|
|
|
no it is not working.i am getting error.like datatype mismatch.
|
|
|
|
|
Two people have told you the same thing now. Perhaps if you told us the EXACT error message. Also, please note, you should have asked this in the SQL forum.
Are you getting an error trying to build the string ? If you're not getting that error, you're not even using C++. In C++ you need to turn the int into a string, with sprintf, or with the Format method on CString, or with itoa. If you're using a .NET language, then it will work, but again, in that case, you have asked in a forum that has NOTHING to do with your question. In that instance, you need to look at your database. If your column is a numeric type, then the SQL you're generating, will work.
The best test is to use the debugger to get the exact string you are generating, and then plug that into your database directly, so your code is out of the picture, and you're just testing the SQL.
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
And why on earth is this in the MFC forum ?
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Hi everybody!, I want to write a MFC application can create a hidden folder, but I don't know have any function allow me can do that.Thus, I hope if someone know,please tell me how to do it. Thanks alot
AS84
|
|
|
|
|
|
Please let me know how do I pass a string class string variable to a function...
Suppose
in main function
string str1("Hello");
creating a function outside main
new_function (----------)
{
.....
}
how do I pass word "Hello" to the new_function()
Please help me out.
Thanks.
|
|
|
|
|
Two different ones:
void new_function(string s)
{
}
or
void new_function(string & s)
{
}
depending on your needs.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
Replace the first option by:
void new_function(const string& s)
{
}
This achieve the same result but is more efficient: you don't duplicate the object you pass to the function. The end result is the same (and even safer) because if you were trying to modify the string (in your option), this would have no impact over the original object. With passing the object as a const reference, you ensure that what is in the fact won't try to change the object.
|
|
|
|
|
you can try str1.c_str();but this is not preferred.
A Chinese VC++ programmer
|
|
|
|
|
How use from Dll in VC++?
I have a Dll that into have a class and i will use from methods.
How define instances and variable?
Is solution LoadLibrary?
How in GetProcAddress Define a instance from Class?
|
|
|
|
|
Do you have header and library file for the DLL. If so then include the header file and link with the library file. This[^ article have step by step instructions for how to do this.
-Saurabh
|
|
|
|
|
|
I have some COM client code that I am trying to write
IAdd *pAdd = NULL ;
IClassFactory *pClassFactory= NULL ;
IUnknown *pUnknown = NULL ;
if (SUCCEEDED(CoInitializeEx(NULL, COINIT_APARTMENTTHREADED)))
{
HRESULT res = CoCreateInstance(g_MotAutoplaycfgCLSID , NULL , CLSCTX_ALL , IID_IUnknown , (void **)&pUnknown);
res = CoGetClassObject(g_MotAutoplaycfgCLSID , CLSCTX_ALL , NULL , IID_IClassFactory , (void **)pClassFactory );
if(res == E_NOINTERFACE )
{
int x = 1;
}
else if(res == E_INVALIDARG)
{
int r = GetLastError() ;
}
}
I can get this to retrive a valid pointer for pUnknown
HRESULT res = CoCreateInstance(g_MotAutoplaycfgCLSID , NULL , CLSCTX_ALL , IID_IUnknown , (void **)&pUnknown);
However I am unable to obtain the interface Handle to IAdd Interface.
On the Server Side I can see that the ClassFactory class is created and that the Coclass is also instantiated.
Help is appreciated
Engineering is the effort !
|
|
|
|
|
You can use pUnknown->QueryInterface(.. , IAdd, ....)
Tarmo.
|
|
|
|
|
What is the error you get?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
I was able to modify my client code to do this
if (SUCCEEDED(CoInitializeEx(NULL, COINIT_APARTMENTTHREADED)))
{
HRESULT res = CoGetClassObject(g_MycfgCLSID , CLSCTX_ALL , NULL , IID_IClassFactory , (void **)&pClassFactory );
if(SUCCEEDED(res))
{
res = pClassFactory->CreateInstance(0,IID_IAdd , (void **)&pAdd);
pClassFactory->Release();
}
else if(res == E_NOINTERFACE )
{
int x = 1;
}
else if(res == E_INVALIDARG)
{
int r = GetLastError() ;
}
CoUninitialize();
}
The call to
HRESULT res = CoGetClassObject(g_MycfgCLSID , CLSCTX_ALL , NULL , IID_IClassFactory , (void **)&pClassFactory );
succeeds providing a pointer to IClassFactory
However this line
res = pClassFactory->CreateInstance(0,IID_IAdd , (void **)&pAdd);
returns the following error
#define REGDB_E_IIDNOTREG _HRESULT_TYPEDEF_(0x80040155L)
Engineering is the effort !
|
|
|
|
|
It states the class you're asking for is not registered.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
Hey Friends
I have a search provider for which i need to create an installer
Found a way to do from webpage for internet explorer
i hope this will work for all browsers (not sure)
checked in firefox & it worked
now what i am looking at is install a search provider for all browsers using c++ or some other way in which i can create a setup & user does not have to go to the page & install the new Search Provider
and finally new Search Provider is available to all browsers.
Any idea?
http://www.microsoft.com/windows/ie/searchguide/en-uk/default.mspx?dcsref=http://runonce.msn.com/runonce2.aspx[^]
Regards
|
|
|
|
|