Click here to Skip to main content
15,919,893 members
Home / Discussions / Database
   

Database

 
GeneralRe: Need to convert the content of one field into several from a view Pin
numbrel18-Feb-05 12:46
numbrel18-Feb-05 12:46 
Generalcannot add new records with multiple fields Pin
elephantstar17-Feb-05 8:31
elephantstar17-Feb-05 8:31 
GeneralRe: cannot add new records with multiple fields Pin
elephantstar17-Feb-05 10:14
elephantstar17-Feb-05 10:14 
GeneralCompare datarows Pin
pedros7316-Feb-05 10:02
pedros7316-Feb-05 10:02 
GeneralRe: Compare datarows Pin
Just Greeky Creek16-Feb-05 21:19
Just Greeky Creek16-Feb-05 21:19 
GeneralRe: Compare datarows Pin
pedros7316-Feb-05 22:47
pedros7316-Feb-05 22:47 
GeneralRe: Compare datarows Pin
Just Greeky Creek16-Feb-05 22:56
Just Greeky Creek16-Feb-05 22:56 
GeneralDelete question Pin
Tom Wright16-Feb-05 8:57
Tom Wright16-Feb-05 8:57 
As I read in all my records from a Recordset, I want to delete them.
Will this code work:
<br />
	try<br />
	{<br />
		CString mySelect;<br />
		//mySelect.Format("SELECT TOP 1 MDC1_DATA_TEXT FROM MDC1 WHERE (MDC1_I_O = 'O')");<br />
		mySelect.Format("SELECT MDC1_DATA_TEXT FROM MDC1 WHERE (MDC1_I_O = 'O')");<br />
		pCommand.CreateInstance(__uuidof(Command));<br />
		pCommand->ActiveConnection = m_pConnection;<br />
		pCommand->CommandText = _bstr_t(mySelect);<br />
		pRecordset.CreateInstance(__uuidof(Recordset));<br />
		pRecordset->CursorLocation = adUseClient;<br />
		pRecordset->Open((IDispatch*) pCommand, <br />
			vtMissing,<br />
			adOpenStatic,<br />
			adLockBatchOptimistic,<br />
			adCmdUnknown);<br />
		_variant_t MDC1_DATA_TEXT;<br />
		_variant_t MDC1_REV_DATE;<br />
		int recCount = pRecordset->GetRecordCount();<br />
		while (!pRecordset->adoEOF)<br />
		{<br />
			MDC1_DATA_TEXT = pRecordset->GetCollect("MDC1_DATA_TEXT");<br />
			int strLength = strlen((char*)_bstr_t(MDC1_DATA_TEXT));<br />
			if (MDC1_DATA_TEXT.vt != VT_NULL)<br />
			{<br />
				m_sConnectSocket.Send((char*)_bstr_t(MDC1_DATA_TEXT), strLength);<br />
				pRecordset->Delete(adAffectCurrent);<br />
				pRecordset->UpdateBatch(adAffectCurrent);<br />
<br />
<br />
			}<br />
			pRecordset->MoveNext();<br />
		}<br />
	}<br />
	catch (_com_error &e)<br />
	{<br />
		_bstr_t bstrError(e.ErrorMessage());<br />
		CString strError = (char*)bstrError;<br />
		AfxMessageBox(strError);<br />
	}<br />
	catch (...)<br />
	{<br />
		AfxMessageBox("Unknown Error!");<br />
	}<br />
<br />
<br />

So after I read in each records that has a 'O', I want to delete it with these commands:
pRecordset->Delete(adAffectCurrent);
pRecordset->UpdateBatch(adAffectCurrent);
Then read the next record that has an 'O', then delete it....so on and so forth.

Will the Delete and UpdateBatch work for me?

Thanks

Tom Wright
tawright915@yahoo.com
GeneralRe: Delete question Pin
Mike Dimmick17-Feb-05 1:25
Mike Dimmick17-Feb-05 1:25 
GeneralRe: Delete question Pin
Tom Wright17-Feb-05 4:22
Tom Wright17-Feb-05 4:22 
GeneralRe: Delete question Pin
Rob Graham17-Feb-05 7:39
Rob Graham17-Feb-05 7:39 
GeneralDataGrid Columns Pin
numbrel16-Feb-05 5:40
numbrel16-Feb-05 5:40 
GeneralRe: DataGrid Columns Pin
Just Greeky Creek16-Feb-05 21:15
Just Greeky Creek16-Feb-05 21:15 
GeneralRe: DataGrid Columns Pin
numbrel17-Feb-05 3:06
numbrel17-Feb-05 3:06 
GeneralSQL Guru challenge :) Or just a simple query question Pin
Richard Parsons16-Feb-05 3:07
Richard Parsons16-Feb-05 3:07 
GeneralRe: SQL Guru challenge :) Or just a simple query question Pin
Michael Potter16-Feb-05 3:24
Michael Potter16-Feb-05 3:24 
GeneralRe: SQL Guru challenge :) Or just a simple query question Pin
Richard Parsons16-Feb-05 6:50
Richard Parsons16-Feb-05 6:50 
GeneralTest data script Pin
Richard Parsons16-Feb-05 6:51
Richard Parsons16-Feb-05 6:51 
GeneralEDIT: SQL Guru challenge :) Or just a simple query question Pin
Richard Parsons16-Feb-05 7:27
Richard Parsons16-Feb-05 7:27 
GeneralRe: EDIT: SQL Guru challenge :) Or just a simple query question Pin
Michael Potter16-Feb-05 8:49
Michael Potter16-Feb-05 8:49 
GeneralRe: EDIT: SQL Guru challenge :) Or just a simple query question Pin
Richard Parsons16-Feb-05 11:34
Richard Parsons16-Feb-05 11:34 
GeneralRe: SQL Guru challenge :) Or just a simple query question Pin
NassosReyzidis10-Mar-05 1:11
NassosReyzidis10-Mar-05 1:11 
Generalprob in sp Pin
amalatsliit15-Feb-05 16:46
amalatsliit15-Feb-05 16:46 
GeneralRe: prob in sp Pin
Rob Graham16-Feb-05 15:59
Rob Graham16-Feb-05 15:59 
GeneralRe: prob in sp Pin
amalatsliit16-Feb-05 19:33
amalatsliit16-Feb-05 19:33 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.