|
Are you looking for this
using System.Data.SqlClient;
public DataTable ReturnDataTbl(string XmlFile)
{
DataSet dset = new DataSet();
FileStream fstr = new FileStream(XmlFile, FileMode.Open, FileAccess.Read);
dset.readXml(fstr);
DataTable dtbl = dset.Tables[0];
fstr.Close();
dset.Dispose();
return dtbl;
}
Live Life King Size
Alomgir Miah
|
|
|
|
|
Hi
I have the below sub the reads a single row table and populates the results in a data grid. Some of the fields have numerical values to represent settings.
E.G.
SecurityLevel
1
1 may be admin, so how to I replace the 1 with admin before I populate my datagrid?
Dim Command1 As SqlCommand = New SqlCommand("SELECT [Name], Type, SecurityLevel, Version, CreatedDateTime, Driver, CabinetType, NetworkAddress, LoginFlag, DomainName, AuthenticationType, WebServerAddress FROM dbtab")
Command1.CommandType = CommandType.Text
Command1.Connection = SQLConnection1
myDataSet = New DataSet("myDataSet")
SQLAdapter1.SelectCommand = Command1
SQLAdapter1.Fill(myDataSet, "Document")
DataGrid2.SetDataBinding(myDataSet, "Document")
About 4 of the Columns in the above select statment have values that I would like to replace bases on a lookup list.
OK BIG point I CAN NOT make an intermediate table
Any thoughts
When people make you see red, be thankful your not colour blind.
|
|
|
|
|
Replace SecurityLevel in your Sql statement with a case statement structured as needed.
CASE
WHEN SecurityLevel = 1 THEN 'Administrator'
WHEN SecurityLevel = 2 THEN 'Supervisior'
ELSE 'User'
END As SecurityLevel,
|
|
|
|
|
http://groups.google.com/group/microsoft.public.dotnet.framework.aspnet.webcontrols/browse_thread/thread/e3de64786d1684a2/be32e7aefcb96da6?lnk=st&q=DataGrid+display+custom+value&rnum=1&hl=en#be32e7aefcb96da6
Live Life King Size
Alomgir Miah
|
|
|
|
|
hi buddies
Can anyone help me to get connected with the Oracle 8i through c#. i am using asp.net1.1 and
1. not able to see the "OracleClient" namespace after the "system.Data ".How can i get it.
2. if I want to get connected through Oledb. how can i do that.
Thanks in advance.Please someone help me fast. its urgent.
bye
nauty
|
|
|
|
|
nauty wrote: 1. not able to see the "OracleClient" namespace after the "system.Data ".How can i get it.
You need to add a refernece to System.Data.OracleClient to your assembly. (Right click on the project in the solution folder. Select Add Reference... and look in the .NET tab for it)
nauty wrote: 2. if I want to get connected through Oledb. how can i do that.
Use the classes in the System.Data.OleDb namespace.
ColinMackay.net
Scottish Developers are looking for speakers for user group sessions over the next few months. Do you want to know more?
|
|
|
|
|
So, "osql -L" dumps a list of SQL in the same subnet. What if I want to hide this instance? Is moving it out of the subnet my only option?
|
|
|
|
|
Hi,
Is it possible to combine the two statements below into one?
I want the company name and suppleir's name to list together alphabetically, and not list at the bottom of the supplier's list of names.
"SELECT SupplierID, LastName + ', ' + FirstName AS NameOrCompany, IsLocal FROM Suppliers WHERE IsLocal=false ORDER BY LastName"
"SELECT SupplierID, Company AS NameOrCompany, IsLocal FROM Suppliers WHERE IsLocal=true ORDER BY Company"
Thanks,
Ron
-- modified at 19:01 Monday 20th February, 2006
|
|
|
|
|
How about using a UNION statement for the two queries, then wrap them with an outer SELECT that performs the ordering?
SELECT SupplierID, NameOrCompany, IsLocal
FROM
(
SELECT SupplierID
, LastName + ', ' + FirstName AS NameOrCompany
, IsLocal
FROM Suppliers
WHERE IsLocal=false
UNION ALL
SELECT SupplierID
, Company AS NameOrCompany
, IsLocal
FROM Suppliers
WHERE IsLocal=true
) x
ORDER BY NameOrCompany
|
|
|
|
|
|
What am I doing wrong?
select username AS UserID, domainname AS Domain, dt AS Date from testtable
gives me:
UserID, Domain, Date
kt001, c_domain, 2/20/2006
kt001, p_domain, 2/15/2006
kt001, p_domain, 2/19/2006
which is normal.
SELECT username AS UserID, MAX(domainname) AS Domain, MAX(dt) AS Date
FROM testtable
GROUP BY username
gives me:
UserID, Domain, Date
kt001, p_domain, 2/20/2006
which i would want the domain of whatever the MAX date was... any clues?
|
|
|
|
|
I think you may want to handle this as a subquery - something like this:
Select a.username as User, b.domainname as Domain, a.MaxDT as Date
From
(
Select username, Max(dt) as MaxDT
From testtable
Group By username
) a INNER JOIN testtable b ON a.username=b.username AND a.MaxDT = b.dt
|
|
|
|
|
Hello,
I have a table such as;
(A and B are attribute names)
A B
- -
1 A
1 B
2 B
3 A
5 C
5 A
I would like a query that returns me each distinct group of B column with its A column values.
For instance;
1, 3, 5 > A
1, 2 > B
5 > C
and I would like to be able to do something on each distinct group.
(hope that I could be able to point my request)
Sarp
|
|
|
|
|
|
Hi,
I have the following table t
ID, M_ID, S_ID, Date
1 , 2 , 7 , 2005-05-06 13:45:56:000
2 , 2 , 7 , 2005-05-06 13:45:58:000
3 , 2 , 8 , 2005-05-06 13:46:56:000
4 , 2 , 9 , 2005-05-06 13:46:57:000
The only thing differing row 1 and 2 is the date.
How can i perform a "distinct select" on the 3 first columns (ID, M_ID, S_ID) i.e ignoring date.
The result i want is
ID, M_ID, S_ID, Date
1 , 2 , 7 , 2005-05-06 13:45:56:000
3 , 2 , 8 , 2005-05-06 13:46:56:000
4 , 2 , 9 , 2005-05-06 13:46:57:000
Niclas Ahlqvist
|
|
|
|
|
select ID, M_ID, S_ID, min(Date)
from t
group by ID, M_ID, S_ID
Chris Meech
I am Canadian. [heard in a local bar]
When I want privacy, I'll close the bathroom door. [Stan Shannon]
BAD DAY FOR: Friendly competition, as Ford Motor Co. declared the employee parking lot at its truck plant in Dearborn, Mich., off limits to vehicles built by rival companies. Workers have to drive a Ford to work, or park across the street. [CNNMoney.com]
Nice sig! [Tim Deveaux on Matt Newman's sig with a quote from me]
|
|
|
|
|
Hehe easy enough..
thanks..
nic
|
|
|
|
|
I am having a simular problem as posted above but I want to Min/Max data other than a date field and i'm getting mixed data.
select username AS UserID, domainname AS Domain, dt AS Date from testtable
gives me:
UserID, Domain, Date
kt001, c_domain, 2/20/2006
kt001, p_domain, 2/15/2006
SELECT username AS UserID, MAX(domainname) AS Domain, MAX(dt) AS Date
FROM testtable
GROUP BY username
gives me:
UserID, Domain, Date
kt001, p_domain, 2/20/2006
Any clue?
|
|
|
|
|
Your getting exactly what you ask for! Which in this case is what's the MAX of the domain column and the MIN of the date column. I think what you are after is the row of data, that is identified by the MAX of the domain column. To do that you need to use a subquery or a view. Here's using a subquery.
select tt.userid, tt.domain, tt.date
from ( select m.userid, max(m.domain)
from testtable m
group by m.userid
) tmp
, testtable tt
where tt.userid = tmp.userid
and tt.domain = tmp.domain
;
Chris Meech
I am Canadian. [heard in a local bar]
When I want privacy, I'll close the bathroom door. [Stan Shannon]
BAD DAY FOR: Friendly competition, as Ford Motor Co. declared the employee parking lot at its truck plant in Dearborn, Mich., off limits to vehicles built by rival companies. Workers have to drive a Ford to work, or park across the street. [CNNMoney.com]
Nice sig! [Tim Deveaux on Matt Newman's sig with a quote from me]
|
|
|
|
|
Hi!
I have some problems with my typed dataset, the dataset contains several datatables and the problem occurs when i try to load the dataset with the ReadXml function. The problem is that some of the tables won't load properly. For example:
<br />
MyDataSet ds = new MyDataSet;<br />
ds.ReadXml("ds.xml");<br />
The table table1 in ds will be empty, even if the xml-file contains data that belongs to table1.
<br />
MyDataSet ds = new MyDataSet;<br />
ds.table1.ReadXml("table1.xml");<br />
Doesnt work either, but this will work:
<br />
MyDataSet ds = new MyDataSet;<br />
MyDataSet.table1 tb1 = new MyDataSet.table1();<br />
tb1.ReadXml("table1.xml")<br />
ds.table1.Merge(tb1);<br />
Any ideas what the problem is?
/Jesper Miller
|
|
|
|
|
Hi,
I'm populating a datatable from a database file and then populating a combobox with it:
ComboBox1.DataSource = myDataTable;
ComboBox1.DisplayMember = "Name";
ComboBox1.ValueMember = "NameID";
The problem is:
I need to have more than one hidden value. I would like to have two hidden values in ValueMember. I thought maybe I could combine two columns (split with a comma) and then use an array to get the right value via split. Is it possible to commbine columns at the ValueMember?
ComboBox1.ValueMember = "NameID" + ',' + "IsMarried";
Nothing I tried like this works, so I'm guessing you can only assign ONE column to the ValueMember?
I thought this might be true so I tried to combine the two columns at the sql line:
NameID + ',' + IsMarried AS Name_IsMarried
This did not work as well, I think because I'm trying to combine a string with a boolean column.
Any help would be greatly appreciated!
Ron
|
|
|
|
|
Hi,
Use this in ur SQL query
SELECT NameID + ','+ convert(nvarchar,IsMarried ) Name_IsMarried
I hope this will help you...
Regards,
Ritesh
|
|
|
|
|
Hi Ritesh,
Thanks for the advice!
I tried the convert, but I'm getting this error...
ERROR: Undefined Function 'Convert' in Expression
OleDbCommand("SELECT convert(nvarchar,NameID) + ',' + convert(nvarchar,IsMarried) AS Name_IsMarried, myConnection);
Any idea why I would get this error?
Thanks!
Ron
|
|
|
|
|
You can access more than just the 2 values of the combobox, every item shown in the combobox is a datarow (if binded to a datatable), if you need another columnvalue just get the current row with
Dim r As DataRow = Me.cboArticulos.SelectedItem
then you can access any column of the current row with r.item("Columnname")
im not sure if this is what you are looking for
Alexei AR
Theres always a better way
Look for it
|
|
|
|
|
Hi Alexie,
Thanks for the advice, I'm new to programming and havn't tried binding yet.
I'm trying to set it up, but I use C#. Are you able to convert your code
to C#? I tried this, but it did not work.
comboBox1.DataBindings.Add("SelectedValue", myDataTable, "Store.Supplier");
//This code must be incorrect, it crashes the event (item selected)
DataRow myRow = (DataRow)myDataTable.SelectedItem;
Thanks for your help,
Ron
|
|
|
|
|