Are learning midas, we see why sql statement recently passed after fruitless! ! !

Category: C/C++ -> ActiveX/COM/DCOM Author: y_angjian Date: 2001-08-03 08:17:00
 
y_angjian
2001-08-03 08:17:00
/ / Server

h:
__published: / / IDE-managed Components
TDatabase * Database1;
TQuery * Query1;
TDataSetProvider * DataSetProvider1;

cpp:

/ / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / /
/ / Global instance of TMydataImpl
/ / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / /
TMydata * Mydata;

/ / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / /
/ / TMydata :: TMydata
/ / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / /
__fastcall TMydata: : TMydata (TComponent * Owner): TCRemoteDataModule (Owner)
{
}

STDMETHODIMP TMydataImpl :: Getsql (BSTR strsql)
{
Mydata-> Query1-> Close ();
Mydata-> Query1-> SQL-> Clear ();
Mydata-> Query1-> SQL-> Add (strsql);
Mydata-> Query1-> Open ();
}

---------------------------------------------- ----------------

/ / client
void __ fastcall TForm1 :: Button1Click (TObject * Sender)
{

String sql = txtsql-> Text;

IDispatch * disp = ; (IDispatch *) (DM-> DCOMConnection1-> AppServer);
IMydataDisp mydata ((IMydata *) disp);
mydata.Getsql (WideString (sql));

DM-> ClientDataSet1-> Open ();

}

Why DM-> ClientDataSet1-> Open (); obtained after the default to query the data set!

sql statement instead of the new data??????????????????????????????????? ??????

CSD15573817192
2001-08-03 08:31:12
1. put the server DataSetProvider11 the Options \ PoAllowCommadText property to Ture
2, it OnDAtaRequet events code:
ADODataSet1-> Close ();
ADODataSet1-> CommandText = Input;
ADODataSet1-> Open () ;
return ((TProvider *) Sender) -> Data;
3. query form in the client's public header file variable definitions: AnsiString sql ;
4. "Search" button code:
int x;
try
{

; sql = "select * from xshxjhj where";
sql = sql + "xingm like '" + Edit1-> Text + " ;% '";
sql = sql +" and xueh like' "+ Edit2-> Text +"% '";
; sql = sql + "and minz like '" + Edit3-> Text + "%'";
sql = sql + "and ; jig like '"+ Edit4-> Text +"%' ";
sql = sql +" and kebbj like '"+ Edit5- > Text + "% '";
sql = sql + "and xingb like'" + Edit6-> Text + "% '";
DataModule1-> ClientDataSet1-> Close ();
DataModule1-> ClientDataSet1-> DataRequest (sql);
DataModule1 -> ClientDataSet1-> Open ();
DBGrid1-> DataSource = DataModule1-> DataSource1;

}
catch ( ...)
{
ShowMessage ("I'm sorry operation can not be performed");
}
}
jxz29
2001-08-03 08:45:51
Master A; however I did not try your method.

I used directly
String sql = txtsql-> Text;
DM-> DCOMConnection1-> Connected = true;
DM-> ClientDataSet1-> Close ();
DM-> ClientDataSet1-> CommandText = sql;
DM-> ClientDataSet1-> Open ();
DM-> DCOMConnection1-> Connected = false;

get the same results of the query;

but a new problem comes up;

in no problem accessing the same machine, different machines situations (server, client different machines, network flow)

client has suggested: "Access denied", how to pull off?

lllyq2008
2001-08-03 09:00:41
Another: I change the server's Getsql process
STDMETHODIMP TMydataImpl :: Getsql (BSTR strsql)
{
ShowMessage (" test ");
}
as no response! If you add to this a client-side event handling process of how to deal with??

I've been in" ** _TLB. H "in the deal:
interface IMydata: public IAppServer
{
public:
virtual HRESULT STDMETHODCALLTYPE ; Getsql (BSTR strsql) = 0;
# if! defined (__TLB_NO_INTERFACE_WRAPPERS)

# endif / / __ TLB_NO_INTERFACE_WRAPPERS

};

template <class T /* IMydata */>
class TCOMIMydataT: public TComInterface <IMydata> ;, public TComInterfaceBase <IUnknown>
{
public:

HRESULT __ fastcall Getsql (BSTR strsql);
};

template <class T>
class IMydataDispT: public TAutoDriver <IMydata>
{
public:
...
HRESULT __ fastcall Getsql (BSTR strsql);
}

template <class T> ; HRESULT __ fastcall
TCOMIMydataT <T> :: Getsql (BSTR Value)
{
return (* this) -> Getsql (Value);
}

template <class T> HRESULT __ fastcall
IMydataDispT <T> :: Getsql (BSTR Value)
{
_TDispID _dispid (* this, OLETEXT ("Getsql"), DISPID (1));
TAutoArgs <1> _args;
_args [1] = Value;
return OleFunction (_dispid, _args);
}
az1010120
2001-08-03 09:11:12
Forget it; Results posted!