If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > Delphi, C etc > MFC C++ ..cant delete data/recordset from database

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 06-03-04, 10:18
Indian Indian is offline
Registered User
 
Join Date: Sep 2003
Posts: 30
MFC C++ ..cant delete data/recordset from database

hi

iam using Microsoft SQL Server 2000 but i cant delete data in my program.
Ican add, read but not deleter

The user permission is set to read, write, delete, update etc allows everying in Microsoft SQL 2000 Server. is something wrong in my code ??

Code:
void CListAllDlg::OnBnClickedDelete()
{
	CDatabase db;
	CCosmetik m_pData(&db);
	int nItem=0;
	CString m_ListItem="";

	//open Recordset
	m_pData.Open(CRecordset::none);

	POSITION pos = m_list_all.GetFirstSelectedItemPosition();

	if (MessageBox("Möchten Sie diesen Datensatz wirklich löschen?","Diesen Datensatz löschen?", MB_YESNO | MB_ICONQUESTION) == IDYES)
	{
		while (pos != NULL)
		{
			nItem = m_list_all.GetNextSelectedItem(pos);
			m_ListItem = m_list_all.GetItemText(nItem,1);

			//delete data
			while(!m_pData.IsEOF())
			{	
				//found data thend delete else move to next data
				if(strcmp(m_pData.m_articel,m_ListItem)==0)
				{
					if(m_pData.CanUpdate())
					{
						m_pData.Delete();			  //delete data in database
						m_list_all.DeleteItem(nItem); //delete data in listbox
					}//end if
					else
					{
						AfxMessageBox("Produkt konnte nicht gelöscht werden", IDOK);
					}//end else
				}
				m_pData.MoveNext();
			}//end while			
		}//end while		
	}//end if
	
	//update and save data
	m_pData.Update();
	m_pData.Close();			

}//end OnBnClickedDelete


Can someone help
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On