If it is an external IP address, the following
Strsql = "provider = sqloledb; server = gooyan; database = skillsbox; uid = sa; Pwd = aaaaaaaa ";
Change server to IP address.
The LAN can be an IP address or a machine name.
Follow these steps
1. Add stdafx. h
# Import "C: \ Program Files \ common files \ System \ ADO \ msado15.dll" no_namespace Rename ("EOF", "adoeof ")
2. Add the initinstance in the app file
If (s_ OK! = Oleinitialize (null ))
{
Afxmessagebox ("COM Component Library initialization error ");
}
The following are database operations.
_ Connectionptr pconn;
_ Recordsetptr PRS;
Cstring strsql;
Pconn. createinstance (_ uuidof (connection ));
Pconn-> cursorlocation = aduseclient;
Strsql = "provider = sqloledb; server = gooyan; database = skillsbox; uid = sa; Pwd = aaaaaaaa ";
Pconn-> open (_ bstr_t (strsql), "", "",-1 );
PRS. createinstance (_ uuidof (recordset ));
PRS-> cursorlocation = aduseclient;
PRS-> putactiveconnection (pconn. getinterfaceptr ());
Prs1.createinstance (_ uuidof (recordset ));
Prs1-> cursorlocation = aduseclient;
Prs1-> putactiveconnection (pconn. getinterfaceptr ());
Strsql = "select * From catalog order by cataid ";
PRS-> open (_ bstr_t (strsql), vtmissing, adopendynamic, adlockbatchoptimistic, adshorttext );