I have this table.
https://www.dropbox.com/s/7xf6ibn5mr9f9yf/test4.PNG?dl=0
Basically, I want to display "AttendDet_Type" which is P, A and MC as the x-axis using multiple series (which will look like this - https://www.dropbox.com/s/v15pp818tmgf8co/test5.PNG?dl=0) and COUNT(AttendDet_Type) as the y-axis.
I managed to display AttendDet_Type for P using asp chart but I totally have no idea how to code multiple series to display A and MC. Can anyone help me out?
My ASP Code
<asp:Chart ID="Chart1" runat="server" SqlDataSourceID="SqlDataSource1" Width="800" Height="500">
<Titles>
<asp:Title Text = "Attendance Report"></asp:Title>
</Titles>
<Series>
<asp:Series Name="Series1">
</asp:Series>
<asp:Series ChartArea="ChartArea1" Name="Series2">
</asp:Series>
<asp:Series ChartArea="ChartArea1" Name="Series3">
</Series>
<ChartAreas>
<asp:ChartArea Name="ChartArea1" >
</asp:ChartArea>
</ChartAreas>
My VB Code
Using con As New MySqlConnection(ConfigurationManager.ConnectionStrings("ConString").ConnectionString)
Dim CmdString As String = "SELECT Attendance.AttendDet_Type, COUNT(Attendance.AttendDet_Type) AS TotalAttendance FROM Student, Attendance WHERE Student.Stud_ID = Attendance.Stud_ID AND Student.Stud_Class = '1A1' AND Attendance.Attend_Date = '2014-11-12' AND AttendDet_Type = 'P'"
Dim sda As New MySqlDataAdapter(CmdString, con)
Dim ds As New DataSet()
sda.Fill(ds)
Chart1.DataSource = ds
Chart1.Series("Series1").XValueMember = "AttendDet_Type"
Chart1.Series("Series1").YValueMembers = "TotalAttendance"
Chart1.DataBind()
End Using
Looking forward to receiving yall replies. Thanks!!
Related
Is anyone familiar with the API sample code for UPS web service DOTNET, I'm testing the code sample from the UPS API, ShipWSSample. I am getting a tracking number back but not sure how to get the label data from the ShipmentResponse. The code has referenced label code just above where I get the response.
Dim labelSpec As New LabelSpecificationType()
Dim labelStockSize As New LabelStockSizeType()
labelStockSize.Height = "6"
labelStockSize.Width = "4"
labelSpec.LabelStockSize = labelStockSize
Dim labelImageFormat As New LabelImageFormatType()
labelImageFormat.Code = "GIF"
labelSpec.LabelImageFormat = labelImageFormat
shipmentRequest.Shipment = shipment
System.Net.ServicePointManager.SecurityProtocol = DirectCast(3072, SecurityProtocolType)
Dim shipmentResponse As ShipmentResponse = shpSvc.ProcessShipment(shipmentRequest)
Any help would be appreciated
Mike
I'm Having a problem regarding to the autocomplete textbox. First I already made the autocomplete textbox work with mysql database as custom source but the default textfilter of autocomplete is "start with" not "contains". I want to change the textfilter to "contains", so that when I search any part of the string, the whole name which contains the searched word will appear in the autocomplete suggestions.
Can anyone help me fix my code?
This is the code i've done so far:
txtSearch.AutoCompleteMode = AutoCompleteMode.SuggestAppend
txtSearch.AutoCompleteSource = AutoCompleteSource.CustomSource
Dim DataCollection As New AutoCompleteStringCollection()
Dim query As String
sqlcon = New MySqlConnection
sqlcon.ConnectionString =
"server=localhost;userid=root;password=root;database=svfmemberlistdb"
Try
sqlcon.Open()
query = " SELECT Name FROM svfmemberlistdb.svfmemberlist "
sqlcmd = New MySqlCommand(query, sqlcon)
sqladr.SelectCommand = sqlcmd
sqladr.Fill(ds)
sqladr.Dispose()
sqlcon.Close()
For Each row As DataRow In ds.Tables(0).Rows
If row.ToString.Contains(txtSearch.Text) Then
DataCollection.Add(row(0).ToString())
End If
Next
Catch ex As Exception
End Try
txtSearch.AutoCompleteCustomSource = DataCollection
I quote here Mitja Bonca's answer on MSDN.
In this case, autocompletemode will just not do. Its code is not meant
for something like it.
You will have to do your own code, to do the filtering on each letter
press.
So I would suggest not to use autocompletemode, and get all the data
(names) into dataTable. When user presses some button ("1" for
example), you start with your filtering, by creating new Datatable
(leave the main one untached - so you can return back to all data when
clearing comboBox by backspace), with Copy() method - to create a full
copy of original one, and use Select method to do the filteing.
This should look something like by using % simbol on both sides of a
string - to filter inbetween - this is what you want!
DataTable AllNames = new DataTable();
//fill it up and leave it untouched!
//to filter comboBox with names that contains pressed characters do in
private void comboBox1_KeyPress(object sender, KeyPressEventArgs e)
{
string name = string.Format("{0}{1}", comboBox1.Text, e.KeyChar.ToString()); //join previous text and new pressed char
DataRow[] rows = table.Select(string.Format("FieldName LIKE '%{0}%'", name));
DataTable filteredTable = AllNames.Clone();
foreach(DataRow r in rows)
filteredTable.ImportRow(r);
comboBox1.DataSource = null;
comboBox1.DataSource = filteredTable.DefaultView;
comboBox1.DisplayMember = "FieldName";
}
Reference
EDIT: This is of course a c# answer not VB.NET but it might be helpful to get the concept.
Ignore this to get to the main problem, below is only the idea
Scenario: I am making a total Private Messaging system in Visual Basic.
Trying: I want to make an Inbox for the users. The messages will be retrieved from the MySQL database and shown in small custom Grid made with Panel(Type of Control from Visual basic) for each message which will be clickable which is when clicked, the whole message will be shown.
Did so far: Not too much though(Talking about the Inbox.), I only wrote the MySQL query.
I will make the Sending and Reading PM after the Inbox as Inbox seems more complex than the other two things.
I really want to know how can this be achieved. I searched around almost everywhere, either it was for PHP and web based or nothing. I want to know how to dynamically create controls like panels and the labels and show the PMs. Is there any other way to do this rather than showing the PMs in DataGridView ? (I really don't want to use that as it's not what I want.)
For reference: The custom Grid is something like this:
The MySQL PM table:
PMId - The ID for the message (Auto Incremented)
Sender_Name - The person sending the message
Receiver_Name - The person receiving the message
Subject - The subject of the message
Date_Sent - Date on which the message was sent
PM_Read - If the PM has been read (0 for not read, 1 for read)
Deleted - If the PM has been deleted (0 for not deleted, 1 for deleted)
Look at the code-behind for a built form and you will see how to create controls at run-time. For example, I created a form, added a panel with a button and label and this is the code created in the designer:
Private Sub InitializeComponent()
Me.Button1 = New System.Windows.Forms.Button()
Me.Label1 = New System.Windows.Forms.Label()
Me.Panel1 = New System.Windows.Forms.Panel()
Me.Panel1.SuspendLayout()
Me.SuspendLayout()
'
'Button1
'
Me.Button1.Location = New System.Drawing.Point(3, 3)
Me.Button1.Name = "Button1"
Me.Button1.Size = New System.Drawing.Size(75, 23)
Me.Button1.TabIndex = 0
Me.Button1.Text = "Button1"
Me.Button1.UseVisualStyleBackColor = True
'
'Label1
'
Me.Label1.AutoSize = True
Me.Label1.Location = New System.Drawing.Point(3, 29)
Me.Label1.Name = "Label1"
Me.Label1.Size = New System.Drawing.Size(39, 13)
Me.Label1.TabIndex = 1
Me.Label1.Text = "Label1"
'
'Panel1
'
Me.Panel1.Controls.Add(Me.Button1)
Me.Panel1.Controls.Add(Me.Label1)
Me.Panel1.Location = New System.Drawing.Point(12, 12)
Me.Panel1.Name = "Panel1"
Me.Panel1.Size = New System.Drawing.Size(198, 69)
Me.Panel1.TabIndex = 2
'
'Form1
'
Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
Me.ClientSize = New System.Drawing.Size(284, 262)
Me.Controls.Add(Me.Panel1)
Me.Name = "Form1"
Me.Text = "Form1"
Me.Panel1.ResumeLayout(False)
Me.Panel1.PerformLayout()
Me.ResumeLayout(False)
End Sub
Friend WithEvents Button1 As System.Windows.Forms.Button
Friend WithEvents Label1 As System.Windows.Forms.Label
Friend WithEvents Panel1 As System.Windows.Forms.Panel
You can do the same thing at run-time.
Dim iTop As Int32 = 5
For Each DR As DataRow In DT.Rows
Dim pnl As New Panel
pnl.Location = New System.Drawing.Point(12, iTop)
pnl.Size = New System.Drawing.Size(198, 40)
Dim lbl As New Label
lbl.Location = New System.Drawing.Point(3, 3)
lbl.Size = New System.Drawing.Size(39, 13)
lbl.Text = DR("Some field from your table")
'Add to panel
pnl.Controls.Add(lbl)
'Add to Form
Me.Controls.Add(pnl)
'Add to the top location so the next set of controls are not on top of the old ones
iTop += 50
Next
Can anyone point me in the rigth direction for a solution, to get data from a xml file. I normaly use XmlDocument in VB applications, and that have worked flawless all times.
Now Windows Store Apps not really supporting xmlDocument anymore, som working when DOM is imported but XmlNode is not availble. However maybe its just me but XDocument seems to me to be very very difficult and not very logic for looking up data in a simple XML file.
before i used some like this:
xmlDevices = xmlDoc.GetElementsByTagName("Device")
For Each xmlDevice As xmlElement In xmlDevices
Dim strDeviceName As String = xmlDevice.Item("DeviceName").InnerText
xmlModbuses = xmlDoc.GetElementsByTagName("Modbus")
For Each xmlModbus As xmlElement In xmlModbuses
Dim strModbusID As String = xmlModbus.Attributes("id").InnerText
Next
Next
The XML file i wants to seek data from looks like:
<?xml version="1.0" encoding="utf-8" ?>
<Devices>
<Device id="01">
<DeviceName>VP18</DeviceName>
<Modbusees>
<Modbus id="01">1000</Modbus>
<Modbus id="02">2000</Modbus>
...
</Modbuses>
<Alarms>
<Alarm id="01">
<AlarmText>Test</AlarmText>
<AlarmType>Critical</AlarmType>
</Alarm>
<Alarm id="02">
<AlarmText>Test</AlarmText>
<AlarmType>Critical</AlarmType>
</Alarm>
</Alarms>
<Device id="02">
<DeviceName>VP19</DeviceName>
<Modbusees>
<Modbus id="01">1010</Modbus>
<Modbus id="02">2020</Modbus>
...
</Modbuses>
<Alarms>
<Alarm id="01">
<AlarmText>Test</AlarmText>
<AlarmType>Critical</AlarmType>
</Alarm>
<Alarm id="02">
<AlarmText>Test</AlarmText>
<AlarmType>Critical</AlarmType>
</Alarm>
</Alarms>
</Device>
</Devices>
Best Regards
Thomas Nissen
I got it working with following.
Dim xDoc As XDocument = XDocument.Load(xmlStream.AsStreamForRead())
Dim xmlDevices = xDoc.Root.Elements("Device")
For Each xmlDevice In xmlDevices
If xmlDevice.Attribute("id").Value = RoamingSettings.Containers("Device").Values("DeviceID") Then
Dim xmlAlarms = xmlDevice.Descendants("Alarm")
For Each xmlAlarm In xmlAlarms
If xmlAlarm.Attribute("id").Value = strAlarmID Then
strAlarmDisp = xmlAlarm.Element("AlarmDisp").Value
strAlarmType = xmlAlarm.Element("AlarmType").Value
strAlarmDesc = xmlAlarm.Element("AlarmDesc").Value
strAlarmHelp = xmlAlarm.Element("AlarmHelp").Value
End If
Next
End If
Next
Hey all I am looking for a way to get this HTML code:
<DIV class=schedule_block>
<DIV class=channel_row><SPAN class=channel>
<DIV class=logo><IMG src='/images/channel_logos/WGNAMER.png'></DIV>
<P><STRONG>2</STRONG><BR>WGNAMER </P></SPAN>
using the HtmlAgilityPack.
I have been trying this:
For Each channel In doc.DocumentNode.SelectNodes(".//div[#class='channel_row']")
Dim info = New Dictionary(Of String, Object)()
With channel
info!Logo = .SelectSingleNode(".//img").Attributes("src").Value
info!Channel = .SelectSingleNode(".//span[#class='channel']").ChildNodes(1).ChildNodes(0).InnerText
info!Station = .SelectSingleNode(".//span[#class='channel']").ChildNodes(1).ChildNodes(2).InnerText
End With
.......
I can get the Logo but it comes up with a blank string for the Channel and for the Station it says
Index was out of range. Must be non-negative and less than the size of
the collection.
I've tried all types of combinations:
info!Station = .SelectSingleNode(".//span[#class='channel']").ChildNodes(1).ChildNodes(1).InnerText
info!Station = .SelectSingleNode(".//span[#class='channel']").ChildNodes(1).ChildNodes(3).InnerText
info!Station = .SelectSingleNode(".//span[#class='channel']").ChildNodes(0).ChildNodes(1).InnerText
info!Station = .SelectSingleNode(".//span[#class='channel']").ChildNodes(0).ChildNodes(2).InnerText
info!Station = .SelectSingleNode(".//span[#class='channel']").ChildNodes(0).ChildNodes(3).InnerText
What do I need to do in order to correct this?
If the whitespace is actually there, it counts as a child node. So:
Dim channelSpan = .SelectSingleNode(".//span[#class='channel']")
info!Channel = channelSpan.ChildNodes(3).ChildNodes(0).InnerText
info!Station = channelSpan.ChildNodes(3).ChildNodes(2).InnerText