|
RU are trying to connect to database
whose name is "SQLOLEDB.1" {it should be ".mdb",..)
Try specifying the full path name
of the data source.
Vikas Amin
Embin Technology
Bombay
vikas.amin@embin.com
|
|
|
|
|
yes I am trying to connect to database but its name is not
sqloledb. There is lot description of this word in msdn.
but i didnot understood.Anyway this type of connectivity he has used at
another place successfully but here it is giving error
void OleList::ExecuteQuery(CString str,bool refreshcol,bool fillcheckbox)
{
ptr=new CObArray;
USES_CONVERSION;
CDataSource db;
HRESULT hr = db.Open(_T("SQLOLEDB.1"), dbinit);
if (FAILED(hr))
{
AfxMessageBox("Failed To Connect Datasource");
return;
}
CSession session;
session.Open(db);
int i=0;
CCommand<cdynamicaccessor> product;
CString temp=GenerateSQL();
LONG row;
char tt[50];
hr=product.Open(session,temp, NULL, &row, DBGUID_DEFAULT, true);
if (FAILED(hr))
{
AfxMessageBox("Failed To Create Table");
return;
}
if(refreshcol)
{
// coltype.RemoveAll();
DBTYPE pType;//=NULL;
for(ULONG j=0;j< product.GetColumnCount() && j < colsize;j++)
if(product.GetColumnType(j+1,&pType))
coltype->SetAt(j,pType);
}
i=0;
if(product.MoveFirst()==S_OK)
do{
CStringArray* sarr=new CStringArray;
sarr->SetSize(colsize);
for(int k=1;k<=colsize;k++)
{
CString st;
switch(coltype->GetAt(k-1))
{
case DBTYPE_STR :
{
char* tm=(char*)product.GetValue(k);
st=A2T(tm);break;
}
case DBTYPE_DBTIMESTAMP : st=GetTime(product.GetValue(k)); break;
case DBTYPE_BOOL : GetBool(product.GetValue(k),&st); break;
case DBTYPE_R4 : GetFloat(product.GetValue(k),&st); break;
case DBTYPE_R8 : GetDouble(product.GetValue(k),&st); break;
case DBTYPE_I4 : GetLong(product.GetValue(k),&st); break;
case DBTYPE_I2 : GetSort(product.GetValue(k),&st); break;
case DBTYPE_UI1 : GetUInt(product.GetValue(k),&st); break;
}
/*if(k==1)
InsertItem(i,st);
else
SetItemText(i,k-1,st);*/
st.TrimRight();
sarr->SetAt(k-1,st);
}
ptr->Add(sarr);
i++;
product.FreeRecordMemory();
}while(product.MoveNext()==S_OK);
if(checkarr!=NULL)
checkarr->RemoveAll();
checkarr=new CWordArray;
checkarr->SetSize(i);
for(int m=0;m<i;m++)
checkarr-="">SetAt(m,fillcheckbox+1);
SetItemCountEx(i);
//char tt[50];
//AfxMessageBox(itoa(i,tt,10));
// SetItemCount(i);
Invalidate();
m_HeaderCtrl.listsize=i;
m_HeaderCtrl.checkarr=checkarr;
product.Close();
session.Close();
db.Close();
m_HeaderCtrl.ptr=ptr;
SetCursor(hcurSave);
}
|| ART OF LIVING ||
|
|
|
|
|
MY PROBLEM IS UNSOLVED
|| ART OF LIVING ||
|
|
|
|
|
shivditya wrote: ...but here it is giving error
What's the error?
"Take only what you need and leave the land as you found it." - Native American Proverb
|
|
|
|
|
-----> hr = db.Open(_T("SQLOLEDB.1"), dbinit);
if (FAILED(hr))
{AfxMessageBox("Failed To Connect Datasource"); }
My code is terminating on above line please help.
Actually senior programmer who developed code left for me to debug
help.
|| ART OF LIVING ||
|
|
|
|
|
You already mentioned this. I asked what the error is that you are receiving. Have you stepped into the Open() method to see what the problem might be?
"Take only what you need and leave the land as you found it." - Native American Proverb
|
|
|
|
|
We want to change the format and the attribute of the .wav
media file.How we can change this format.
Hi i am am fine now a day.
ok bye take care
|
|
|
|
|
You can pass the data through the audio compression manager.
|
|
|
|
|
Dear All,
In VC++, I don't know the function to get the full path of execute file.
I found AfxGetApp()->m_pszExeName, but it return execute name only.
Please help me to find this function.
Thanks alot.
inew
|
|
|
|
|
|
//->Get the application path for the database
CString app_path=GetModuleLoadPath();
Use this code u will get the file name in the
format as (D:\\PMR\\vc++\\conndevices.mdb)
enjoy
Vikas Amin
Embin Technology
Bombay
vikas.amin@embin.com
|
|
|
|
|
inew wrote: I found AfxGetApp()->m_pszExeName, but it return execute name only.
GetModuleFileName is only Function that can reterive file path for you..
http://alok.bizhat.com/site/tipandtrick.php?tiptype=2&tipid=55#55[^]
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
|
|
|
|
|
When I click a tab page I want to be able to set a flag to indicate to the system that this page has been visited.
Something like OnGetFocus(). Does such a funciton or something similar exist?
Basically when a page gets focus it needs to ensure that any activity on its sister page has been saved before it can proceed, so the sister page will need to have set something
GER
Ger
|
|
|
|
|
Hi
I have done something like that before... the information on the previous tab needs to be save when another tab is selected.. this is what i have done...
1. Create a variable to store the selected tab...
2. Use OnClickTab to find out which is the newly selected tab...
3. Check if different from last selected tab - if true... prompt save and save previous tab...
4. Refresh the information on the new tab...
5. Save new tab selection to variable
I hope this helps...
Thomas
|
|
|
|
|
U needs to save last tab info when another tab is selected
Vikas Amin
Embin Technology
Bombay
vikas.amin@embin.com
|
|
|
|
|
OnClickTab - Now that sounds like a very good idea. I'll try it out...
Thanks
Ger
|
|
|
|
|
Ger Hayden wrote: When I click a tab page I want to be able to set a flag to indicate to the system that this page has been visited.
A page will have an invalid window handle until it has been visited at least once.
Ger Hayden wrote: Basically when a page gets focus it needs to ensure that any activity on its sister page has been saved before it can proceed, so the sister page will need to have set something
This is what OnKillFocus() is for.
"Take only what you need and leave the land as you found it." - Native American Proverb
|
|
|
|
|
How to know whether the sound card is an 5.1/7.1 channels audio supported card by code?
|
|
|
|
|
can someone please explaing what type is UINT_PTR. Is it pointer to unsigned integer or just an alias for unsigned integer?
after looking in basetsd.h file I found it is defined as :
typedef _W64 int INT_PTR;
so it seems it is unsigned integer, but then why people at microsoft has choosen such an ambiguous name for it or is it just PTR doesnt mean pointer and I am misinterpreting it.
thanks
-Saurabh
-- modified at 4:03 Friday 4th November, 2005
|
|
|
|
|
|
Like Johann said, it's used to treat a pointer as an UINT. There's INT_PTR, which treats the pointer as an INT and so on.
Pretty useful for writing platform independent code. Simply casting a pointer to unsigned int won't work on a 64 bit platform, for example.
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
There is 2 definitions for UINT_PTR:
if _WIN64 is defined it is a unsigned __int64 (a integer on 64 bit)
if not it is defined as an unsigned int (a integer on 32 bit)
Eric
|
|
|
|
|
#include <vector>
#include <fstream>
#include <iostream>
//英文检索程序
using namespace std;
typedef struct Line
{
int LineNumber; //行数
int Pos; //位置
} LINE;
vector< LINE > Array_Line(200);
//进行字符串的分割
int partition( char * s1 , char * s2 , int pos )
{
int i = pos; //从欲分割的位置开始进行分割
while( s1[i] == ' ' ) //忽略字符串前的所有空格符号
{
i++;
}
if( s1[i] != '\0' ) //判断字符是否已结束
{
int j = 0;
//复制非空格符直到找到下一个空格符
while( s1[i] != '\0' && s1[i] != ' ' )
{
s2[j] = s1[i];
i++;
j++;
}
s2[j] = '\0'; //设置分割字符串之结束字符
return i;
}
return -1;
}
//子字符串的判断
bool Juge( char * strDes , char * strS )
{
int len = strlen( strDes );
for( int i = 0 ; i < len ; i++ )
{
if( strDes[i] != strS[i] )
{
return false;
}
else if( strDes[i] == strS[i] && i == ( len - 1 ) )
{
return true;
}
}
return false;
}
//在一篇文档里找出某字符串的所有行号和个数
int Counter( ifstream file , char * str )
{
int Counter = 0; //设置计数变量起始值
int Number = 0;
int index = 0;
int times = 0;
int position = 0;
char strChar[1024] = {' '};
char partition_string[255] = {' '};
while( !file.eof() )
{
Counter++; //行数加一
file.getline( strChar , 1024 , '\n' ); //读取一行的内容
int tmp = 0;
int pos = 0;
while( ( position = partition( strChar , partition_string , position ) ) != -1 )
{
pos++;
if( Juge( str , partition_string ) )
{
tmp++;
Array_Line[index].LineNumber = Counter;
Array_Line[index].Pos = pos;
Number += tmp;
index++;
}
}
}
return Number; //返回计数值
}
void main()
{
ifstream fin("I:\\Str.dat");
int number = Counter( fin , "cat" );
cout<
|
|
|
|
|
Exactly what's the problem/bug?
|
|
|
|
|