Showing posts with label code. Show all posts
Showing posts with label code. Show all posts

Monday, March 19, 2012

Cannot work with Scrip task

Hey guys,
It's sort of madness I guess. :))
I use Script Task.
It has no code inside, but "Dts.TaskResult = Dts.Results.Success"
I execute package. I'm getting error

Error: 0x5 at Script Task: The script files failed to load.

Task failed: Script Task
What is it? How I can fix it? What's wrong?
Thanks.

Check out this thread ...

http://forums.microsoft.com/msdn/showpost.aspx?postid=68546&siteid=1

Donald

|||Thanks. It works.

cannot view wsdl of endpoint.

i created this endpoint in SSMS:

Code Snippet

/****** Object: Endpoint [first_Endpoint] Script Date: 06/19/2007 16:39:22 ******/

CREATEENDPOINT [first_Endpoint]

AUTHORIZATION [Domain\username]--scrubbed my username out of post!

STATE=STARTED

ASHTTP(PATH=N'/sql',

PORTS=(CLEAR),

AUTHENTICATION=(NTLM,KERBEROS,INTEGRATED),

SITE=N'sitename,

CLEAR_PORT= 80,

COMPRESSION=DISABLED)

FORSOAP(

WEBMETHOD 'provideInfo'(NAME=N'[adventureworks].[dbo].[uspGetBillOfMaterials]'

,SCHEMA=DEFAULT

, FORMAT=ALL_RESULTS),BATCHES=DISABLED,

SESSIONS=DISABLED,SESSION_TIMEOUT=60,

DATABASE=N'AdventureWorks',

NAMESPACE=N'http://tempuri.org/',

SCHEMA=STANDARD,

CHARACTER_SET=XML)

When i type http://localhost/sql/provideinfo?wsdl into internet explorer, i just get a 404 page cannot be found error.

When i type http://server/sql/provideinfo?wsdl in to the browser i get a Page cannot be displayd error.

I get the same when i type http://myServerName/sql/provideinfo?wsdl

I get the same when i type http://sitename/sql/provideinfo?wsdl

Sql server is running under an account with admin access to the box and sa access to the sql server. what am i doing wrong here that i cannot view my wsdl. oh, the OS is vista.

Could it be a configuration issue that im not seeing?

Can you try the following?
http://localhost/sql?wsdl

See also http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=1372924&SiteID=1|||i tried http://localhost/sql?wsdl but still get a 401 not found error. as i am not getting the error speicifed in the link you provided, it would make me think that it is unrelated to my issue. thanks for the reply though.|||

when i use http://server/sql?wsdl i get a 502 error, a connection could not be made as the server actively refused it.

Are there some network settings i should change on my machine possibly?

|||Is server here the same name which you specified in SITE?|||no. the server and the site have different names. I have tried the url both ways though. when i specify the servername in the url, i get an iis page not found error. when i try with the sitename, i get a page cannot be displayed error.|||

The way the 'SITE' keyword value is treated is that it is passed to the OS HTTP.sys service. The HTTP.sys service uses a combination of information to determine which process to redirect the HTTP request to. In this scenario, only HTTP requests send to http://sitename/sql are redirected to this SQL Server endpoint. So, unless machine running SQL Server is named 'sitename', it is very unlikely that the HTTP request will get to SQL Server.

If possible, I recommend changing the SITE value to '*' or the actual machine name.

BTW, I believe the default value for the WSDL generation is NONE, so ?wsdl will get you a 502 HTTP error.

Jimmy

|||

Hi Jimmy.


That indeed was the problem!!! i dropped the endpoint, changed the site name to the name of the pc the endpoint is hosted upon and bingo!!!! cant believe i was so stupid in the first place!!!! it makes total sense now that i look at it! I expected to see the page that comes up when you view the definition of an enpoint in IE, but i also realise that that wont happen. i just see a lot of xml making up the wsdl file, and thats what i required. Thanks for the help and suggestions everyone, and Jimmy, for the answer that gave me the required results.

Sunday, March 11, 2012

Cannot View Master.sysdatabase Names in Webpage

I have a webpage that should display the database names from the master.sysdatabases in a dropdownlist.

The code for the stored procedure works fine in Query Analyzer and returns the list of all database names under that instance of SQL-Server 2000.

The code:

select name from master.dbo.sysdatabases
order by 1

doesn't return the sysdatabase names to the ASP.NET webpage when executing the stored procedure.

It returns:

System.Data.DataRowView

Why does it do this and how can I fix it?

Tx

I don't know what you are trying to do but the Master database and it's content are Microsoft Property, I don't think you can use them in your web application. If you look inside the Master or look at the System tables Poster you know using those tables in your application is not something you do. Hope this helps.|||Probably a permissions issue.|||

Thanks.

The lookup is for our administrative/development purposes.
Since we have multiple databases to search through, the app shows the databases, you select a database, there's a lookup and display of tables, views and sprocs, and the contents are displayed in a large textbox for cutting and pasting purposes.

So the sysdatabases lookup is needed to select though the production databases.

The sproc doing the work has remote privs.
Other than that, how would you assign a priv to access the tables?
I didn't need it in QA.

Your help is appreciated.

|||I don't think it's a security/permissions issue. The built-in stored procedure sp_databases, which does exactly what your sql query does, has its execute permissions default to thepublic role. I think the problem is in your code, so you should post your code snippet here.|||

A quick test is to run this in both the webpage and your QA and see the difference:

SELECT SUSER_NAME(),USER_NAME()

That will tell you who are logged into SQL Server as, and what login are you being mapped to.

Although, rereading your original message, herman is most likely correct. It appears that your .NET code is wrong, considering that system.whatever.dataview is a .NET class, I would say that you've assigned a dataview to a variable using the .ToString method, or have done so implicitly.

Wednesday, March 7, 2012

Cannot Trap Specific Errors

I set up the following code to trap errors after each SQL command issued. I
n
the Error_Handler section, I populate an error table which gets exported to
Microsoft Access. Up until now it has been working, however, I got an error
:
"There is already an object named 'TempCalc010' in the database", which
stopped the program immediately and did not populate the error file. Is
there anyway to trap this error and populate the error file ?
Set @.iErr = @.@.Error
If @.iErr <> 0
Begin
Set @.vErrMess = '#50 Cannot update LSDC for TC FTF.'
GoTo Error_Handler
EndImplementing Error Handling with Stored Procedures
http://www.sommarskog.se/error-handling-II.html
Error Handling in SQL Server – a Background
http://www.sommarskog.se/error-handling-I.html
AMB
"rmcompute" wrote:

> I set up the following code to trap errors after each SQL command issued.
In
> the Error_Handler section, I populate an error table which gets exported t
o
> Microsoft Access. Up until now it has been working, however, I got an err
or:
> "There is already an object named 'TempCalc010' in the database", which
> stopped the program immediately and did not populate the error file. Is
> there anyway to trap this error and populate the error file ?
> Set @.iErr = @.@.Error
> If @.iErr <> 0
> Begin
> Set @.vErrMess = '#50 Cannot update LSDC for TC FTF.'
> GoTo Error_Handler
> End
>|||What is the code in the Error_Handler?
Arnie Rowland, YACE*
"To be successful, your heart must accompany your knowledge."
*Yet Another certification Exam
"rmcompute" <rmcompute@.discussions.microsoft.com> wrote in message
news:3F35FF3B-175C-4F4A-8E4D-DF9CD01D1429@.microsoft.com...
>I set up the following code to trap errors after each SQL command issued.
>In
> the Error_Handler section, I populate an error table which gets exported
> to
> Microsoft Access. Up until now it has been working, however, I got an
> error:
> "There is already an object named 'TempCalc010' in the database", which
> stopped the program immediately and did not populate the error file. Is
> there anyway to trap this error and populate the error file ?
> Set @.iErr = @.@.Error
> If @.iErr <> 0
> Begin
> Set @.vErrMess = '#50 Cannot update LSDC for TC FTF.'
> GoTo Error_Handler
> End
>|||Exit_Procedure:
Return @.iErr
Error_Handler:
SELECT @.vErrDesc = description
FROM master.dbo.sysmessages
WHERE error = @.iErr
Set @.vErrNumMess = 'Sys #:' + RTrim(Cast(@.iErr as nvarchar(10))) + ' Sys
Desc:' +
RTrim(@.vErrDesc) + ' Prog Desc:' + RTrim(@.vErrMess)
Insert
SvcReports.dbo. tblSRProcessErrors(SysRec,Program,ErrorC
ode,SysDesc,ProgDesc)
Values('B','u_spSRCreateActualData',@.iEr
r,@.vErrDesc,@.vErrMess)
Raiserror(@.vErrNumMess,16,1,5) With Log
Goto Exit_Procedure
Go
"Arnie Rowland" wrote:

> What is the code in the Error_Handler?
> --
> Arnie Rowland, YACE*
> "To be successful, your heart must accompany your knowledge."
> *Yet Another certification Exam
>
> "rmcompute" <rmcompute@.discussions.microsoft.com> wrote in message
> news:3F35FF3B-175C-4F4A-8E4D-DF9CD01D1429@.microsoft.com...
>
>|||Where is TempCalc010 created/used/accessed?
Arnie Rowland, YACE*
"To be successful, your heart must accompany your knowledge."
*Yet Another certification Exam
"rmcompute" <rmcompute@.discussions.microsoft.com> wrote in message
news:513BE8FE-5592-45AF-B4F8-4506E67A7909@.microsoft.com...
> Exit_Procedure:
> Return @.iErr
> Error_Handler:
> SELECT @.vErrDesc = description
> FROM master.dbo.sysmessages
> WHERE error = @.iErr
> Set @.vErrNumMess = 'Sys #:' + RTrim(Cast(@.iErr as nvarchar(10))) + '
> Sys
> Desc:' +
> RTrim(@.vErrDesc) + ' Prog Desc:' + RTrim(@.vErrMess)
> Insert
> SvcReports.dbo. tblSRProcessErrors(SysRec,Program,ErrorC
ode,SysDesc,ProgDes
c)
> Values('B','u_spSRCreateActualData',@.iEr
r,@.vErrDesc,@.vErrMess)
> Raiserror(@.vErrNumMess,16,1,5) With Log
> Goto Exit_Procedure
> Go
> "Arnie Rowland" wrote:
>|||It exists in the first part of the program:
SELECT Fielda, Fieldb, Fieldc ...
INTO TempCalc010
From TempCalc005
I can prevent this error by checking if the file exists and then deleting
it before
running this step, but my question was, are there certain errors that
@.@.Error
does not catch and if so, how are those errors trapped ?
"Arnie Rowland" wrote:

> Where is TempCalc010 created/used/accessed?
> --
> Arnie Rowland, YACE*
> "To be successful, your heart must accompany your knowledge."
> *Yet Another certification Exam
>
> "rmcompute" <rmcompute@.discussions.microsoft.com> wrote in message
> news:513BE8FE-5592-45AF-B4F8-4506E67A7909@.microsoft.com...
>
>|||Yes, there are certain errors that cause an procedrue 'abort', and any error
handling code will be missed. For a better analysis of the issues, Refer
back to the articles taht Alejandro offered.
Arnie Rowland, YACE*
"To be successful, your heart must accompany your knowledge."
*Yet Another certification Exam
"rmcompute" <rmcompute@.discussions.microsoft.com> wrote in message
news:1E0C0080-6A0C-4BEB-8071-47F56FEED9E8@.microsoft.com...
> It exists in the first part of the program:
> SELECT Fielda, Fieldb, Fieldc ...
> INTO TempCalc010
> From TempCalc005
> I can prevent this error by checking if the file exists and then deleting
> it before
> running this step, but my question was, are there certain errors that
> @.@.Error
> does not catch and if so, how are those errors trapped ?
>
> "Arnie Rowland" wrote:
>|||Thank you.
"Alejandro Mesa" wrote:
> Implementing Error Handling with Stored Procedures
> http://www.sommarskog.se/error-handling-II.html
> Error Handling in SQL Server – a Background
> http://www.sommarskog.se/error-handling-I.html
>
> AMB
> "rmcompute" wrote:
>|||Ok. Thank you.
"Arnie Rowland" wrote:

> Yes, there are certain errors that cause an procedrue 'abort', and any err
or
> handling code will be missed. For a better analysis of the issues, Refer
> back to the articles taht Alejandro offered.
> --
> Arnie Rowland, YACE*
> "To be successful, your heart must accompany your knowledge."
> *Yet Another certification Exam
>
> "rmcompute" <rmcompute@.discussions.microsoft.com> wrote in message
> news:1E0C0080-6A0C-4BEB-8071-47F56FEED9E8@.microsoft.com...
>
>

Sunday, February 19, 2012

Cannot set maximum database size by DBPROP_SSCE_MAX_DATABASE_SIZE;

I try to limit the database size to 2MB by the following code, but it doesn't work, Could somebody help me on it?

Thanks a lot!

Part of my code is:

VariantInit(&dbprop[0].vValue);

VariantInit(&dbprop[1].vValue);

VariantInit(&dbprop[2].vValue);

VariantInit(&dbprop[3].vValue);

// Create an instance of the OLE DB Provider

//

hr = CoCreateInstance( CLSID_SQLSERVERCE_3_0,

0,

CLSCTX_INPROC_SERVER,

IID_IDBInitialize,

(void**)&pIDBInitialize);

if(FAILED(hr))

{

goto Exit;

}

// Initialize a property with name of database

//

dbprop[0].dwPropertyID = DBPROP_INIT_DATASOURCE;

dbprop[0].dwOptions = DBPROPOPTIONS_REQUIRED;

dbprop[0].vValue.vt = VT_BSTR;

dbprop[0].vValue.bstrVal = SysAllocString( DATABASE_LOG );

if(NULL == dbprop[0].vValue.bstrVal)

{

hr = E_OUTOFMEMORY;

goto Exit;

}

// Initialize property with open mode for database

dbprop[1].dwPropertyID = DBPROP_INIT_MODE;

dbprop[1].dwOptions = DBPROPOPTIONS_REQUIRED;

dbprop[1].vValue.vt = VT_I4;

dbprop[1].vValue.lVal = DB_MODE_READ | DB_MODE_WRITE;

// Set max database size

dbprop[2].dwPropertyID = DBPROP_SSCE_MAX_DATABASE_SIZE;

dbprop[2].dwOptions = DBPROPOPTIONS_REQUIRED;

dbprop[2].vValue.vt = VT_I4;

dbprop[2].vValue.lVal = 2; // 2MB

// set max size of temp. database file to 2MB

dbprop[3].dwPropertyID = DBPROP_SSCE_TEMPFILE_MAX_SIZE;

dbprop[3].dwOptions = DBPROPOPTIONS_REQUIRED;

dbprop[3].vValue.vt = VT_I4;

dbprop[3].vValue.lVal = 2; // 2MB

// Initialize the property set

//

dbpropset[0].guidPropertySet = DBPROPSET_DBINIT;

dbpropset[0].rgProperties = dbprop;

dbpropset[0].cProperties = sizeof(dbprop)/sizeof(dbprop[0]);

// Get IDBDataSourceAdmin interface

//

hr = pIDBInitialize->QueryInterface(IID_IDBDataSourceAdmin, (void **) &pIDBDataSourceAdmin);

if(FAILED(hr))

{

goto Exit;

}

// Create and initialize data store

//

hr = pIDBDataSourceAdmin->CreateDataSource( 1, dbpropset, NULL, IID_IUnknown, &pIUnknownSession);

if(FAILED(hr))

{

goto Exit;

}

"Max database size" does not set a limit on the physical size of the sdf file. See http://blogs.msdn.com/sqlservercompact/archive/2007/06/13/the-story-of-max-database-size-connection-string-parameter.aspx

I think there may be a minimum value, which is probably more than 2.

|||Your SSCE props need to be in a seperate propset as follows:

Code Block

DBPROPSET dbpropset[2]; // Property Set used to initialize provider
DBPROP dbprop[1]; // property array set to initialize provider
DBPROP sscedbprop[4]; // Property array for SSCE properties

//Initialize variants
VariantInit(&dbprop[0].vValue);
VariantInit(&sscedbprop[0].vValue);
VariantInit(&sscedbprop[1].vValue);
VariantInit(&sscedbprop[2].vValue);
VariantInit(&sscedbprop[3].vValue);

// Initialize a property with name of database
dbprop[0].dwPropertyID = DBPROP_INIT_DATASOURCE;
dbprop[0].dwOptions = DBPROPOPTIONS_REQUIRED;
dbprop[0].vValue.vt = VT_BSTR;
dbprop[0].vValue.bstrVal = SysAllocString(a_pwszName);
if(NULL == dbprop[0].vValue.bstrVal)
{
hr = E_OUTOFMEMORY;
goto _ExitCreate;
}

// Initialize the first property set.
dbpropset[0].guidPropertySet = DBPROPSET_DBINIT;
dbpropset[0].rgProperties = dbprop;
dbpropset[0].cProperties = sizeof(dbprop)/sizeof(dbprop[0]);

sscedbprop[0].dwPropertyID = DBPROP_SSCE_AUTO_SHRINK_THRESHOLD;
sscedbprop[0].dwOptions = DBPROPOPTIONS_REQUIRED;
sscedbprop[0].vValue.vt = VT_I4;
sscedbprop[0].vValue.intVal = 100;

sscedbprop[1].dwPropertyID = DBPROP_SSCE_MAX_DATABASE_SIZE;
sscedbprop[1].dwOptions = DBPROPOPTIONS_REQUIRED;
sscedbprop[1].vValue.vt = VT_I4;
sscedbprop[1].vValue.intVal = 4091;

if(a_pwszPass!=NULL)
{
// Specify the property for encryption.
sscedbprop[2].dwPropertyID = DBPROP_SSCE_ENCRYPTDATABASE;
sscedbprop[2].dwOptions = DBPROPOPTIONS_REQUIRED;
sscedbprop[2].vValue.vt = VT_BOOL;
sscedbprop[2].vValue.boolVal = (a_bEncrypted==TRUE)?VARIANT_TRUE:VARIANT_FALSE;

// Specify the password.
sscedbprop[3].dwPropertyID = DBPROP_SSCE_DBPASSWORD;
sscedbprop[3].dwOptions = DBPROPOPTIONS_REQUIRED;
sscedbprop[3].vValue.vt = VT_BSTR;
sscedbprop[3].vValue.bstrVal = SysAllocString(a_pwszPass);
if(NULL == sscedbprop[3].vValue.bstrVal)
{
hr = E_OUTOFMEMORY;
goto _ExitCreate;
}
}
else if(a_bEncrypted)
{
hr = E_INVALIDARG;
CHKHR(hr, L"Encrypted databases require a password", _ExitCreate);
}

dbpropset[1].guidPropertySet = DBPROPSET_SSCE_DBINIT ;
dbpropset[1].rgProperties = sscedbprop;
dbpropset[1].cProperties = sizeof(sscedbprop)/sizeof(sscedbprop[0]) - ((a_pwszPass==NULL)?2:0);

// Get IDBDataSourceAdmin interface
hr = m_pIDBInitialize->QueryInterface(IID_IDBDataSourceAdmin, (void **) &m_pIDBDataSourceAdmin);
CHKHR(hr, L"Failed to obtain IDBDataSourceAdmin interface", _ExitCreate);

// Create and initialize data store
hr = m_pIDBDataSourceAdmin->CreateDataSource(sizeof(dbpropset)/sizeof(dbpropset[0]), dbpropset, NULL, IID_IUnknown, &m_pIUnknownSession);
CHKHR(hr, L"Failed to create data source", _ExitCreate);

// Clear Variants
VariantClear(&dbprop[0].vValue);
VariantClear(&sscedbprop[0].vValue);
VariantClear(&sscedbprop[1].vValue);
VariantClear(&sscedbprop[2].vValue);
VariantClear(&sscedbprop[3].vValue);


Notice how dbpropset[1].guidPropertySet = DBPROPSET_SSCE_DBINIT instead of DBPROPSET_DBINIT

|||Thanks a lot Erik! the link is very helpful, and after testing, i found the minimum size for SQL CE is 16MB.|||Thanks a lot J Shaddix! after using DBPROPSET_SSCE_DBINIT instead of DBPROPSET_DBINIT

, the max size limitation works! and i found the minimum size for SQL CE is 16MB.

|||Good to know about the min size, thanks!

Sunday, February 12, 2012

Cannot run job created by SMO

I've create a SQL Agent job using C# SMO to process an Analysis Service Database (see code below). When I tried to start job from Management Studio, I get the following error message...any ideas?

TITLE: Microsoft.SqlServer.Smo

Start failed for Job 'Schedule Job OLAPProj'.

For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&ProdVer=9.00.1314.00&EvtSrc=Microsoft.SqlServer.Management.Smo.ExceptionTemplates.FailedOperationExceptionText&EvtID=Start+Job&LinkId=20476


ADDITIONAL INFORMATION:

An exception occurred while executing a Transact-SQL statement or batch. (Microsoft.SqlServer.ConnectionInfo)

Cannot start the job "Schedule Job OLAPProj" (ID 089BEE15-B060-466E-B59E-7F7DAB1EB8DB) because it does not have any job server or servers defined. Associate the job with a job server by calling sp_add_jobserver. (Microsoft SQL Server, Error: 14256)



Common.ServerConnection l_oServerConn = new Common.ServerConnection();

l_oServerConn.ServerInstance = txtServer.Text;

l_oServerConn.LoginSecure = true;

l_oServerConn.Connect();

Smo.Server l_oServer = new Smo.Server(l_oServerConn);

Agent.Job l_oJob = new Agent.Job(l_oServer.JobServer, "Schedule Job " + cboDB.Text);

l_oJob.IsEnabled = true;

l_oJob.Description = "Schedule Job Processing OLAP Cube: " + cboDB.Text;

l_oJob.OwnerLoginName = @."NT AUTHORITY\SYSTEM";

l_oJob.Create();

Agent.JobStep l_oJobStep = new Agent.JobStep(l_oJob, "Process " + cboDB.Text);

l_oJobStep.SubSystem = Agent.AgentSubSystem.AnalysisCommand;

string l_sCmd = @."<Process xmlns=""http://schemas.microsoft.com/analysisservices/2003/engine"">";

l_sCmd = l_sCmd + "<Object><DatabaseID>" + cboDB.Text + "</DatabaseID></Object><Type>ProcessFull</Type>";

l_sCmd = l_sCmd + "<WriteBackTableCreation>UseExisting</WriteBackTableCreation></Process>";

l_oJobStep.Command = l_sCmd;

l_oJobStep.Server = txtServer.Text;

l_oJobStep.DatabaseName = @."master";

l_oJobStep.JobStepFlags = Agent.JobStepFlags.AppendToJobHistory;

l_oJobStep.OnSuccessAction = Agent.StepCompletionAction.QuitWithSuccess;

l_oJobStep.OnFailAction = Agent.StepCompletionAction.QuitWithFailure;

l_oJobStep.Create();


I have posted a sample here, which should clarify this. Please let me know if you have further issues after reading the sample.

|||Based on your sample, I've added the following which seemed to do the trick:

l_oJob.ApplyToTargetServer("(local)");

Initially I use "localhost\yukon" which is name of my instance but that failed and "(local)" worked. Thanks.