|
You'll have to use p/invoke for this. The corresponding win32 function is SHGetFileInfo[^].
You don't need an actual file, a file name alone will do.
Regards,
mav
--
Black holes are the places where God divided by 0...
|
|
|
|
|
Thanks for the help, after a lot of searching and reading I found a really good class to work with over at eggheadcafe.
If someone is interested, here's a link IconHandler
Cheers, Johan
|
|
|
|
|
Hello,
I'm new in C# programming and I have a question.
I want to delete a row from a table using a button.
The row i want to delete must have the same information that the selected cell in a grid view.
How can i do that?
Thanks.
|
|
|
|
|
All you need is a stored procedure that takes as a parameter the ID of the row you wish to delete. Obtain the ID from the selected row in the grid.
only two letters away from being an asset
|
|
|
|
|
write CommandText = "delete from <tablename> where <row identity=""> = " + >gridview selected item<
hope it will help
Becoming Programmer...
|
|
|
|
|
Hi.
To delete the row from table by pressing button with selected value from GridView:
protected void btDelete_Click(object sender, EventArgs e)
{
GridViewRow gvr = GridView1.SelectedRow;
con.Open();
cmd = new SqlCommand("<stored procedure="" name="">", <sqlconnection object="">);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add(new SqlParameter("@xID <procedure parameter="">", SqlDbType.VarChar));
cmd.Parameters[0].Value = gvr.Cells[<cell id="">].Text;
cmd.ExecuteNonQuery();
}
Thanks Wish Helps U.
Good Thing Goes With Good Guys.........
|
|
|
|
|
Hi All,
Slim pickings for this topic on MSDN [1, 2]. [2] does not really apply, but it was a keyword hit ("SelectedItemChanged"). Does any one know how to receive this notification? I'm not receiving it.
What I done so far: Hightlight the TreeView in Design Mode, and then switching to Events: no SelectedItemChanged available. I tried the following (TreeView control name is ObjectTree ):
private void ObjectTree_SelectedItemChanged(object sender, EventArgs e)
{
...
} Sorry about another beginner question. I have no idea what to do with (from [1]):
public static readonly RoutedEvent SelectedItemChangedEvent Pasting it into the code resulted in compile errors. The Microsoft Wiki[^] is looking more appealing every day.
Jeff
[1] TreeView.SelectedItemChangedEvent Field[^]
[2] DomainUpDown.SelectedItemChanged Event[^]
|
|
|
|
|
Hi Jeff,
I don't know, I haven't had much experience with TreeView, but I noticed your [1] ref is
on .NET 3.0 suggesting SelectedItemChangedEvent does not exist on 2.0 (assuming that's
what you use), which confuses me since 3.0 is said to be identical to 2.0 except for
extra modules (WPF, WCF, ...).
RoutedEvent is unknown to me; it too requires .NET 3.0
Luc Pattyn [Forum Guidelines] [My Articles]
this months tips:
- use PRE tags to preserve formatting when showing multi-line code snippets
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
Hi Luc,
Luc Pattyn wrote: I noticed your [1] ref is on .NET 3.0 ...
That would make it an ID-10T eror... I despise being on this end of the learning curve.
Jeff
|
|
|
|
|
Jeffrey Walton wrote: on this end of the learning curve
is there an other end? I thought it was like a rainbow...
Luc Pattyn [Forum Guidelines] [My Articles]
this months tips:
- use PRE tags to preserve formatting when showing multi-line code snippets
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
Huh? A rainbow...
So it starts off really hard, then eases out. And as time goes by you slowly forget everything you already learned?
My current favourite word is: PIE!
Good ol' pie, it's been a while.
|
|
|
|
|
The Undefeated wrote: A rainbow...
Yep. It invites you for a long journey, but you will never reach the end (remember,
that's where the pot of waffles and pie is). I can't remember the part about forgetting
everything though.
Luc Pattyn [Forum Guidelines] [My Articles]
this months tips:
- use PRE tags to preserve formatting when showing multi-line code snippets
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
I have an older imaging toolkit that I use in a number of apps and I am trying to migrate one of them to C#. The toolkit has a number of ActiveX OCX controls. I have tried to add them to my C# app, but to no avail. I use SharpDevelop as my IDE.
So far, I have been able to add references to my app, but I cannot find a way to add the controls as components so that I can drop them onto my forms. Can this be done, and if so, how do I go about doing so?
Thanks in advance,
William
|
|
|
|
|
Hello all,
If i am showing a message with a MessageBox how can i close it myself with a timer...?
Thanks for the help...
Luis E Tineo S
|
|
|
|
|
You can't. Create your own form that looks like a message box so that you can put a timer on it.
Experience is the sum of all the mistakes you have done.
|
|
|
|
|
Oh well... I think that it is much better since i can have it look the way i wanted, plus i can have more control over it.
Thanks for the info!!!
Luis E Tineo S
|
|
|
|
|
|
OK, I love to learn new and better ways to do things, but this just doesn't seem one of them.
I'm originally from the Java camp so I've used straight DB code such as hard coded calls to the database and ORM tools like Hibernate. I've been working in VB for the past 5 years on various projects and have used similar techniques here as well.
I am working on a fairly large project and decided to use strongly typed db access such as what is taught in these fairly popular tutorials:
http://www.asp.net/learn/data-access/[^]
Boy am I getting a headache. It seems to me that the only benefits I get are IntelliSense and compile time checking. IntelliSense wasn't available before strongly typed database code so this is more of a convenience than any real need. Compile time checking is nice but I've already had several errors that are not caught until runtime. These errors largely deal with enforcing constraints when filling a DataTable using a standard DataAdapter. Most of these errors are extremely trivial, do not interfere with my actual code and would never have been brought to my attention without strongly typed db code.
So here is what I see as the major negative. I feel like I am getting much more code dependence rather than the current shift towards independence. This project largely works with data from a vendor database. If they ever update their schema (which can be as often as once a week) my app will break, even if they simply change a field from varchar(10) to varchar(12).
I'm starting to lean towards either rolling my own db code or using NHibernate again. Also, LINQ seems to be a departure from this strategy as well.
Does anyone else have any comments? Have any of you used strongly typed db code on a large project and found it to be indispensable? What am I missing?
Thanks!
Matt Penner
|
|
|
|
|
We use XPO[^] here at work. We had done it "by hand" previously, and XPO saves us tons of time.
That said, it's not a walk in the park. There are still issues, such as the db scheme change breakings (although XPO handles most schema changes automatically OK).
Most O/R mappers give you database independence; your code will work with MS SQL Server, MySQL, Oracle, Access, whatever.
Overall, I'm certainly glad we have an O/R mapper. It could be better, but it's far, far better than doing it by hand.
|
|
|
|
|
Judah Himango wrote: It could be better
Yes it could. As a work around, don't do development that uses databases... actually don't do development that uses data at all.... oh what heck just don't do software development. Hey maybe the circus that's in town could use another clown?
|
|
|
|
|
led mike wrote: Hey maybe the circus that's in town could use another clown?
Sorry, I went there last night and took the LAST CLOWN JOB IN TOWN. Ha. Take that, you clown-wannabe.
|
|
|
|
|
Judah Himango wrote: you clown-wannabe.
Not really... I was just clowning around.
|
|
|
|
|
Yay XPO. I like XPO - even with its quirks.
|
|
|
|
|
MattPenner wrote: What am I missing?
This requirement of yours seems to stand out... to me anyway.
MattPenner wrote: If they ever update their schema (which can be as often as once a week)
That seems to be a significant requirement to me. Based on that requirement I would not expect standard database techniques to sufficiently meet that requirement. It might warrant specific custom design to accomplish flexibility and extensibility.
|
|
|
|
|
On program startup, you could query the schema for all your tables. Build class to hold information like field names, value types and lengths.
Here's some of my code, I'm sure most people here can come up with something more effecient . The tabbing is getting killed but you get the idea.
Mine looks something like this
<br />
namespace DBWrapper<br />
{<br />
public class FieldInfo<br />
{<br />
private string strField = string.Empty;<br />
private string strType = string.Empty;<br />
private int nLen = 0;<br />
<br />
public string FieldName<br />
{<br />
get { return strField; }<br />
set { strField = value; }<br />
}<br />
<br />
public string FieldType<br />
{<br />
get { return strType; }<br />
set { strType = value; }<br />
}<br />
<br />
public int FieldLen<br />
{<br />
get { return nLen; }<br />
set { nLen = value; }<br />
}<br />
}<br />
<br />
public class TableData : List<FieldInfo><br />
{<br />
public FieldInfo Get(string strFieldName)<br />
{<br />
FieldInfo retFieldInfo = new FieldInfo();<br />
<br />
foreach (FieldInfo fiInfo in this)<br />
{<br />
if (string.Compare(fiInfo.FieldName, strFieldName, true) == 0)<br />
return fiInfo;<br />
}<br />
<br />
return new FieldInfo();<br />
}<br />
<br />
}<br />
}
<br />
To get the schema info I use this (I think this is half my code and half somebody elses but it's been so long since I touched it I don't remember)<br />
<br />
protected bool GetTableSchema(out DataTable dtSchema)<br />
{<br />
dtSchema = new DataTable();<br />
SqlCommand dbCommand = new SqlCommand();<br />
SqlDataReader dbReader;<br />
bool bRetValue;<br />
<br />
if (!OpenDatabase())<br />
return false;<br />
<br />
try<br />
{<br />
dbCommand.CommandText = "SELECT * FROM " + m_strTableName;<br />
dbCommand.Connection = m_DBConnection;<br />
dbReader = dbCommand.ExecuteReader(CommandBehavior.KeyInfo);<br />
dtSchema = dbReader.GetSchemaTable();<br />
bRetValue = true;<br />
}<br />
catch (Exception ex)<br />
{<br />
string strErrorMessage = "Error Getting Table Schema " + dbCommand.CommandText + "\r\nMsg: " +<br />
ex.Message;<br />
#if DEBUG<br />
Console.WriteLine(strErrorMessage);<br />
#else<br />
m_LogHandler.WriteLogLine(strErrorMessage);<br />
#endif<br />
bRetValue = false;<br />
}<br />
finally<br />
{<br />
CloseDatabase();<br />
dbCommand.Dispose();<br />
}<br />
<br />
return bRetValue;<br />
}
|
|
|
|