Thursday, March 22, 2012
count 2 value in a table
need to know how to do a count for 2 value in a column
example :
my table(entries)
has the field name 'selection'
under this selection, data inside have is e.g(apple,apple,pear,pear,pear,orange)
i need to do a COUNT on how many apple and pear there is inside this table
but i seriously have no idea, pls kindly help thanksThis sounds like homework from an "Introduction to databases" course, but I'm willing to give you the benefit of the doubt...SELECT Count(*), selection
FROM entries
GROUP BY selection
ORDER BY Count(*) DESC -- gratis-PatP|||SELECT Count(*), selection
FROM entries
GROUP BY selection
ORDER BY Count(*) DESC -- gratis
sorry for my ignorance..
wat u meant by DESC over here??
wat i want is to count how many pears and apple there is in that table but not orange|||DESC means descending, and you don't have to use it if you don't want to
did you want the total of apples and pears? that's different --
SELECT count(*) as applesandpears
FROM entries
WHERE selection in ('apple','pear')|||thanks so much...
really so basic
need to read up my books again :(|||Sorry, my background is showing :rolleyes:
Gratis is a Latin vulgate term that means "free of charge" or "complimentary". When I used it in a comment, I meant that I expected it to make things easier to use, without actually impacting the solution at all.
As Rudy pointed out, in this case it simply orders the result set so that the most frequently occuring items appear at the top of the list. You can safely ignore it if it doesn't help you.
-PatP|||ok got it ..
but still appreciated
:)
Wednesday, March 7, 2012
Could Not Find Installable ISAM
Pls Can someone tell me why this code is giving me "Could not find installable ISAM"
ProtectedSub Page_Load(ByVal senderAsObject,ByVal eAs System.EventArgs)HandlesMe.Load
Dim strConnAsNew OleDbConnection("Provider=Microsoft.JET.OLEDB.4.0;Data Source=" & Server.MapPath("~/App_Data/WK 48-2007.xls") &";" &"Extended Properties=""EXEL 8.0;HDR=YES""")
strConn.Open()
Dim StrSelectAsString ="SELECT * FROM [Sheet1$]"
Dim CommAsNew OleDbCommand(StrSelect, strConn)
Dim readerAs IDataReader = Comm.ExecuteReader
GRD.DataSource = reader
GRD.DataBind()
reader.Close()
strConn.Close()
EndSub
Hi,
From your description, it seems that you are using OLEDB Jet driver to connect to your EXCEL table, right?
When you try to set custom, provider-specific properties for the Microsoft OLE DB Provider for Jet in the ADO OLE DB connection string, you receive the following error message:
Could not find installable ISAM
CAUSE
The Microsoft OLE DB Provider for Jet includes many custom properties that you can set only after you establish a connection to the database. These provider-specific properties are custom OLE DB session properties. You cannot set these properties in the ADO OLE DB connection string; you must set these properties after the connection is opened.
For these properties in details and get more information on this issue, see
http://support.microsoft.com/kb/318161/en-us
Thanks.
Hi Nai-Dong,
Tnx. Socan i use SqlClient to connect to EXEL table ? How ?
Thanks again
|||Hi
Hope this is what you are looking for
Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\MyExcel.xls;Extended Properties="Excel 8.0;HDR=Yes;IMEX=1";
string SQLQuery = "SELECT * FROM [sheet1$]".
// excel worksheet name followed by a "$" and wrapped in "[" "]" brackets.
You can just replace all your OleDB with SQL... In other words, OleDBconnection with SQLConnection and so on.
This query can also be executed using a DataAdapter using the FILL method. That can give you back a dataset which will contain all the rows.
Hope this helps
VJ
|||Hi,
Tnx. Socan i use SqlClient to connect to EXEL table ? How ?
Since you are using OLEDB driver, you should use OLEDBCommand (using System.Data.OleDb;) to execute your query.
Thanks.