I have created a XML document using visual basic in visual studio 2010.
it seems its not letting me use array values when i write a start element.
arrayValue = array(UBound(array))
Dim xw As XmlWriter = XmlWriter.Create("xmlfile.xml", xws)
xw.WriteStartDocument()
xw.WriteStartElement(arrayValue)
xw.WriteEndElement()
xw.WriteEndDocument()
xw.Flush()
xw.Close()
Wont let me do that it gives me an error and also does nothing.
"A first chance exception of type 'System.ArgumentException' occurred in System.Xml.dll"
Whats going on?
You could try using the XMLTextWriter.
arrayValue = array(UBound(array))
Dim xWriter As New Xml.XmlTextWriter("C:\Users\Admin\Desktop\mytest.xml", System.Text.Encoding.UTF8)
xWriter.Formatting = Formatting.Indented
xWriter.Indentation = 2
xWriter.WriteStartDocument(True)
xWriter.WriteStartElement(arrayValue)
xWriter.WriteEndElement()
xWriter.Flush()
xWriter.Close()
A few of my arrayValue values were not coming out as xml standard. There happen to be a lot of them.
Some started with numbers (which you cannot have as nodenames). That is why it wasn't writing to the document. I have to write a filter to change the values into XML standard.
I wish visual studio would of told me this in an error message or something. Thanks for all of your help.
Related
I have added a reference of a soap webservice in my visual studio 2012. Working for the first time with is a little bit hard because it gave an error and I don't know how to resolve it. Any hints? Below is my code:
Dim obj() As MobileApp.ClaimsDetails
Dim respClaimsDetails As MobileApp.BAMobileAppSoap
Dim a As New MobileApp.MVGetClaimsDetailsAllRequest
a.strVisaID = 123
Dim b As New MobileApp.MVGetClaimsDetailsAllResponse
b = respClaimsDetails.MVGetClaimsDetailsAll(a)
obj = b.MVGetClaimsDetailsAllResult
MobileApp is the name of my webservice. The exception thrown is a null reference in respClaimsDetails.MVGetClaimsDetailsAll(a).
I know that MobileApp.BAMobileAppSoap is an interface that needs a Concrete Implementation to complete my work, but I have at least 50 interfaces, I cannot concrete them all... I am sure there is another way to call webservice and resolve this issue ... any help, any links or documentation concerning added webservices in visual studio 2012 are appreciated.
Regards.
OK finally I could solve it :
Instad of using an interface there a class for client that takes a parameter "BAMobileAppSoap" which is the enpoint name in web.config, and then I could call my methods easily:
Dim respClaimsDetails As New MobileApp.BAMobileAppSoapClient("BAMobileAppSoap")
Dim res = respClaimsDetails.MVGetClaimsDetailsAll(claimNum)
I've got an error while creating an AxShockwaveFlash control in VB.NET , when I load a movie , an error appears :
Exception of type
'System.Windows.Forms.AxHost+InvalidActiveXStateException' was thrown
.
This is my code :
Dim animFlashObject As New AxShockwaveFlash
Me.Controls.Add(animFlashObject)
animFlashObject.Movie = "D:\Dé-compilateur de .d2p\data\swf\9014.swf"
animFlashObject.EmbedMovie = True
animFlashObject.Play()
I'm going to try to answer this, keep in mind that my English is not that good.
I think the problem lays with your "url" to the .swf file.
Try putting your .swf file in another folder, example: "C:\anotherfolder\movie.swf" it's bin a while since I used vb.net, but I think this is it.
Goodluck
I've been googling around around and read this article
C# How to get SQL Server installation path programatically?
and this is exactly what i need in VB.NET , however i'm not good in translating this code into VB.NET Code. So, any help would greatly appreciated. Thank you.
Note : I'm using SQL Server 2005 and Visual Basic 2008
While the question was originally titled about retrieving SQL Server's installation path, I felt it was more about a code translation problem (the solution already existed, just not in the right language).
But then I thought that the method in the original code was fairly blunt.
Evan provided you with what I assume is a workable translation of the existing solution. But probably a much easier way to perform this specific task - assuming you just need to find the installation path for an instance you're already connected to, and assuming that a user who can read the registry will also have VIEW SERVER STATE permissions - is to issue this simple query against the DMV sys.dm_os_loaded_modules from your program:
SELECT name
FROM sys.dm_os_loaded_modules
WHERE name LIKE '%sqlservr.exe';
This will give you something like this:
C:\Program Files\Microsoft SQL Server\MSSQL11.SQL2012\MSSQL\Binn\sqlservr.exe
You have some parsing to do, depending on exactly what you're after (e.g. do you want to stop at MSSQL, or Binn?), but this is much easier than reading the registry or other methods that are out there IMHO.
I just used a code converter ... There are only basic things that need to be changed ..
Using sqlServerKey As RegistryKey = Registry.LocalMachine.OpenSubKey("SOFTWARE\Microsoft\Microsoft SQL Server")
For Each subKeyName As String In sqlServerKey.GetSubKeyNames()
If subKeyName.StartsWith("MSSQL.") Then
Using instanceKey As RegistryKey = sqlServerKey.OpenSubKey(subKeyName)
Dim instanceName As String = instanceKey.GetValue("").ToString()
If instanceName = "MSSQLSERVER" Then
'say
Dim path__1 As String = instanceKey.OpenSubKey("Setup").GetValue("SQLBinRoot").ToString()
path__1 = Path.Combine(path__1, "sqlserver.exe")
Return path__1
End If
End Using
End If
Next
End Using
If you were to just read a quick article on C#, you would notice that strings are declared differently, and minor syntax discrepancies exist such as foreach vs for each
You can read here for some more common differences.
I use a very good (offline) tool, called Convert .NET Free
It's from www.fishcodelib.com
Here's a direct link to the latest release (as of 19/04/14) Size: 2.06MB, File: Zip :
[Direct Link]
Hope this is of some use ;)
P.S. This software requires .NET Framework 4.5.
This almost never fails! :) Good Luck
http://www.developerfusion.com/tools/convert/csharp-to-vb/
I am new to vb this is the code i am working on:
Dim InputDoc As XmlDocument = New XmlDocument()
InputDoc.LoadXml(tem)
Dim Transformer As XslCompiledTransform = New XslCompiledTransform()
Transformer.Load(Server.MapPath("D/" & T))
Dim xmlCtl As System.Web.UI.WebControls.Xml = New System.Web.UI.WebControls.Xml
xmlCtl.Document = InputDoc
xmlCtl.Transform = Transformer
Controls.Add(xmlCtl)
I changed XslTranform to XslCompiledTranform - is this right thing to do?
But i am still getting few other errors as xmlCtl.Document is obselete and value of xmlCtl.Transform cannot be converted to Transformer. I am using .Net 4.0 . Can anybody please tell me how to resolve these?
I changed XslTranform to XslCompiledTranform - is this right thing to do?
As to this post yes that is the right thing to do.
Apparently there is an issue with memory leakage when transforming large documents. So i guess be wary of that.
But i am still getting few other errors as xmlCtl.Document is obselete and value of xmlCtl.Transform cannot be converted to Transformer
This would be right if you were not going to have XSLT transformations.
Dim xmlCtl As System.Web.UI.WebControls.Xml = New System.Web.UI.WebControls.Xml
But you want to use XSLT, so that will not work.
Create an XPathDocument and call CreateNavigator()
Use XPathNavigator to execute an XSLT transformation.
This post talks about working with xml web controls and xslt.
You may want to take a look at this as well.
This uses XslCompiledTransform and is supposed to be a replacement of the ASP.NET Xml control. Will work with integrating XSLCompiledTransform
Anyways i hoped some of this helped.
"Error 1 DBML1005: Mapping between DbType 'Xml' and Type 'System.Xml.Linq.XElement' in Column 'XML_LAYOUT' of Type 'QUEST_BLOCK' is not supported."
The above is the error am getting. What am doing is dragging a table with xml fields as columns from server explorer into a dbml file. After that when i compile i am getting the above error. Now after that i changed server datatype to blank. Now the program compiles successfully. But at runtime if i query the table directly using WCF in silverlight the function is showing error. After a debug i found that the select statement on the table is returning the rows in the funtiion, however the error is produced in the reference file in the following function.
Public Function EndGetQuestionListRecord1(ByVal result As System.IAsyncResult) As ServiceReference1.QUEST_BLOCK Implements ServiceReference1.Medex.EndGetQuestionListRecord1
Dim _args((0) - 1) As Object
Dim _result As ServiceReference1.QUEST_BLOCK = CType(MyBase.EndInvoke("GetQuestionListRecord1", _args, result),ServiceReference1.QUEST_BLOCK)
Return _result
End Function
Hope someone around here could resolve this error...
rideonscreen, recently I started getting the same type of error. In my case I get it dragging a stored procedure with a XML input parameter.
I wonder whether you managed to resolve the issue and how.
I googled and found some articles:
http://dev.techmachi.com/?p=319
http://www.west-wind.com/Weblog/posts/505990.aspx
http://www.jonathanjungman.com/blog/post/Visual-Studio-Build-failed-due-to-validation-errors-in-dbml-file.aspx
"devenv /resetskippkgs" helps, but next day the issue appears again.
What is also interesting that I do not touch the LINQ2SQL model (dbml file) at all. The code there is the same for a long time. The issues is definitely exclusively related to Visual Studio.
P.S. I am thinking to migrate to EF.