System.Web.Services cannot be added to VB.NET project in Visual Studio - vb.net

I am working on a VB.NET project in Visual Studio Community 2019, using Windows forms. I want to populate a DataGridView with data from a DataSet. But I get an error upon creating the DataSet, saying that "System.Web.Services could not be added to the project". The DataSet is then created, but I cannot chose it as a DataSource for the DataGridView. Maybe it is worthwhile to mention that my project is not intended to deal with anything online, so I wonder why should I need any Web Service stuff. How I can get rid of the error, or at least populate the DataGridView with my DataSet?
I am noticing -thanks Jon!- the following in the VB code (some 600 auto-generated lines) belonging to the DataSet:
Me.DataSetName = "DataSet1"
Me.Prefix = ""
Me.Namespace = "http://tempuri.org/DataSet1.xsd"
and further down:
Dim any1 As Global.System.Xml.Schema.XmlSchemaAny = New Global.System.Xml.Schema.XmlSchemaAny()
any1.Namespace = "http://www.w3.org/2001/XMLSchema"
I do not know how to bind the data to the grid view by hand, I was trying to use the GUI for doing it, which is not offering me the DateSet as source.
For the DataGrid view, I dragged it in from the toolbox where it can be found under "All Windows Forms"->"DataGridView".

worked now around the GUI way of creating a DataSet by
creating an xml which I can load as DataSet
<NewDataSet>
<Table0><col0>entry0row0</col0><col1>entry1row0</col1></Table0>
<Table0><col0>entry0row1</col0><col1>entry1row1</col1></Table0>
</NewDataSet>
reading in the xml by:
Imports System.xml
ds = New DataSet
Using xmlFile As XmlReader = XmlReader.Create(filename, New XmlReaderSettings())
ds.ReadXml(xmlFile)
End Using
DataGridView1.DataSource = ds.Table(0)

Related

VB.net, cannot access OpenFileDialog that has been added to project

I have decades of experience writing VB6 apps but today I tried to write a simple VB.net app using Microsoft Visual Studio 2019. I fell at the first hurdle. I'm sure I'm doing something really simple wrong so forgive the naive question.
Using the toolbox, I added an OpenFileDialog object to my main (one and only) form. Unlike VB6, this didn't appear on the form but in a sort of bar along the bottom of the window, but it was definitely there and I was able to set some properties.
I then added a button and wrote my first line of code:
With OpenFileDialog1
Wrong! I get errpr BC30451: 'OpenFileDialog1' is not declared. It may be inaccessible due to its protection level.
But I can see it sitting there in the design view, I have spelt its name correctly and the above code is
exactly copied from the example. I tried changing OpenFileDialog1's Modifiers property from Friend to Public - makes no difference.
What novice mistake have I made? How do I access an OpenFileDialog object that I have definitely added to my form?
The FolderBrowserDialog which can be dragged onto the form using the toolbox, is out of date and offers (from today's perspective) too few options. Do yourself a favor and use the Nuget Package Manager to download the modern OpenFileDialog.
Imports Microsoft.WindowsAPICodePack.Dialogs
in your Private Sub Button1_Click:
Dim Pfad As String
Using OFD1 As New CommonOpenFileDialog
OFD1.Title = "Datei auswählen"
OFD1.Filters.Add(New CommonFileDialogFilter("JPG", ".jpg"))
OFD1.Filters.Add(New CommonFileDialogFilter("JPEG", ".jpeg"))
OFD1.Filters.Add(New CommonFileDialogFilter("Bitmap", ".bmp"))
OFD1.Filters.Add(New CommonFileDialogFilter("PNG", ".png"))
OFD1.IsFolderPicker = False 'true to make it an FolderBrowserDialog ;-)
OFD1.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Desktop)
If OFD1.ShowDialog = CommonFileDialogResult.Ok Then
Pfad = OFD1.FileName
Else
Return
End If
End Using
for Multiselect (with Bildpfade1 as a New List(of String) ):
Using OFD As New CommonOpenFileDialog
OFD.Title = "Bilder auswählen"
OFD.Filters.Add(New CommonFileDialogFilter("JPG", ".jpg;jpeg"))
OFD.Multiselect = True
OFD.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Desktop)
If OFD.ShowDialog() = CommonFileDialogResult.Ok Then
For Each file As String In OFD.FileNames
Bildpfade1.Add(file)
Next
End If
End Using
I think I have found the answer but it looks, to me, like a bug in Visual Studio. I saved the project and closed Visual Studio. Restarted and reloaded the project. All the controls I had added to my form had vanished!
I rebuilt the now-empty project then started adding controls - lo and behold, I can now access all my controls from code whereas, previously, I couldn't access any of them. It looks like, prior to the initial build, none of the controls I thought I'd added had actually been added. Certainly they didn't survive save project, restart Visual Studio.
Seems to work now. Many thanks to those who contributed suggestions.

Data not showing in Crystal reports

I'm using a ConnectionString located at a Module for all of my Code in the project.
Code:
Public connString As String = "Data Source=192.168.1.11,1433;Network Library=DBMSSOCN;Initial Catalog=MY_DB;User Id=sa;Password = abc#1234
But for the Crystal Reports, I have added a project Data Source using project > add new Data Source > New Connection and used a ConnectionString.
After adding, I can see the Table and Fields. Once I add this to a Report, and browse Data through Field explorer, I don't see any Data. When I add the fields to a report, same happens. But, in the actual Table there are Rows.
What am I doing wrong here?

Passing data from a Datagrid to Report Viewer

I'm relatively new to form programming in Visual Basic and need some help.
I've successful got what I want from my database into a datagrid but need this in a report viewer.
dgvReport.DataSource = dsReport
Dim ds As DataTable = New DataTable("GenerateReport")
Dim ReportDataSource = New ReportDataSource("GenerateReport", ds)
rvReport.LocalReport.DataSources.Clear()
rvReport.LocalReport.DataSources.Add(ReportDataSource)
rvReport.LocalReport.ReportEmbeddedResource = "Test.Report1.rdlc"
rvReport.RefreshReport()
Where 'dsReport' is the name of the dataset I'm using.
'Generate Report' is the table name within the dataset.
"Test.report1.rdlc" is the path of the report file.
I've searched and found this code, but the error I get says that the the program cannot find the file. I was unaware that there's a file saved which you then copy the data from into the report viewer.
I don't know if this is right, what I'm doing. Any help is much appreciated.

VS reportviewer how do i create a rdlc file

I am new to reportviewer and struggling with the concepts.
I realise that I am probably being very stupid here. I have tried reading up on the reportviewer but not found any tutorials except those that drag and drop datasets. which is not what I want to do.
I want to create a report from a single datatable at first just as a learning exercise.
I have created a dataset added the table to it and have tried this code but I get an error: 'The report definition for report "C:\Users\Mike\BM\Reports\" has not been specified. Object reference not set to an instance of an object'
I don't really understand what the 'The report definition' bit means?
I would appreciate some guidance please.
Dim MyTestDS As New DataSet
Dim myTestTable As New DataTable
myTestTable = Data.Accounts.Table.Copy
MyTestDS.Tables.Add(myTestTable)
Dim DSReport As New ReportDataSource()
DSReport.Name = "MyTestDS"
DSReport.Value = MyTestDS.Tables(0)
Dim PathReport As String = "C:\Users\Mike\BM\Reports\"
ReportViewer1.LocalReport.ReportEmbeddedResource = PathReport
ReportViewer1.LocalReport.DataSources.Clear()
ReportViewer1.LocalReport.DataSources.Add(DSReport)
ReportViewer1.LocalReport.Refresh()
ReportViewer1.RefreshReport()
As a learning exercise, I think is better not using embedded resource so you can simply specify the complete report path of your rdlc file; for example:
ReportViewer1.LocalReport.ReportPath = "C:\Users\Mike\BM\Reports\YourReportFile.rdlc"
If you want to use an embedded report, I think you have to get it like this:
Get Embedded Resource
Copy YourReportFile.rdl to YourReportFile.rdlc

ODBC reading of BMC AR System / Remedy data to VS2010/VB .NET

Edit MY goal is this, I need to do read data from a Remedy Database using a VB .Net app. /Edit
I am trying to read data from the AR System ODBC driver in a VS 2010 VB windows form.
I have added a connection in the data connections via , a system dsn, connection string pulled from a working excel data pull, and built a connection string based via the wizard.
I can test connection, and it comes back 'test connection succeeded'.
When I click ok and the Data connection goes to my server explorer, it expands to tables, view, and procedures and viewing/refreshing those causes errors such as:
Column 'Table_Cat' does not belong to table Tables.
Error [im00][ar system odbc driver] not supported
I am aware there is the api out there, however this has a problem in that the api acts like a login session from the client, which limits you to one login session. This not feasible for the task at hand as the user needs to remain logged into remedy, and the app I'm writing will be read only for data.
The goal is a billboard app that will display certain tickets, kind of like a stock ticker.
There will be no editing of ticket data from remedy, I just need to read the tickets and provide tallies and alerts for our helpdesk.
It seemed so easy when I sat down, but now 4 hours later and a mind numbing amount of irrelevant google results, I'm almost wondering if I'm going to have to report back that it cannot be done with out the api and creating more remedy accounts. Not having to create additional remedy accounts was part of of the request put to me.
Tags: Visual Studio 2010 BMC AR System Remedy ODBC VB.NET
Update
So I have done the code by hand and now seem a few steps forward, but still blind.
Ok, so if i export my excel query it looks like this from the dqy file
export.dqy
DRIVER={AR System ODBC Driver};ARServer=xxxxxx;ARServerPort=xxxxx;UID=xxxx;PWD=xxxx;ARAuthentication=;SERVER=NotTheServer
SELECT "EN:HelpDesk"."Company Name", "EN:HelpDesk"."Call Status", "EN:HelpDesk"."Caller Region", "EN:HelpDesk"."Next Action", "EN:HelpDesk"."Detailed Description(FTS)", "EN:HelpDesk".Device, "EN:HelpDesk"."Submitted-by", "EN:HelpDesk".Impact, "EN:HelpDesk"."Arrival Time", "EN:HelpDesk"."Call Id", "EN:HelpDesk".Market FROM "EN:HelpDesk" "EN:HelpDesk" WHERE ("EN:HelpDesk"."Call Status"<>'Closed') AND ("EN:HelpDesk"."Submitted-by"<>'nis') AND ("EN:HelpDesk".Impact='High') AND ("EN:HelpDesk".Market='DCIN') AND ("EN:HelpDesk"."Caller Region"<>'UK')
First off, these quotes look wrong to me, but it seems to work because if I leave them, executing the command doesn't fail, however it doesn't return data to my data grid view in vb.
Second the EN:Helpdesk looks odd to me but again same results as the quotes.
I have tried changing the quotes to brackets [ ] but receive errors once I do.
Here is my code:
VB Code
Imports SystemM My goal
Imports System.Data
Imports System.Data.Odbc
Imports System.Data.SqlClient
Sub Main()
Dim sql As String
Dim connectionString As String = "DRIVER={AR System ODBC Driver};ARServer=xxx;ARServerPort=xxx;UID=xxx;PWD=xxx;ARAuthentication=;SERVER=NotTheServer"
sql = "SELECT ""EN:HelpDesk"".""Company Name"", ""EN:HelpDesk"".""Call Status"", ""EN:HelpDesk"".""Caller Region"", ""EN:HelpDesk"".""Next Action"", ""EN:HelpDesk"".""Detailed Description(FTS)"", ""EN:HelpDesk"".Device, ""EN:HelpDesk"".""Submitted-by"", ""EN:HelpDesk"".Impact, ""EN:HelpDesk"".""Arrival Time"", ""EN:HelpDesk"".""Call Id"", ""EN:HelpDesk"".Market FROM EN:HelpDesk WHERE (""EN:HelpDesk"".""Call Status""<>'Closed') AND (""EN:HelpDesk"".""Submitted-by""<>'nis') AND (""EN:HelpDesk"".Impact='High') AND (""EN:HelpDesk"".Market='DCIN') AND (""EN:HelpDesk"".""Caller Region""<>'UK')"
Dim bindingSource1 As New BindingSource()
Me.SQLDS_reportresults.DataSource = bindingSource1
Dim myAdapter = New OdbcDataAdapter(sql, connectionString)
Dim commandBuilder As New OdbcCommandBuilder(myAdapter)
Dim table As New DataTable()
table.Locale = System.Globalization.CultureInfo.InvariantCulture
myAdapter.Fill(table)
bindingSource1.DataSource = table
Me.SQLDS_reportresults.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCellsExceptHeader)
End Sub
Project is a windows forms with a button to activate main(), a textbox (textbox1) and a datagridview(SQLDS_reportresults).
As the code stands, this causes no errors, but my datagridview never populates. Since there are no errors, I'm inclined to think my connection is working , and that my command is being executed,making my problem lay in code, however given the funky use of quotes and en:helpdesk in the sql command, I'm also concerned that is malformed and causing the where portion to return no results.
Anyone have any suggestions / ideas?
I need a way to display these results in app, and right now I don't care how just as long as I can see some data at all.
I've been googling and looked at the vb examples in the api zip but that is not related to opening a odbc connection and I found that of little help in my research.
I almost feel like I'm missing something simple or obvious.
When i run odbcad32.exe my ar system odbc driver shows 7.00.01.02 which is what I assume is installed on everyones machines as I used the remedy install set provided to me by the IT/Software admins to build this dev box.