|
Hello,
I'm trying to write an OLE DB Wrapper class and have created a function called SetStringFieldValue and inside that function I need to set 1 columns data to the string passed to the function. I have yet to find any examples of SetData anywhere and for some reason its not working for me. Any help is greatly appreciated.
[PRE]
void COleDBWrapper::SetStringFieldValue(int nIndex, LPCTSTR lpszValue)
{
CString strValue(lpszValue);
IRowsetChange* pIRowsetChange = (IRowsetChange*)m_pUnkRowsetChange;
IRowsetUpdate* pIRowsetUpdate = (IRowsetUpdate*)m_pUnkRowsetUpdate;
IAccessor* pIAccessor = NULL;
HACCESSOR hAccessor;
ULONG cBindings = 1;
DBBINDING rgBinding[1];
memset(rgBinding, 0, sizeof(DBBINDING));
char szValue[50];
_tcscpy(szValue, strValue.GetBuffer(0));
rgBinding[0].iOrdinal = nIndex;
rgBinding[0].dwPart = DBPART_VALUE|DBPART_STATUS|DBPART_LENGTH;
rgBinding[0].obLength = (strValue.GetLength() + 1) * sizeof(TCHAR);
rgBinding[0].obStatus = (strValue.GetLength() + 1) * sizeof(TCHAR);
(CString)rgBinding[0].obValue = szValue; // -- DOESN'T DO JACK! -- //
rgBinding[0].wType = DBTYPE_STR;
rgBinding[0].pTypeInfo = NULL;
rgBinding[0].pObject = NULL;
rgBinding[0].pBindExt = NULL;
rgBinding[0].dwMemOwner = DBMEMOWNER_CLIENTOWNED;
rgBinding[0].cbMaxLen = (strValue.GetLength() + 1) * sizeof(TCHAR);
rgBinding[0].dwFlags = 0;
HRESULT hr = m_pUnkRowset->QueryInterface(IID_IAccessor, (void**)&pIAccessor);
if (FAILED(hr))
return;
hr = pIAccessor->CreateAccessor(DBACCESSOR_ROWDATA, 1, rgBinding, 0,
&hAccessor, NULL);
if (FAILED(hr))
return;
hr = pIRowsetChange->SetData(m_hRow, hAccessor, szValue);
// hr is ALWAYS DB_E_ERRORSOCCURRED
}
[/PRE]
Bret Faller
Odyssey Computing, Inc.
|
|
|
|
|
Hi,
I am using ADO tecnology to execute stored procedure.
Does anyone know how to read out a parameter from sp into VC++ variable
I need to get @file_id (which is set at the bottom of sp)
thank you,
bartek
My stored procedure:
CREATE PROCEDURE [sp_StandardFileNew]
@receive_date varchar(20),
@pj_id int,
@pj_type varchar(20),
@file_group varchar(200),
@name varchar(255),
@ext varchar(10),
@total_words int,
@dtp_pages int,
@notes varchar(500)
AS
DECLARE @file_id int,
@receive_date2 smalldatetime,
@project_id int,
@job_id int,
@group_id int
-- Check if obligatory text parameters are null
if @name is null OR @ext is null OR @pj_id is null OR @pj_type is null OR @receive_date is null
begin
return 1
end
-- Set @project_id or @job_id depending on the @pj_type [ "job" | "project" ]
if @pj_type="job" begin
set @project_id=null
set @job_id=@pj_id
end else if @pj_type="project" begin
set @project_id=@pj_id
set @job_id=null
end else begin
return 2
end
-- Check group_txt if it exists retrieve its id or create new group if it does not exist
if @file_group is not null begin
exec sp_NewFileGroup @file_group, null, @project_id, @job_id, @group_id OUTPUT
if @group_id is null begin
return 3
end
end else begin
set @group_id = null
end
-- Convert date-string format to datetime / smalldatetime
exec sp_DateConvert @receive_date, @receive_date2 OUTPUT
-- insert new row to the Files table and convert text arguments to integer values
insert into files(name, ext, receive_date, group_id, job_id, project_id, total_words, dtp_pages, file_type_id, deleted, works_count, notes)
values(@name, @ext, @receive_date2, @group_id, @job_id, @project_id, @total_words, @dtp_pages, 0, 0, 0, @notes)
set @file_id = @@identity
if @file_id is null begin
return 4
end
return 0
GO
|
|
|
|
|
You need to change the parameter declaration in your stored procedure
..
DECLARE @file_id int OUTPUT,
..
This will then return the value for you when you execute the code via ADO.
One thing to remember is that you will need to close your recordset down before you can read the value. This is only if you are not also returning a recordset
|
|
|
|
|
Hi all,
In Orcle is it possible to create a user without having the password?
If anybody knows plz tell me the procedure.
Thanx in advance.
|
|
|
|
|
I have created an excel sheet by executing a query on an external database using MS Query. Now I want the data that I have changed in the sheet to be updated back into the database from where it actually came. Is this possible? Do VB/VBScript provide any way of doing this?
Krishnan
|
|
|
|
|
Hi I want to create a simple windows that displays a message. The message would be passed to it from another application. How is this done. Any guidance would be appreciated. Is this a situation, would I use Remote procedure calls. Any help would be most appreciated.
Regards,
A Novice
|
|
|
|
|
I would like to know if the find method is the best if i want to open a field which the name is given by the user of my dlgbox application. For example, if the user write "1Y" in a edit box, my application will have to open the "1Y" field to catch value in it. So, do i have to use Find?
thanks in advance
gerald
|
|
|
|
|
Depends.
For example if the user write the EXACT text is better and more Quickly to use the command Seek, because this use the index, (you need that the field to be an index) But if the user write the no exact string how part to the string, in this case is better to use the Find.
Other solution is make a query.
Cheers!!!
Carlos Antollini.
|
|
|
|
|
Is there a performance hit if I encrypt all my database stored procedures?
|
|
|
|
|
Friends,
I'm calling an ActiveX DLL I wrote in VB from VC++. In the VB, I'm using the VB data environment to do a parameterized insert. Everything is OK until I get a duplicate key. As soon as the DataEnvironment.Commands(1).Execute statement runs, VB immeadiately returns to the C++ caller; the hResult is 0x800A0CC1, which doesn't make any sense being that the previous 812 insert suceeded. What I'm trying to do is trap the error on the VB side (using on error goto) so I can log it prior to returning to the caller. But, the error routine never runs due to the immeadiate return.
Any help will be much appriciated!
Thanks,
David Douglass
Bloomingdale, NJ
|
|
|
|
|
i have a program that connect to odbc((user DSN))
and i want to install it with installshield
i don't know that set odbc connection in install shield.
thanks
|
|
|
|
|
Can anyone suggest a report tool, add-in or something that I can use in my C++ project that tracks some basic usage data. Do most developers roll their own when they need to provide 10 or so, simple reports to screen and printer?
Any ideas would be appriciated.
Regards
Rod Hamilton
|
|
|
|
|
hi,
Does anybody know how to use SQLXML Type Library in Visual C++ programs...
I need it to do some XML-data retrieving from SQL server 7.0.Or if there is another way to use SQL Server 7.0's XML features through ADO,please let me know...
Greetings from Germany
Özgür
Bachelor of Control&Computer Engineering from IStanbul Technical University
Worked with Delphi for 6 Months
Worked with Java for 3 Months
Now ,Working with MFC,VIsual C++6.0 and ADO
|
|
|
|
|
I've got my application ready and it is running perfect under my developing computer (win95), but on an other machine (winNT) it doesn't start at all!!! No error-message is shown!
I think the proplem has to do with the control "Microsoft ADO Data Control, version 6.0 (OLEDB).lnk"
It is a matter of different paths?
"c:\windows\system\msadodc.ocx" on w95 and
"c:\winnt\system32\msadodc.ocx" on NT ?
I already use the MFC as a static lib. ADO 2.5 is installed on both computers.
Please help me!
Friedrich
|
|
|
|
|
Try to load dynamically the component... The #import <filename> is almost always a bad idea.
LoadTypeLibrary, CoCreateInstance, even old LoadLibrary can help.
Or it can be a different version control that has some methods on 95 and other on NT. Trying to call the method "7" when the interface implements only "6"...
By the way, application doesn't tell nothing? No crash, no "Debug", nothing? What does it mean "doesn't start at all"?
|
|
|
|
|
Sorry, I was not precise enough.
I didn't use the #import, I used "Project | add | Controls | Registred Active-X controls"...
(sth like that, I'm using a german visual studio)
I dragged the control with the mouse to a dialog in the dialog-editor ( and a MS-Data Grid etc )
"Nothing" means, nothing happens if i double click on the Icon in Win Explorer. Just as it wasn't there.
To Debug, i would have to install Visual sudio to the NT system. But I wanted to avoid it, cause it is always a matter: running on the development-computer is successfull, running on an other system fails:
On another NT System with Visual Studio, the application started, the starting querie succeded, but the user-queries failed (access error).
?
Thanks for your answer.
Friedrich
|
|
|
|
|
... using InstallShield. It has made a setup.exe with all things which are needed.
Thanks
Friedrich
|
|
|
|
|
Hi,
I am just a beginner in this field.I want to learn more about how to retrieve database information as XML data from SQL Server.I got the basic concept,now i need some code snippets that can let me fly.All the information that i could find on internet was for Visual Basic developers..I am working with Visual C++ and ADO and SQL Server 7.0.Can anybody show me some code or some internet sites devoted to Visual C++ developers..Also
what else,i need to be able to use XML features of SQL Server?
with greetings from Germany
Özgür
Bachelor of Control&Computer Engineering from IStanbul Technical University
Worked with Delphi for 6 Months
Worked with Java for 3 Months
Now ,Working with MFC,VIsual C++6.0 and ADO
|
|
|
|
|
Hi
I tried to make my CRecordset derived class using a dynaset instead of a snapshot, and suddenly the recordset object was readonly. Why? How can I fix it?
I'm letting the CRecordset-derived object manage my CDatabase object, and uses only default open and construction parameters.
|
|
|
|
|
I have a need to replicate and synchronize an .mdb file in VC++ 6.0. I see that the JRO contains CreateReplica() and Synchronize() methods, these are precisely what I need to do. What I need to know is how to create the Replica object, I've seen reference to IReplica in the msjro.tlb file but I'm not sure what is the Replica equivalent of _ConnectionPtr. Once I know how to create the Replica object the rest should fall into place.
Roger Cornell
|
|
|
|
|
I've got a solution for my own question now, here it is.
I've found out how to create a replica of an Access .mdb file through VC++. Here's the code.
This code goes at the end of STDAFX.H
#import "C:\\program files\\common files\\system\\ado\\msado21.tlb" \
no_namespace \
rename("EOF", "adoEOF")
#import "C:\\program files\\common files\\system\\ado\\msjro.dll"
MSJRO.DLL uses a namespace JRO.
This code goes in a .CPP file
CoInitialize(NULL);
JRO::IReplicaPtr m_pReplica;
HRESULT hr0;
hr0 = m_pReplica.CreateInstance(__uuidof( JRO::Replica ) );
if(SUCCEEDED(hr0))
{
CString m_connectString = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=D:\\JDOCS\\Data\\JDOCS.mdb";
m_pReplica->PutActiveConnection(_bstr_t(m_connectString));
CString m_repName = "D:\\JDOCS\\Data\\JDOCSRep2.mdb";
CString m_repDesc = "JDOCS Database Replica";
m_pReplica->CreateReplica(_bstr_t(m_repName), _bstr_t(m_repDesc), JRO::jrRepTypeFull, JRO::jrRepVisibilityGlobal, -1, JRO::jrRepUpdFull);
}
CoUninitialize();
Roger Cornell
|
|
|
|
|
Anyone can tell me where I can find the C/C++ source code on how page and buffer manager are
implemented in a database system? I need to get some ideas about this. Thank you
|
|
|
|
|
Hi,
Is anybody knows the procedure to interact with an excel defined table from VC++?
thanks
|
|
|
|
|
I have been staring at this for 2 hours now and can't put my finger on the problem. Any comments would be helpful:
rs is a recordset that is already opened.
Platform is IIS 5 running on Windows 2000 Pro.
Database is SQL Server 2000
<br />
if rs.supports(adAddNew) and rs.supports(adUpdate) then<br />
rs.AddNew<br />
... update fields here<br />
rs.Update<br />
end if<br />
the problem is that I get an error telling me that the database can't be updated on the rs.AddNew line!
|
|
|
|
|
I'm looking for an IDE for developing store procedure in SQL Server with debugging, context help, code assist, ecc.... Does anybody know something for me?
Thanks!
|
|
|
|
|