Solved

invalid object name 'dbo.pSupervisorCheck_EOL'

Posted on 2011-02-14
6
576 Views
Last Modified: 2012-05-11
Working on a program "Supervisor" written in MFC on MS Visual c++ 2005 , the program is used to log in with supervisor user name and password, then adjust the "SoftVer"data in SQL SERVER 2005.
The following code is my ADO database connection part. and attached the SQL server image and error msg image.
_ConnectionPtr pConnection = NULL;
	_CommandPtr cmmd = NULL;
	_ParameterPtr param = NULL;
	_RecordsetPtr pRs = NULL;

	HRESULT  hr= S_OK;
	_bstr_t  strCnn(_T("Provider=sqloledb; Network Library=DBMSSOCN; Data Source=555.55.555.55,1433; Initial Catalog=Central_DB; User Id='"+strRegName+"'; Password='"+strPWD+"';")); 
	
	try
	{
		TESTHR(pConnection.CreateInstance(__uuidof(Connection)));   
		hr = pConnection->Open(strCnn,"","",NULL);   
		(cmmd.CreateInstance(__uuidof(Command)));	
		

		param = cmmd->CreateParameter(_T("")/*UserName*/,adVarChar,adParamInput,strUserName.GetLength()+1,_variant_t(strUserName));   
		cmmd->Parameters->Append(param);   
		param = cmmd->CreateParameter(_T("")/*LoginPWD*/,adVarChar,adParamInput,strLoginPWD.GetLength()+1,_variant_t(strLoginPWD));   
		cmmd->Parameters->Append(param);   
		param = cmmd->CreateParameter(_T("")/*FactoryID*/,adVarChar, adParamInput,strFactoryID.GetLength()+1,_variant_t(strFactoryID));     
		cmmd->Parameters->Append(param);   
		param = cmmd->CreateParameter(_T("")/*LineID*/,adVarChar,adParamInput,strLineID.GetLength()+1,_variant_t(strLineID));   
		cmmd->Parameters->Append(param);
		//Return para
		param = cmmd->CreateParameter(_T("Result")/*Result*/,adVarChar, adParamOutput,50,_variant_t(strResult)); 
		cmmd->Parameters->Append(param);
		param = cmmd->CreateParameter(_T("Year")/*Year*/,adVarChar,adParamOutput,50,_variant_t(strYear));   
		cmmd->Parameters->Append(param);
		param = cmmd->CreateParameter(_T("Model")/*Model*/,adVarChar,adParamOutput,50,_variant_t(strUBMModel));   
		cmmd->Parameters->Append(param);
		param = cmmd->CreateParameter(_T("Material")/*Material*/,adVarChar,adParamOutput,50,_variant_t(strMaterial));   
		cmmd->Parameters->Append(param);
		param = cmmd->CreateParameter(_T("SoftwareVer")/*SoftVer*/,adVarChar,adParamOutput,50,_variant_t(strSoftVer));   
		cmmd->Parameters->Append(param);
		param = cmmd->CreateParameter(_T("CalibrationVer")/*CalVer*/,adVarChar,adParamOutput,50,_variant_t(strCalVer));   
		cmmd->Parameters->Append(param);		
		
		cmmd->CommandText=_bstr_t(_T("pLoginCheck_EOL"));   
		cmmd->ActiveConnection = pConnection;  
		cmmd->CommandType=adCmdStoredProc;     
	     
		cmmd->Execute(NULL,   NULL,   adCmdStoredProc);  

		strResult=cmmd->Parameters->GetItem(_T("Result"))->GetValue();     	
		
		
		if (strResult==_T("Fail"))
		{
			cmmd.Detach(); 
			GetDlgItem(IDC_Status)->SetWindowTextA(_T("Error:Login Fail!"));
			m_lbStatus.SetTextColor(RGB(255,0,0));
			return;
		}
		else
		{
			GetDlgItem(IDC_Status)->SetWindowTextA(_T("Login Success!"));
			strYear=cmmd->Parameters->GetItem(_T("Year"))->GetValue();
			strUBMModel=cmmd->Parameters->GetItem(_T("Model"))->GetValue();
			strMaterial=cmmd->Parameters->GetItem(_T("Material"))->GetValue();
			strSoftVer=cmmd->Parameters->GetItem(_T("SoftwareVer"))->GetValue();
			strCalVer=cmmd->Parameters->GetItem(_T("CalibrationVer"))->GetValue();
			cmmd.Detach();  

		}

Open in new window


sql procedure image error message
0
Comment
Question by:snowycanada
  • 3
  • 3
6 Comments
 
LVL 7

Expert Comment

by:lundnak
ID: 34892175
Does your userid have execute privileges on the stored procedure?
0
 

Author Comment

by:snowycanada
ID: 34894442
In database user "Steven"->propertiies->securable, It's blank.
I tried to add the procedure in the securable and give all the permission, but the problem is still.
0
 
LVL 7

Expert Comment

by:lundnak
ID: 34896694
I'm curious to find out if you are actually connecting to the SQL Server instance as that user id.
Would you be able to put a wait or sleep call in your code (wait minute or so) right before you execute the stored procedure?  Then open SQL Server management studio and run "exec sp_who2" in a SQL window in order to see what sessions are active and what the logins are.

0
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 

Author Comment

by:snowycanada
ID: 34897395
Did as Lundnak's suggestion. One more question: Why is still TODO <PRODUCT NAME> ?THE RESULT OF SP_WHO2
0
 

Author Comment

by:snowycanada
ID: 34899201
Hi Lundnak,
the error msg "invalid object message" is replaced by "Type mismatch", after I create a new procedure pSupCheck, and I copied the old procedure code into new one. The procedure looks like working, but why it coms out the error message mismatch? I delete all the code in new procedure, it still mismatch. Is it because some setting error?
0
 
LVL 7

Accepted Solution

by:
lundnak earned 500 total points
ID: 34899534
I noticed that the parameter fields for the sproc are Nvarchar, but in your code you are using adVarChar.  That is likely the issue.  You need to change one or the other.  
0

Featured Post

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
OPENDATASOURCE 8 35
insert query with value having 's 2 46
Microsoft C++ code failing in executable that worked 9 83
Error when saving to sql table a '/' 5 25
What my article will show is if you ever had to do processing to a listbox without being able to just select all the items in it. My software Visual Studio 2008 crystal report v11 My issue was I wanted to add crystal report to a form and show…
Entering time in Microsoft Access can be difficult. An input mask often bothers users more than helping them and won't catch all typing errors. This article shows how to create a textbox for 24-hour time input with full validation politely catching …
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
A company’s greatest vulnerability is their email. CEO fraud, ransomware and spear phishing attacks are the no1 threat to a company’s security. Cybercrime is responsible for the largest loss of money to companies today with losses projected to r…

932 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now