Showing posts with label example. Show all posts
Showing posts with label example. Show all posts

Friday, March 23, 2012

Error when importing XML to SQL-server using activX

I have tried this example to import XML to SQL-server:
http://www.perfectxml.com/articles/X...rtXMLSQL.asp#3
But i get an error when the import is finish:
Error Source: Microsoft Data Transformation Service (DTS) Package
Error Description: ActiveX Scripting encounted a Run Time Error during
the execution of the script.
The data is imported to the table as it should
What could be the problem?//Peter
"Peter" <dj-pnr@.get2net.dk> wrote in message
news:4073f900@.news.wineasy.se...
[snip]
> The data is imported to the table as it should
> What could be the problem?//Peter
If the data gets imported, then it is probably a problem with syntax at the
end of your script. Check to make sure it is correct.
Bryant
|||I have the following code:
'************************************************* *********************
' Visual Basic ActiveX Script
'************************************************* ***********************
Dim objXBulkLoad
Set objXBulkLoad = CreateObject("SQLXMLBulkLoad.SQLXMLBulkLoad.3.0")
objXBulkLoad.ConnectionString =
"PROVIDER=SQLOLEDB.1;SERVER=000.000.000.000;UID=ad m;PWD=password;DATABASE=No
rthWind;"
objXBulkLoad.KeepIdentity = False
'Optional Settings
objXBulkLoad.ErrorLogFile = "c:\NWError.LOG"
objXBulkLoad.TempFilePath = "c:\temp"
'Executing the bulk-load
objXBulkLoad.Execute "c:\books.xsd", "c:\books.xml"
Main = DTSTaskExecResult_Success
Can you see any errors?
"Bryant Likes" <bryant@.suespammers.org> skrev i en meddelelse
news:uekmKakHEHA.3476@.TK2MSFTNGP11.phx.gbl...
> "Peter" <dj-pnr@.get2net.dk> wrote in message
> news:4073f900@.news.wineasy.se...
> [snip]
> If the data gets imported, then it is probably a problem with syntax at
the
> end of your script. Check to make sure it is correct.
> --
> Bryant
>
|||"Peter" <dj-pnr@.get2net.dk> wrote in message
news:407bedf5$1@.news.wineasy.se...
[snip]
> Main = DTSTaskExecResult_Success
> Can you see any errors?
It doesn't look like you have a Function called main, so that last line
would cause the error. You should wrap everything in a function like:
Function Main()
''' Insert all your code here
Main = DTSTaskExecResult_Success
End Function
Bryant
|||Xref: TK2MSFTNGP08.phx.gbl microsoft.public.sqlserver.xml:23306
Tanks! That solved my problem
"Bryant Likes" <bryant@.suespammers.org> skrev i en meddelelse
news:%237pbt4dIEHA.3964@.TK2MSFTNGP10.phx.gbl...
> "Peter" <dj-pnr@.get2net.dk> wrote in message
> news:407bedf5$1@.news.wineasy.se...
> [snip]
> It doesn't look like you have a Function called main, so that last line
> would cause the error. You should wrap everything in a function like:
> Function Main()
> ''' Insert all your code here
> Main = DTSTaskExecResult_Success
> End Function
> --
> Bryant
>

Friday, March 9, 2012

Error when assigning Dimension Data Permissions using AMO

Hello,

I am using AMO example posted on MSDN: http://msdn2.microsoft.com/en-us/library/ms345081.aspx

I followed this example very closely. I can create a role, assign read permissions to it, but when I try to

assign AllowedSet to Dimension Attribute (see code below):

// Get dimension and attribute

Dimension dim = dataBase.Dimensions.GetByName(dimName);

DimensionAttribute attr = dim.Attributes.GetByName("Group Name");

CubeDimensionPermission cubeDimPerm = cubePerm.DimensionPermissions.Add(dim.ID);

cubeDimPerm.Read = ReadAccess.Allowed;

AttributePermission attrPerm = cubeDimPerm.AttributePermissions.Add(attr.ID);

attrPerm.AllowedSet = "{[GroupUsers].[Group Name].&[0]}";

cubePerm.Update();

I am getting this error: Microsoft.AnalysisServices.AnalysisServicesClient.SendExecuteAndReadResponse(ImpactDetailCollection impacts, Boolean expectEmptyResults, Boolean throwIfError)
at Microsoft.AnalysisServices.AnalysisServicesClient.Alter(IMajorObject obj,
ObjectExpansion expansion, ImpactDetailCollection impact, Boolean allowCreate)
at Microsoft.AnalysisServices.Server.Update(IMajorObject obj, UpdateOptions o
ptions, UpdateMode mode, XmlaWarningCollection warnings, ImpactDetailCollection
impactResult)
at Microsoft.AnalysisServices.Server.SendUpdate(IMajorObject obj, UpdateOptio
ns options, UpdateMode mode, XmlaWarningCollection warnings, ImpactDetailCollect
ion impactResult)
at Microsoft.AnalysisServices.MajorObject.Update(UpdateOptions options, Updat
eMode mode, XmlaWarningCollection warnings)
at Microsoft.AnalysisServices.MajorObject.Update()
at IHS.Datawarehouse.CubeUtility.Program.AssignDimensionData(Database dataBas
e, String roleName, String dimName) in C:\IHS\WWBA\Development\Applications\IHS.
Datawarehouse.CubeUtility\IHS.Datawarehouse.CubeUtility\IHS.Datawarehouse.CubeUt
ility\Program.cs:line 99
at IHS.Datawarehouse.CubeUtility.Program.Main(String[] args) in C:\IHS\WWBA\D
evelopment\Applications\IHS.Datawarehouse.CubeUtility\IHS.Datawarehouse.CubeUtil
ity\IHS.Datawarehouse.CubeUtility\Program.cs:line 32

Has anyone experienced this error. What's causing this?

Actual error message in the event viewer:

The description for Event ID ( 22 ) in Source ( MSSQLServerOLAPService ) cannot be found. The local computer may not have the necessary registry information or message DLL files to display messages from a remote computer. You may be able to use the /AUXSOURCE= flag to retrieve this description; see Help and Support for details. The following information is part of the event: Internal error: An unexpected exception occured..

Error when "SELECT" statement has conditions

Hi everyone,

I just started in developing applications for PocketPC. I found an example from this webpage link and I tried it out. I have a listbox to display the results.


Dim mySelectQuery As String = "SELECT ID, Name FROM StaffData WHERE Name = 'John'"

Dim myConnection As New SqlServerCe.SqlCeConnection("Data Source = \My Documents\test.sdf")

Dim myCommand As New SqlServerCe.SqlCeCommand(mySelectQuery, myConnection)
myConnection.Open()

Dim myReader As SqlServerCe.SqlCeDataReader
myReader = myCommand.ExecuteReader()

' Always call Read before accessing data.
While myReader.Read()
ListBox1.Items.Add(myReader.GetInt32(0) & " " & myReader.GetString(1))
End While

' always call Close when done reading.
myReader.Close()
' Close the connection when done with it.
myConnection.Close()

The above code gave me an error on the line in red.
But, if I have the query statement without condition:


Dim mySelectQuery As String = "SELECT ID, Name FROM StaffData"


Everything runs fine and my listbox has the data.

Am I doing something wrong?

Regards.

What error are you getting? Since you are new to SQL CE/SQL Mobile development, wrap everything starting with "myConnection.Open()" through the While loop in a Try Catch block. Catch Exception or SqlCeException and use the following code to enumerate the exception:

Public Sub DisplaySQLCEErrors(ByVal ex As SqlCeException)

Dim errorCollection As SqlCeErrorCollection = ex.Errors
Dim bld As New StringBuilder()
Dim inner As Exception = ex.InnerException
Dim err As SqlCeError

For Each err In errorCollection

bld.Append(ControlChars.Lf + " Error Code: " + err.HResult.ToString())
bld.Append(ControlChars.Lf + " Message : " + err.Message)
bld.Append(ControlChars.Lf + " Minor Err.: " + err.NativeError.ToString())
bld.Append(ControlChars.Lf + " Source : " + err.Source)

Dim numPar As Integer
For Each numPar In err.NumericErrorParameters
If (numPar <> 0) Then
bld.Append(ControlChars.Lf + " Num. Par. : " + numPar.ToString())
End If
Next numPar
Dim errPar As String
For Each errPar In err.ErrorParameters
If (errPar <> String.Empty) Then
bld.Append(ControlChars.Lf + " Err. Par. : " + errPar)
End If
Next errPar

MessageBox.Show(bld.ToString(), "SQL Mobile Error")

Next err

End Sub

-Darren Shaffer
.NET Compact Framework MVP

|||Thanks Darren!

Your error display code is awesome!
I've an error saying "The ntext and image data types cannot be used in WHERE, HAVING, GROUP BY, ON, or IN clauses, except when these data types are used with the LIKE or IS NULL predicates."

I guess what I need to do is to change the data type.

But one thing I don't understand is why do I always have to declare like this:


Dim err As SqlServerCe.SqlCeError


instead of:


Dim err As SqlCeError


which I have no clue.

Thanks!|||Apparently your Name column is of type ntext - you should probably change it to nchar or nvarchar.

-Darren Shaffer

Sunday, February 26, 2012

Error trying to write file

I don't have direct access to the SQL server. I have to write/read through a class I recieved from the IT department. The class also had an example in it but I can't get it to work correctly.

I get an error: Object reference not set to an instance of an object. Line 35


Dim clsWDD As New WebDevDB.WebDevDB
Dim intLeng As Int32
Dim intLock As Int32

Dim strAppl As String = "MyApplication"
Dim strData As String = "This is my text data!"

Dim strFile As String = "MyFile"

intLock = clsWDD.LockTextFile(strAppl, strFile) 'line 35
intLeng = clsWDD.WriteTextFile(strAppl, strFile, strData, WriteAction.Create)
intLock = clsWDD.UnlockTextFile(intLock)

What does the whole exception.tostring say?|||Object reference not set to an instance of an object.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.

Source Error:

Line 33: Dim strFile As String = "MyFile"
Line 34:
Line 35: intLock = clsWDD.LockTextFile(strAppl, strFile)
Line 36: intLeng = clsWDD.WriteTextFile(strAppl, strFile, strData, WriteAction.Create)
Line 37: intLock = clsWDD.UnlockTextFile(intLock)

Source File: C:\Inetpub\wwwroot\TestSolution\WebForm1.aspx.vb Line: 35

Stack Trace:

[NullReferenceException: Object reference not set to an instance of an object.]
WebDevDB.WebDevDB.GetConnectionString()
WebDevDB.WebDevDB.LockTextFile(String ApplicationName, String FileName, Byte LockSeconds, Byte LockAttempts)
TestSolution.WebForm1.Page_Load(Object sender, EventArgs e) in C:\Inetpub\wwwroot\TestSolution\WebForm1.aspx.vb:35
System.Web.UI.Control.OnLoad(EventArgs e)
System.Web.UI.Control.LoadRecursive()
System.Web.UI.Page.ProcessRequestMain()

Wednesday, February 15, 2012

error running sp_stored_procedures

I downloaded the code example "Running Stored Procedures with ASP.NET" (http://www.dotnetjunkies.com/Tutorial/9AE62C44-3841-4687-B906-2F6D4A5A4622.dcik)
and I'm having trouble filtering the sp's that are populating the drop down box. Here's my code: (all I did was add the one parameter)

Dim ds As New DataSet

Dim conn As New SqlConnection( _
Data source=" & DatabaseServer.Text & _
";User id=" & Userid.text & _
";Password=" & Password.Text & _
";Initial catalog=" & Database.Text)

Dim cmd As New SqlCommand("sp_stored_procedures", conn)
Dim adpt As New SqlDataAdapter(cmd)
Try
cmd.Parameters.Add("@.sp_name", SqlDbType.NVarchar, 390).Value = CType("my%", String)

so if I comment out the cmd.Parameters.Add ... line it all works fine and I get every sp, but if I uncomment it I get " Incorrect syntax near 'sp_stored_procedures'" every time no matter what i put in the string.

I have a feeling I'm doing something stupid :) Anyone have any ideas? The query works fine in query analyzer with the same arguments that I'm trying in the code.Add:

cmd.CommandType=CommandType.StoredProcedure|||...and you shouldn't begin the name of your stored procedures with the sp_ prefix. This prefix should always be reserved only for system stored procedures.|||"
...and you shouldn't begin the name of your stored procedures with the sp_ prefix. This prefix should always be reserved only for system stored procedures.

"

It IS a system stored procedure.|||"
Add:

cmd.CommandType=CommandType.StoredProcedure
"

Doh!

Thanks!