Date: Mon, 14 Feb 2005 14:38:04 +0900
From: "Sakaeda" <who@sub.example.jp>
This is a multi-part message in MIME format.
------=_NextPart_000_001D_01C512A2.CAF87690
Content-Type: text/plain;
charset="iso-2022-jp"
Content-Transfer-Encoding: 7bit
こんにちは。栄田ともうします。
大変な勘違いや無知が原因でのトラブルだと考えますが、何卒ご教授くださるようお
願いいたします。
MSDEをVC++(6.0)を使用しております。(両方ともサービスパックは最新です)
またOSはWindows2000(Pro)です。
データが全く無い状態ではデータ書き込みができるのですが、
2回目から下記の場所でif文が多分FALSEになってしまうようなのです。
//
//ADO用変数
//BOOL m_IsConnectionOpen;
//_ConnectionPtr m_pConnection;
//ドキュメントクラスのヘッダにメンバ変数としています
//まずデータベースを開きます
void CSubMasterDoc::DataBaseOpen()
{
CAristoApp* pApp = (CAristoApp*)AfxGetApp();
CString DataBaseName = pApp->DataBaseName;
//データベースの名は
//CAristoApp::InitInstance()
//でファイルから読み込んでいます
HRESULT hr;
try
{
hr = m_pConnection.CreateInstance(__uuidof(Connection));
if(SUCCEEDED(hr))
{
hr = m_pConnection->Open(_bstr_t(L"Provider=sqloledb.1; Data Source="
+DataBaseName+";Initial Catalog=Data;User Id=sa;Password=;"),
_bstr_t(L""),
_bstr_t(L""),
adModeUnknown);
if(SUCCEEDED(hr))
{
m_IsConnectionOpen = TRUE;
}
}
}
catch(_com_error &e)
{
AfxMessageBox("有効なデータベース名を指定してください。""データアクセス");
_bstr_t bstrSource(e.Source());
_bstr_t bstrDescription(e.Description());
TRACE("#importによって生成されたクラスに対して例外が生成された");
TRACE("\tコード= %081x\n", e.Error());
TRACE("\tコードの意味=%s\n", e.ErrorMessage());
TRACE("\tソース=%s\n", (LPCTSTR)bstrSource);
TRACE("\t説明=%s\n", (LPCTSTR)bstrDescription);
}
catch(...)
{
AfxMessageBox("有効なデータベース名を指定してください。""データアクセス");
TRACE("****処理されない例外****");
}
}
//そしてSQL文にてテーブルを開こうとしますが....
void CSubMasterDoc::RecordTenpoData()
{
DataBaseOpen();
_RecordsetPtr pRecordSet;
_bstr_t bstrQuery("SELECT * FROM SaijiTenpo");
HRESULT hr;
_variant_t vNull;
vNull.vt = VT_ERROR;
vNull.scode = DISP_E_PARAMNOTFOUND;
try
{
hr = pRecordSet.CreateInstance(_uuidof(Recordset));
if(SUCCEEDED(hr))
{
pRecordSet->PutRefActiveConnection(m_pConnection);
hr = pRecordSet->Open(_variant_t(bstrQuery), vNull, adOpenForwardOnly,
adLockOptimistic, adCmdText);
if(SUCCEEDED(hr) && pRecordSet->BOF)//←ここでifがFALSEになってしま
うようなのです。
{
COleSafeArray vaFieldlist;
vaFieldlist.CreateOneDim(VT_VARIANT, 6);
COleSafeArray vaValuelist;
vaValuelist.CreateOneDim(VT_VARIANT, 6);
//どうかよろしくお願いいたします。
------=_NextPart_000_001D_01C512A2.CAF87690
Content-Type: text/html;
charset="iso-2022-jp"
Content-Transfer-Encoding: quoted-printable
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-2022-jp">
<META content=3D"MSHTML 6.00.2800.1491" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT face=3D"MS UI Gothic" =
size=3D2>=1B$B$3$s$K$A$O!#1IED$H$b$&$7$^$9!#=1B(B</FONT></DIV>
<DIV><FONT face=3D"MS UI Gothic"=20
size=3D2>=1B$BBgJQ$J4*0c$$$dL5CN$,860x$G$N%H%i%V%k$@$H9M$($^$9$,!"2?B4$46=
5<x$/$@$5$k$h$&$*4j$$$$$?$7$^$9!#=1B(B</FONT></DIV>
<DIV><FONT face=3D"MS UI Gothic"=20
size=3D2>MSDE=1B$B$r=1B(BVC++=1B$B!J=1B(B6.0=1B$B!K$r;HMQ$7$F$*$j$^$9!#!J=
N>J}$H$b%5!<%S%9%Q%C%/$O:G?7$G$9!K=1B(B</FONT></DIV>
<DIV><FONT face=3D"MS UI Gothic" =
size=3D2>=1B$B$^$?=1B(BOS=1B$B$O=1B(BWindows2000(Pro)=1B$B$G$9!#=1B(B</FO=
NT></DIV>
<DIV><FONT face=3D"MS UI Gothic" =
size=3D2>=1B$B%G!<%?$,A4$/L5$$>uBV$G$O%G!<%?=3Dq$-9~$_$,$G$-$k$N$G$9$,!"=1B=
(B</FONT></DIV>
<DIV><FONT face=3D"MS UI Gothic"=20
size=3D2>=1B$B#22sL\$+$i2<5-$N>l=3Dj$G=1B(Bif=1B$BJ8$,B?J,#F#A#L#S#E$K$J$=
C$F$7$^$&$h$&$J$N$G$9!#=1B(B</FONT></DIV>
<DIV><FONT face=3D"MS UI Gothic" size=3D2></FONT> </DIV>
<DIV><FONT face=3D"MS UI Gothic" size=3D2>//</FONT></DIV>
<DIV><FONT face=3D"MS UI Gothic" =
size=3D2>//=1B$B#A#D#OMQJQ?t=1B(B<BR> //BOOL=20
m_IsConnectionOpen;<BR> //_ConnectionPtr =
m_pConnection;</FONT></DIV>
<DIV><FONT face=3D"MS UI Gothic" =
size=3D2>//=1B$B%I%-%e%a%s%H%/%i%9$N%X%C%@$K%a%s%PJQ?t$H$7$F$$$^$9=1B(B</=
FONT></DIV>
<DIV><FONT face=3D"MS UI Gothic" size=3D2></FONT> </DIV>
<DIV><FONT face=3D"MS UI Gothic" =
size=3D2>//=1B$B$^$:%G!<%?%Y!<%9$r3+$-$^$9=1B(B</FONT></DIV>
<DIV><FONT face=3D"MS UI Gothic" size=3D2>void=20
CSubMasterDoc::DataBaseOpen()<BR>{<BR> CAristoApp* pApp =3D=20
(CAristoApp*)AfxGetApp();<BR> CString DataBaseName =3D=20
pApp->DataBaseName;</FONT></DIV>
<DIV><FONT face=3D"MS UI Gothic" =
size=3D2>//=1B$B%G!<%?%Y!<%9$NL>$O=1B(B</FONT></DIV>
<DIV><FONT face=3D"MS UI Gothic" =
size=3D2>//CAristoApp::InitInstance()</FONT></DIV>
<DIV><FONT face=3D"MS UI Gothic" =
size=3D2>//=1B$B$G%U%!%$%k$+$iFI$_9~$s$G$$$^$9=1B(B</FONT></DIV>
<DIV><FONT face=3D"MS UI Gothic" size=3D2></FONT> </DIV>
<DIV><FONT face=3D"MS UI Gothic" size=3D2> HRESULT=20
hr;<BR> try<BR> {<BR> hr =3D=20
m_pConnection.CreateInstance(__uuidof(Connection));<BR> if(SUC=
CEEDED(hr))<BR> { <BR> <BR> &=
nbsp;hr=20
=3D m_pConnection->Open(_bstr_t(L"Provider=3Dsqloledb.1; Data =
Source=3D"=20
+DataBaseName+";Initial Catalog=3DData;User=20
Id=3Dsa;Password=3D;"),<BR> _bstr_t(L""),<BR>  =
; _bstr_t(L""),<BR> adModeUnknown);</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=3D"MS UI Gothic"=20
size=3D2> if(SUCCEEDED(hr))<BR> {<BR>&n=
bsp; m_IsConnectionOpen=20
=3D=20
TRUE;<BR> }<BR> }<BR> }<BR> catch(_=
com_error=20
&e)<BR> {<BR> AfxMessageBox("=1B$BM-8z$J%G!<%?%Y!<%9L=
>$r;XDj$7$F$/$@$5$$!#=1B(B""=1B$B%G!<%?%"%/%;%9=1B(B");<BR> _b=
str_t=20
bstrSource(e.Source());<BR> _bstr_t=20
bstrDescription(e.Description());<BR> TRACE("#import=1B$B$K$h$=
C$F@8@.$5$l$?%/%i%9$KBP$7$FNc30$,@8@.$5$l$?=1B(B");<BR> TRACE(=
"\t=1B$B%3!<%I!a!!=1B(B%081x\n",=20
e.Error());<BR> TRACE("\t=1B$B%3!<%I$N0UL#!a=1B(B%s\n",=20
e.ErrorMessage());<BR> TRACE("\t=1B$B%=3D!<%9!a=1B(B%s\n",=20
(LPCTSTR)bstrSource);<BR> TRACE("\t=1B$B@bL@!a=1B(B%s\n",=20
(LPCTSTR)bstrDescription);<BR> }<BR> catch(...)<BR> {<BR>&=
nbsp; AfxMessageBox("=1B$BM-8z$J%G!<%?%Y!<%9L>$r;XDj$7$F$/$@$5$$!#=1B=
(B""=1B$B%G!<%?%"%/%;%9=1B(B");<BR> TRACE("****=1B$B=3DhM}$5$l=
$J$$Nc30=1B(B****");<BR> }</FONT></DIV>
<DIV><FONT face=3D"MS UI Gothic" size=3D2>}</FONT></DIV>
<DIV><FONT face=3D"MS UI Gothic" size=3D2></FONT> </DIV>
<DIV><FONT face=3D"MS UI Gothic" =
size=3D2>//=1B$B$=3D$7$F#S#Q#LJ8$K$F%F!<%V%k$r3+$3$&$H$7$^$9$,=1B(B....</=
FONT></DIV>
<DIV><FONT face=3D"MS UI Gothic" size=3D2>void=20
CSubMasterDoc::RecordTenpoData()<BR>{<BR> DataBaseOpen();</FONT></DI=
V>
<DIV> </DIV>
<DIV><FONT face=3D"MS UI Gothic" size=3D2> _RecordsetPtr=20
pRecordSet;<BR> _bstr_t bstrQuery("SELECT * FROM=20
SaijiTenpo");<BR> HRESULT hr;</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=3D"MS UI Gothic" size=3D2> _variant_t =
vNull;<BR> vNull.vt=20
=3D VT_ERROR;<BR> vNull.scode =3D =
DISP_E_PARAMNOTFOUND;</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=3D"MS UI Gothic" =
size=3D2> try<BR> {<BR> hr =3D=20
pRecordSet.CreateInstance(_uuidof(Recordset));<BR> if(SUCCEEDE=
D(hr))<BR> {<BR> pRecordSet->PutRefActiveC=
onnection(m_pConnection);<BR> hr=20
=3D pRecordSet->Open(_variant_t(bstrQuery), vNull, adOpenForwardOnly, =
adLockOptimistic, adCmdText);<BR> if(SUCCEEDED(hr) =
&&=20
pRecordSet->BOF)//=1B$B"+$3$3$G=1B(Bif=1B$B$,#F#A#L#S#E$K$J$C$F$7$^$&$=
h$&$J$N$G$9!#=1B(B<BR> {<BR> COle=
SafeArray=20
vaFieldlist;<BR> vaFieldlist.CreateOneDim(VT_VARIA=
NT,=20
6);<BR> COleSafeArray=20
vaValuelist;<BR> vaValuelist.CreateOneDim(VT_VARIA=
NT,=20
6);<BR>//=1B$B$I$&$+$h$m$7$/$*4j$$$$$?$7$^$9!#=1B(B</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=3D"MS UI Gothic" size=3D2></FONT> </DIV>
<DIV><FONT face=3D"MS UI Gothic" =
size=3D2></FONT> </DIV></BODY></HTML>
------=_NextPart_000_001D_01C512A2.CAF87690--
[MSDE/SQLServerに関して、今、どんなことにお困りですか?] |
よろしければお困りの内容を、電子メールで教えて下さい。 |
質問を電子メールで作成する
|
[ウィンドを閉じる][MSDE/SQLServer FAQ ][MSDE / MSDE2000 技術サポート情報一覧]
|