How to connect to TFS using VB - vb.net

I'm writing an application that needs to connect to the Team Foundation Server, and then get the last version of a specific file from a specific project. At the begging I did this by using an external .bat, but I'd preffer running eveything inside the code.
I've been looking for examples but all I can find is written in C#. All I got so far is:
Dim tfs As TeamFoundationServer = New TeamFoundationServer(nameOfServer)
Thanks!

Finally I manage to solve it:
Dim tfs As TeamFoundationServer = New TeamFoundationServer(serverAddress)
Dim vcs As VersionControlServer = tfs.GetService(Of VersionControlServer)()
vcs.DownloadFile(fileToGet, fileDestination)

Related

Restore a SQL .bak file using a VB script?

I am exploring methods to enable users to restore a database from within the project.
I have a project which I want to publish together with the database, so that users with no experience can use the program I have developed.
The code is written in VB script and I am able to publish the VB code, but am finding it difficult to include the database in the ClickOnce method.
I have been thinking that I could possibly copy the .bak file to the client's PC and then run a VB script that restores the database to the SQLserver that is installed in the ClickOnce install.
Has anyone ever done this?
I did find on the web something that looked promising, but it has been written for .NET framework 2.0 or 3.0 and I found that when I added System.Data.SqlClient 4.8.0 I got the following error:
Severity Code Description Project File Line Suppression State
Error Could not install package 'System.Data.SqlClient 4.8.0'. You are trying to install this package into a project that targets '.NETFramework,Version=v2.0', but the package does not contain any assembly references or content files that are compatible with that framework. For more information, contact the package author.
The website where I got the code: http://www.planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=1433&lngWId=10
Please can anyone help?
VBScript, which would get run via wscript.exe is decades old technology
VB.NET, which would get compiled into a custom .exe or .dll, is 2005+ (not included in this is .net core which is the past few years but I've not touched it)
dim connectionString as string = "Provider=MSOLEDBSQL;Server=localhost;Database=myDataBase;Trusted_Connection=yes;"
dim connection as New OleDbConnection(connectionString)
Dim cmd As New OleDbCommand
Dim query As String = "RESTORE DATABASE AdventureWorks2012 FROM AdventureWorksBackups;"
Try
cmd.CommandText = query
cmd.ExecuteNonQuery()
Catch ex As Exception
MsgBox("something bad happened")
End Try
Reference bits
ExecuteNonQuery https://learn.microsoft.com/en-us/dotnet/api/system.data.oledb.oledbcommand.executenonquery?view=netframework-4.8
Restore database https://learn.microsoft.com/en-us/sql/t-sql/statements/restore-statements-transact-sql?view=sql-server-ver15
and if you're not using OLEDB, or need a different provider, then futz with connection string as needed but that's the general approach

Download power BI dashboard programmatically

I am trying to write a VB code to export Power BI dashboard from PowerBI server to local path using script task in SSIS using HTTP Connection Manager. A 5KB file is getting generated but not able to open it. Could anyone help me to fix this up.
Dim HttpCon As ConnectionManager = Dts.Connections("ReportServer")
Dim ClientCon As HttpClientConnection = New HttpClientConnection(HttpCon.AcquireConnection(Nothing))
Dim ReportFileName As String = "C:\localpath\Warranty.pdf"
ClientCon.ServerURL = "http://powerbidev.abc.com/Reports/powerbi/FolderName/&rs:Command=Render&rs:Format=PDF&rc:Toolbar=False"
ClientCon.DownloadFile(ReportFileName, True)
You can use Power BI API (link to request you need) to accomplish it.
There should be a programmatic authnetication first, but it is a whole new topic.
Also, there are nu-get package to do it, but you will got problems with adding additional ddls to Script task, when deploying package to server.

Windows 10 Universal App, Reference Local SQLite DB file

I'm getting closer to having a functional SQLite Database in my Universal App.
I keep getting the error 'Cannot Open' and I feel it might be a path problem as SQL Toolbox for Visual Studio picks up the .db file fine.
How to I reference the .db should i put it in a new folder? I need to perform operations to this database but information on this in VB.NET is extremely limited!
Here is what I have so far:
Dim platform As New SQLite.Net.Platform.WinRT.SQLitePlatformWinRT
Dim lc As New SQLite.Net.SQLiteConnection(platform, "/myDB.db")
lc.Execute("INSERT INTO lcCust (CName) VALUES ('Hello')")
I have now successfully created a db using a GUI program. This one specify is SQLiteStudio. I created the DB and connected to it using the SQLite-PCL package along with the Visual Studio addon

Create Spreadsheet in .NET Compact Framework 3.5

I hope this is not a repetitive question; I've searched on the site but I was not able to find anything.
As the title say I would like to create/edit spreadsheet on a .NET Compact Framework project.
On desktop project with the full size framework I use, with pleasure, ClosedXML but if I try to use this I get multiple errors so I'm searching for an alternative.
I have found a commercial option (TMS Flexcel Studio for .NET) but I was wondering if there is something free to use.
I know that I could simply create a csv but I want to do something a bit more modern.
Thanks in advance to everyone who will help.
Ok, after trying a lot of free librery i found a solution.
Excellibrary works! link to google code
I have tried it with Visual Studio 2008 in combination with a Windows CE 5 device and it created an xls file easily.
I must test it to check the performance but at least it works and it's free.
Also the sintax is very simple
Dim file As String = "\HardDisk\newdoc.xls"
Dim workbook As New Workbook()
Dim worksheet As New SpreadSheet.Worksheet("First Sheet")
worksheet.Cells(3, 3) = New Cell(3.45)
workbook.Worksheets.Add(worksheet)
workbook.Save(file)

Why does my MVC application report the GetExecutingAssembly Name as App_web_xxxxx.dll?

I am updating our CruiseControl.NET continuous integration environment from using the old Visual Studio 2008 Web Deployment projects to Visual Studio 2010.
I do not want to use the Beta 2010 Web Deployment projects as I think I can make use of the updated Publishing/Packaging in 2010.
Currently I have managed to configure the CruiseControl script to call MSBuild twice. First to Build the solution in the Release configuration and then to Package the MVC project.
I then copy out the correct files from the Package from a hideous file path (which makes me suspect I am not doing this right but heh) and the Transformed web.configs to the Test server.
This is finally working but unlike when I used the 2008 Deployment Projects this code returns the ExecutingAssembly as App_web_xxxxx.dll and not Company.Product.Web.dll which is what I'm after.
Dim CurrentAssembly As Reflection.Assembly = System.Reflection.Assembly.GetExecutingAssembly
Dim version As String = CurrentAssembly.GetName.Version.ToString
I know GetName returns the a longer string than just the name but I'm debugging it to see what it contains. I understand that is is the compiled/cached dll but why isn't it the one in the MVC bin.
Cheers
I figured this out - basically when I was calling Assembly.GetExecutingAssembly inside the footer.ascx. This meant that the code was in a dynamically compiled dll for the footer.
What I wanted was the DLL for the MVC website. So I used an extension property on the controller that set ViewStates with the Assembly information.
In my case I will want to use this code again so the extension property is in a different Assemmly that I can include in various MVC projects. This meant I had to change the code to use Assembly.GetCallingAssembly but it now works exactly how I wanted.