|
Thanks Griff..But this gives "Argument Exception" saying parameter is not valid.
|
|
|
|
|
Then I suspect that the data is not a jpeg file - what are you trying to do? Not "read a file as an Image, but what is the file? Why are you reading it? What are you trying to achieve? It may be that one of use is using the wrong terms!
If you get an email telling you that you can catch Swine Flu from tinned pork then just delete it. It's Spam.
|
|
|
|
|
I need help on how to capture windows messages.
|
|
|
|
|
|
What technology are you using? Windows Forms or WPF? If you're using WinForms, there's an implicit WndProc that you can add your code into. If it's WPF, things get a little more complicated as you have to add your own WndProc handler.
|
|
|
|
|
Dear All,
I have used SqlConnection to connection to Sql database. There are some friends, they always use IDbConnection. He also suggest me use IDbConnection. I also see some of project here using IDbConnection: AccountPlus[^]
_ What's the difference bettwen SqlConnection and IDbConnection.
_ Using IDbConnection is better?
Tks,
LVD
|
|
|
|
|
SqlConnection implements IDbConnection and therefore IS_A IDbConnection.
In my opinion, one should code to the interfaces; that's what I do, and I'm not the only one. It may not matter now, but if you ever have to provide support for another database, you'll be glad you did.
I regularly work with SQL Server, MySQL, Oracle, Access, and Excel. In the past I've also had to work with Cache, Ingres, and maybe some others I've forgotten. As long as there's an ADO.net connector, my code can work with it.
|
|
|
|
|
To add to PIEBALDconsult's answer IDbConnection is not used in LINQ to SQL DataContext or Entity Framework.
Lobster Thermidor aux crevettes with a Mornay sauce, served in a Provençale manner with shallots and aubergines, garnished with truffle pate, brandy and a fried egg on top and Spam - Monty Python Spam Sketch
|
|
|
|
|
Hi,
Totally new to LINQ and wondering how I can get the following sandbox code to work. Ideas?
List<PositionValues> list = new List<PositionValues>();
PositionValues item1 = new PositionValues();
item1.Position = 2;
item1.Value = 44;
list.Add(item1);
PositionValues item2 = new PositionValues();
item2.Position = 1;
item2.Value = 33;
list.Add(item2);
var resultList = from b in list group b by b.Position into g orderby b.Value select b;
It relies on:
public struct PositionValues
{
/// <summary>
/// The position.
/// </summary>
public int Position;
/// <summary>
/// The position.
/// </summary>
public double Value;
}
Thanks for looking,
Alan
|
|
|
|
|
It might be helpful to tell us what isnt working, or what you expect to happen.
|
|
|
|
|
Biggest thing that looks wrong to me is that your not using the groupby properly
have a look at this to for a good example 101 LINQ Samples in C#[^]
If that dont work please tell us as much information as possible and we will help you as much as we can possible.
Lobster Thermidor aux crevettes with a Mornay sauce, served in a Provençale manner with shallots and aubergines, garnished with truffle pate, brandy and a fried egg on top and Spam - Monty Python Spam Sketch
|
|
|
|
|
Hi J4amieC and Simon_Whale,
Sorry I did not respond sooner. I started to look other directions and was paying less attention to this thread.
For the code supplied, I am getting the compiler error:
"The name 'b' does not exist in the current context"
If I could get rid of the error, I am hoping that the code would do two sorts:
A primary sort based on "Position" and a secondary sort on "Value". I would end up with the list grouped on "Position" and within each "Position" groupings they would be sorted based on "Value". If the following code snippet is added for a 3rd item:
PositionValues item3 = new PositionValues();
item3.Position = 1;
item3.Value = 22;
list.Add(item3);
the resulting list (I am hoping) would be ordered as follows:
resultList[0] {1, 22}
resultList[1] {1, 33}
resultList[2] {2, 44}
where the first entry in the parenthesis is the "Position" and the second is the "Value".
I had looked previously at the 101 LINQ Samples but did not see something readily that was close enough to this (but probably just missed it since new to this - good suggestion and I plan on using as reference).
Thanks again,
Alan
|
|
|
|
|
Since responses have ended, I will post elsewhere. Thanks for the replies.
|
|
|
|
|
let's say i have two columns,one called area and second called city .i want to get all the cities when i choos a Specific area .
i use with datatable and i don't know how to Formulate an sql Query.it's suppose to be like that:
string areaName = DropDownList1.Items[DropDownList1.SelectedIndex].ToString().Trim();
DataRow[] city = dt.Select("city_name where area='"+areaName+"'");
for (int i = 0; i < city.Count<DataRow>(); i++)
{
DropDownList2.Items.Add(city[i]["city_name"].ToString());
}
|
|
|
|
|
I can't quite tell what you are trying to do there, but (dt is a DataTable, right?) you could try:
dt.DefaultView.RowFilter = "area=" + areaname ;
DropDownList2.DataSource = dt.DefaultView ;
Edit: Here's a full working example.
System.Data.DataRow dr ;
// Define a State table
System.Data.DataTable state = new System.Data.DataTable("State");
state.Columns.Add(new System.Data.DataColumn("ID",typeof(int)));
state.Columns.Add(new System.Data.DataColumn("Name",typeof(string)));
// Add some rows
dr = state.NewRow() ;
dr [ "ID" ] = 1 ;
dr [ "Name" ] = "Arizona" ;
state.Rows.Add ( dr ) ;
dr = state.NewRow() ;
dr [ "ID" ] = 2 ;
dr [ "Name" ] = "California" ;
state.Rows.Add ( dr ) ;
// Set the first ComboBox to display the table
this.comboBox1.DataSource = state.DefaultView ;
this.comboBox1.DisplayMember = "Name" ;
// Define a City table
System.Data.DataTable city = new System.Data.DataTable("State");
city.Columns.Add(new System.Data.DataColumn("ID",typeof(int)));
city.Columns.Add(new System.Data.DataColumn("State",typeof(int)));
city.Columns.Add(new System.Data.DataColumn("Name",typeof(string)));
// Add some rows
dr = city.NewRow() ;
dr [ "ID" ] = 1 ;
dr [ "State" ] = 1 ;
dr [ "Name" ] = "Phoenix" ;
city.Rows.Add ( dr ) ;
dr = city.NewRow() ;
dr [ "ID" ] = 2 ;
dr [ "State" ] = 1 ;
dr [ "Name" ] = "Tucson" ;
city.Rows.Add ( dr ) ;
dr = city.NewRow() ;
dr [ "ID" ] = 3 ;
dr [ "State" ] = 2 ;
dr [ "Name" ] = "San Diego" ;
city.Rows.Add ( dr ) ;
dr = city.NewRow() ;
dr [ "ID" ] = 4 ;
dr [ "State" ] = 2 ;
dr [ "Name" ] = "Los Angeles" ;
city.Rows.Add ( dr ) ;
// Set the second ComboBox to display the table
this.comboBox2.DataSource = city.DefaultView ;
this.comboBox2.DisplayMember = "Name" ;
// Add a SelectedIndexChanged handler
this.comboBox1.SelectedIndexChanged += delegate ( object sender , System.EventArgs e )
{
System.Data.DataRowView item = this.comboBox1.SelectedItem as System.Data.DataRowView ;
city.DefaultView.RowFilter = "State=" + item [ "ID" ] ;
return ;
} ;
// Select the first State
this.comboBox1.SelectedIndex = 0 ;
modified 14-Jan-13 9:49am.
|
|
|
|
|
i have two DropDownList and i want that if i choose from the first DropDownList valu(i mean area) automaticly in the second DropDownList i will have all the cities in that area.
|
|
|
|
|
Trap the change event on the 1st combo and filter the datasource of the second combo based on the selected item of the 1st combo.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
|
By learning what an event is, how to wire it up and how to deal with the result. All this depends on your UI, ASP/SL-WPF/Winforms are all different.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
someone already help me from anther site ,my problem now is only if i press on some button(even if the button do not doing anyting) i see the new data in my second DropDownList.how can i get the data Immediate in the second DropDownList when i change something in the first DropDownList ?
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
DropDownList2.Items.Clear();
string areaName = DropDownList1.Items[DropDownList1.SelectedIndex].ToString().Trim();
DataRow[] city = dt.Select("area='" + areaName + "'");
for (int i = 0; i < city.Count<DataRow>(); i++)
{
DropDownList2.Items.Add(city[i]["city_name"].ToString());
}
}
|
|
|
|
|
Just set the DefaultView's RowFilter. Done.
modified 14-Jan-13 9:51am.
|
|
|
|
|
i dont understand to what do you mean
|
|
|
|
|
You have a DataTable with the cities, right? It has a DefaultView property. You set it as the DataSource of the control. Possibly have to set the DisplayMember property as well. And when the value in the other control changes, set the RowFilter value of this one.
|
|
|
|
|
the solution was to change in the propoty of the first DropDownList the autopostback to true
|
|
|
|
|
I need to translit the documents, translit from cyrillic letters to latin letters.
and I need to make my program to work with as many documents as it possible, and huge document, may be a document with 500 pages....
So, I'm thinking different ways to implement it to work as efficient as possible...
any advices?
|
|
|
|