I have the following html, there might be rows before the first row or rows after the last row I pasted, and I need to select ALL the rows follow the row containing "order number" cell, all the way up to the row contining "total", in the following case, I need to select 2 rows , one contain 123, and another one contains 456.
<tr>
<td> order number </td>
<td> order unit </td>
</tr>
<tr>
<td> 123 </td>
<td> 123 </td>
</tr>
<tr>
<td> 456 </td>
<td> 456 </td>
</tr>
<tr>
<td> total </td>
<td> 579 </td>
</tr>
Based on your requirements I think the easiest thing for you to do would be to select IWebElements that are found at your table row level. Then you can loop through the elements and compare child elements text to the numbers that you want. If the number doesn't match your first number then delete the element from the list.
After you find the first number set a flag that tells you not to delete and then check for the second number. It will skip the deletion, until you find the second number and then that would toggle the flag to delete again. At this point you could just have a delete for each one without the check or you can use the flag delete again.
Then you should have an implementation of IWebElements where you only have rows that match your requirements.
The only catch would be if you had repeated numbers that were part of your criteria...which would have to be a one off of this.
Related
I'm using Nokogiri and ruby, and I'm trying to get the information from the table at the following link: roster.
In the past I've used the "id" field for the table I want to use, but since I want to protect against them changing that id in the future and breaking my code I want to identify the table by assuming things about it's attributes. Such as, the table has an unordinary number of rows (<tr>), and assuming it would almost always have 4 or more columns.
The problem I'm having here is when I use the following code to pull back all tables in the web page and then look for the one with 80+ rows, it counts the child table's rows, when I'd like to only count the immediate children's rows.
tables = document.css("table")
tables.each do |table|
tables.each { |table| puts "#{table.css('tr').count}" }
end
Output for this would be...
202
135
109
22
19
1
0
There should actually be only one table here that is 100+ rows. But because the document embeds tables within tables it's returning counts for all the <tr> elements within the table including the embedded tables. How can I change my selector to only return the immediate children <tr> count from each table?
Having a bit of trouble with my SQL query.
I am retrieving a value from my SQL database, where it has the date of when a person was added as a life member. The column type is "date" rather than varchar as i couldnt organise by date if it was just a string.
The value of "DateInducted" is just a simple date such as "01/05/1963"
In the query builder for Visual Studio, I have tested my SQL Statement (which is below) and appears exactly as i want
"SELECT [DateInducted], [Name] FROM [LifeMembers] ORDER BY [DateInducted] DESC"
However when the Website is loaded, the value is
5/26/2012 12:00:00 AM
Where is it getting the time from? Is there a way to stop this? All i need is the date.
Thinking this is just a simple oversight on my part, but Google searches didnt provide the correct answer. According to W3 schools site, Date type should just give me the date?
Thanks in Advance
Edit:
Page Code now attached
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<h2>Lifemembers</h2>
<table class="DataTable">
<asp:Repeater ID="rptLifemembers" runat="server" DataSourceID="dsLifeMembers">
<HeaderTemplate>
<tr class="DataTableHeader">
<td style="min-width:40%"><strong>Date Inducted</strong></td>
<td style="min-width:60%"><strong>Member</strong></td>
</tr>
</HeaderTemplate>
<ItemTemplate>
<tr class="DataTableRow">
<td style="min-width:40%"><strong><%#Eval("DateInducted")%></strong></td>
<td style="min-width:60%"><%#Eval("Name")%></td>
</tr>
</ItemTemplate>
</asp:Repeater>
</table>
<asp:SqlDataSource ID="dsLifeMembers" runat="server"
ConnectionString="<%$ ConnectionStrings:SPEEDWAYConnectionString %>"
SelectCommand="SELECT [DateInducted], [Name] FROM [LifeMembers] ORDER BY [DateInducted1] DESC">
</asp:SqlDataSource>
You can either convert the date to varchar in the query or format the output in asp.net.
If you choose to do it in the query you can use the function Convert:
SELECT CONVERT(varchar(50),[DateInducted], 101) DateInducted, [Name] FROM [LifeMembers] ORDER BY [DateInducted] DESC
Add a format string to your binding expression:
<%#Eval("DateInducted", "{0:d}")%>
The datetime data type in SQL and the Date type in CLR always hold both a date and a time. In order to display one or the other and not both when converting to string, you need to use a format string or Date built-in string conversion functions such as ToShortDateString().
I've created the survey form but I don't know how to continue doing the database...
Can someone each me?
Anyway, Here's my code:
<tr>
<td class="auto-style2">5) Would you share our website to your friends?</td>
<td>
<asp:RadioButtonList ID="rbl5" runat="server" AutoPostBack="True" RepeatDirection="Horizontal" RepeatLayout="Flow">
<asp:ListItem>Yes</asp:ListItem>
<asp:ListItem>No</asp:ListItem>
</asp:RadioButtonList>
</td>
</tr>
<tr>
<td class="auto-style2">6) Any comments or suggestions?</td>
<td>
<asp:TextBox ID="tbComment" runat="server" Height="182px" TextMode="MultiLine" Width="271px"></asp:TextBox>
<br />
<br />
<br />
<input type="button" onclick="btnSubmit_Click()" value="Submit" />
<asp:Button ID="btnReset" runat="server" OnClick="btnReset_Click" Text="Reset" />
</td>
</tr>
</table>
</div>
</form>
As you noticed, I used radiobuttonlist and comment box. These are the reasons why I'm having problem to create the database... Please teach me...I only know how to create tables for database...
And the database might be something like this...
This is the QUESTION Table:
CREATE TABLE [dbo].[Question]
(
[Id] INT NOT NULL PRIMARY KEY,
[Question] NCHAR(10) NULL,
[Options] NCHAR(10) NULL
)
This is the ANSWERS Table:
CREATE TABLE [dbo].[Answers]
(
[Id] INT NOT NULL PRIMARY KEY,
[QuestionId] NCHAR(10) NULL,
[Answers] NCHAR(10) NULL
)
And I'm also not sure about the NCHAR(10) ...
So this is how bad I am in programming.
Please teach me.
If you don't have experience with SQL, you could try parse.com, just to get something up and running quick.
You'll have to read through their docs, they also have tutorials and a quickstart explanation.
I would still recommend learning about SQL, simply because you don't really need to know that much to get going.
you need to use database servers like sql or ms-sql or oracle or other database engines unless u are asking query to create the database, which i assume not, as there is no query or other related tags in your question
If you have access to a SQL Server (SQLExpress, LocalDB, Full MSSQL) and you are able to make use of EF (Entity Framework), then you can use Code First to build your Database from your domain models.
EF Code First Tutorial
Assuming you're running Windows, SQLExpress and LocalDB should already be installed on your PC, if not they can be downloaded here. Either of these will suffice for what you are looking to do and both are free. You could alternatively pay for a fully featured MSSQL license, however, this might be overkill for you currently.
All of these will happily run on your local machine, if however you are looking to deploy your application to the Internet, you may want to considering some sort of hosting option unless you are comfortable with doing so yourself.
I wonder if someone can help:
Long story short, I'm using MSSQL2005 to build a Pivot table. The data being examined is limited by date range (All data for 1 week starting from the nearest Monday to the date selected)
When I run the Stored Proc and pass it a date, I get The correct table back eg:
Time
1 Jan 09
2 Jan 09
3 Jan 09
...
09:00
0
9
25
...
09:30
8
27
65
...
10:00
20
44
112
...
The only problem I have is that the column headers will vary based on both the date passed in to the SP (The desired view date) and the logic inside the SP (which forces the left-hand column to be the nearest Monday to the date specified).
This means that when I display the results to the user, I (currently) need to duplicate the date-checking logic in classic ASP [easy but a maintainability fail]
What I really need is a way of retrieving the column names from the recordset itself.
Can someone please point me in the right direction?
I've Googled but all the results I get seem to relate to reading a Table Schema - which doesn't help in this case as my table is being generated on the fly in memory.
Many thanks in advance for any help you can provide
Given an ado record set you could do roughly the following (This is in psuedo code):
foreach (field in rs.Fields)
{
alert(field.Name);
}
This will give you the name of the field check out this documentation.
Something like this ought to do it:-
<table>
<thead>
<tr>
<%For Each fld in rst.Fields%>
<th><span><%=Server.HTMLEncode(fld.Name)%></span></th>
<%Next %>
</tr>
</thead>
<tbody>
<%
Do Until rst.EOF
OutputRow rst.Fields
rst.MoveNext
Loop
%>
</tbody>
</table>
Sub OutputRow(fields)
%>
<tr>
<%For Each fld in fields%>
<td><span><%=Server.HTMLEncode(fld.Name)%></span></td>
<%Next %>
</tr>
<%
End Sub
%>
I was wondering if I could have more than one tables like below. If you notice, I have applied th with the id="id", and id="name". so If have the more than one tables then, there will be many ths with the same id.
<table>
<thead>
<tr><th id="id"></th><th id="name"></th></tr>
</thead>
<tbody>
<tr><td headers="id">1</td><td headers="name">First Name</td></tr>
</tbody>
</table>
No. You can't. An id must be unique in the document.
The simplest option is to apply a prefix to each id in a given table e.g. id="mytable_name"