|
Heath Stewart wrote:
even more than my MIS cracks I dish-out to Nick Parker!
You have to stop grouping me with the other M.I.S. students that work there.
-Nick Parker
DeveloperNotes.com
|
|
|
|
|
Heath Stewart wrote:
People who post such blatently stupid questions don't even bother to google the 'net or search CP,
Especially as when we needed something similar we found a freeware library in minutes with google !!!
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
|
Well, I unfortunately don't have the book (although I am currently keeping watch for one for under $15 on Ebay), so I'm not that familiar with its contents. I've looked at the TOC on Amazon.com, though.
But I'll let you know if I find something that needs coverage that I don't think you've covered.
|
|
|
|
|
|
Why does your name sound sooo familiar???
/\ |_ E X E GG
|
|
|
|
|
|
|
|
Tom,
I just read your reply, however I have not received a notification yet via email that a reply was posted. I'll keep watching in case it just hasn't passed through all the wires yet.
-Nick Parker
DeveloperNotes.com
|
|
|
|
|
Do we get a free copy for responding
|
|
|
|
|
As many people feel that authors don't cover enough of the issues that need to be addressed, I thought I'd give people here a chance to make sure that the topics of their interest are included in the book.
And what better place to offer that chance than on a site where people come when they can't find answers in current books
Cheers,
Tom Archer
Never be afraid to try something new. Remember that a lone amateur built the Ark. A large group of professionals built the Titanic.
* Inside C# -Second Edition
* Visual C++.NET Bible
* Extending MFC Applications with the .NET Framework
|
|
|
|
|
You are truely an author for the people.;)
|
|
|
|
|
|
(my post from Tom's forum copied here for the benefit of Code Project users)
Tom,
I would like to see a C# book with more coverage of the following issues:
1. Performance. For example, an expansion of the stuff in Jan Gray's article (http://msdn.microsoft.com/library/?url=/library/en-us/dndotnet/html/fastmanagedcode.asp) would be excellent! Also have a look at the topics in the dotnet framework performance newsgroup and hit on some of those.
2. Threading and async delegate calls, in depth! Top to bottom, beginning to end, easy to hard.
3. I'm waiting on the equivalent of Scott Myers's "Effective C++" books for C#, so the more such tips you can include, the better!
4. As a continuation of #3, I'd like to see a bit about lazy evaluation in C#. For example, I often use a property that creates the object on demand, and I'd like to find more similar tricks.
5. More on code generation.
6. More on how the C# compiler works.
7. LOTS on generics! This will be exciting.
I'm looking forward to your book and the new laguage features!
|
|
|
|
|
This is probably a dumb question, but I'm trying to figure out how to add a row to an SQL table using C# -- without having to create a messy INSERT command.
For example, in ASP/JScript I can do something like this:
con = Server.CreateObject( "ADODB.Connection" );
con.Open( "CONNECT_STRING" );
rs = Server.CreateObject( "ADODB.Recordset" );
rs.CursorLocation = adUseClient;
rs.Open( "TABLE_NAME", con, adOpenKeyset, adLockOptimistic, adCmdTable );
rs.AddNew();
rs( "COLUMN_NAME" ) = COLUMN_VALUE;
rs( "COLUMN_NAME" ) = COLUMN_VALUE;
... etc ...
rs.Update();
rs.Close();
con.Close(); In C++, using these ADO classes[^], I can do something like this:
CADODatabase db;
if( db.Open( "CONNECT_STRING" )
{
CADORecordSet rs( &db );
if( rs.Open( "TABLE_NAME", CADORecordSet::openTable ) )
{
rs.AddNew();
rs.SetFieldValue( "COLUMN_NAME", COLUMN_VALUE );
rs.SetFieldValue( "COLUMN_NAME", COLUMN_VALUE );
... etc ...
rs.Update();
rs.Close();
}
db.Close();
} I'm trying to learn how to do this in C#, and I've got this so far (okay, not much):
SqlConnection sql = new SqlConnection( "CONNECT_STRING" );
SqlCommand cmd = new SqlCommand( "COMMAND", sql );
cmd.ExecuteNonQuery(); I assume this would work, but as mentioned, I don't want to be burdened with creating a huge complicated INSERT command or escaping the ' character in fields. I'd rather just set the individual fields to some sort of object (like I've done with ADO Recordset in the past) and then use that to add a row to the table.
Can anyone point me in the right direction? Any idea what classes I need to use to do this? Or a rough overview of the procedure?
|
|
|
|
|
You're not using the SQL statements correctly in .NET if you think INSERTs (or any other command) is hard. Take a look at the documentation for SqlParameter and SqlCommand.Parameters . You don't have to worry about properly escaping param values and can work with input, output, and return params with no problem:
SqlConnection conn = new SqlConnection(connectionString);
try
{
SqlCommand cmd = conn.CreateCommand();
cmd.CommandText = "INSERT INTO MyTable (ID, Name, Birthday) " +
"VALUES(@ID, @Name, @Birthday)";
cmd.Parameters.Add("@ID", SqlDbType.Int);
cmd.Parameters.Add("@Name", SqlDbType.NVarChar, 40);
cmd.Parameters.Add("@Birthday", SqlDbType.DateTime);
string[] names = new string[] {"Dad", "Mom", "Brother"};
conn.Open();
for (int i=0; i<names.Length; i++)
{
cmd.Parameters["@ID"].Value = i;
cmd.Parameters["@Name"].Value = names[i];
cmd.Parameters["@Birthday"].Value = DateTime.Now.AddYears(i * -10);
cmd.ExecuteNonQuery();
}
}
finally
{
if (conn != null) conn.Close();
} This is just an example to show you the power of parameterized statements. The same is done with SqlCommand s when using the SqlDataAdapter .
The other way is to create a DataSet , build the schema (or create a strongly-typed DataSet using VS.NET's DataSet designer (or other data designers, like dragging and dropping a table from the connections tab), or the xsd.exe utility), and add rows to that, which you then call SqlDataAdapter.Update , but you'll still need parameterized queries.
This is how ADO.NET works and - if you architect your solution right - can be much better than the old ADO way (for example, DataSet s are very good at tracking changes, dealing with relationships, and even identity columns).
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Thank you! That is exactly what I wanted to know.
|
|
|
|
|
I have a working printtemplate but css print formating isn't working.
I have a CSS style page-break-after: always; set for div. When i open the page in IE and go to print preview the css styles work right. Using my print template the pagebreak setting doesn't work. How do i force IE to process CSS properly?
|
|
|
|
|
You can't force IE to do anything. You must work within the constraints of the software. That said, remember that print templates wrap the body of a document to be printed. Depending on how you scope the styles in your CSS document. The best way is to examine the HTML that is generated and see why the style isn't being used. If you're setting this for element hierarchies, remember that those might not be valid after inserting the body content between other elements in your print template.
Also, are you specifying page-breaks only for the print @media? If so, make sure that in your <IE:DEVICERECT> you specify MEDIA="print" , otherwise it will default to the screen styles.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
I am developing a user control and I want the ability to resize the control outside the borders of its parent (could be another control or a form). An example of this is the dropdown list on a combo box. Just setting the parent of the control to be the form doesn't handle the case where the control wants to go off the form.
What is the best way to do this?
Gary Kirkham
A working Program is one that has only unobserved bugs
I thought I wanted a career, turns out I just wanted paychecks
|
|
|
|
|
You have to place your control in a toplevel window - since you want to have this go beyond the form.
First thing you will need to do is make a class "TopLevelWindow" derive it from "Form". You have to set the appropriate styles you want, so that it doesn't show in taskbar and doesn't have any borders. You then use the windows api SetWindowPos(...) to position the window. From there its fairly easy. You just have to include what ever you need in the popup window. Create a popup manager class that takes a control and puts it into the toplevelwindow.
|
|
|
|
|
Apologies if the title of this thread is a little vague.
Let me explain a little further, lets assume that I have the following simple class :
public class MyClass
{
public int x;
public MyClass(int x)
{
this.x = x
}
}
Now elsewhere in code, I create multiple instances of this class :
MyClass mc1 = new MyClass(16);
MyClass mc2 = new MyClass(11);
MyClass mc3 = new MyClass(73);
What I would like to be able to do is add all the values in the current objects of a class to get a total. Forexample :
int ClassTotal = myClass.GetTotals();
Which in this example would return 100 (i.e. 16 + 11 + 73)
This also needs to be smart enough to handle the fact that an object may have been disposed, so if I was to dispose the object mc3, GetTotals would return 27
post.mode = signature;
SELECT everything FROM everywhere WHERE something = something_else;
> 1 Row Returned
> 42
|
|
|
|
|
create a static variable "ClassTotal" in your class.
add the code to add the value of the new instance of the class to the ClassTotal in the constructor and add the code to subtract the value of the desposed instance in the destructor.
|
|
|
|
|
Hi,
I've got a problem, calling via remoting, a COM+ which activation is type library. I configure the client application and the web.config file, then I make the call, and that's ok. The problem appears because my COM+ application has to read information from a configuration file. My first attempt to solve this, was to introduce this information in the web.config file, but it doesn't work. The fact is that the configuration file which it's been read is aspnet_wp.exe.config, instead web.config.
I am creating the COM+ through a wrapper. When I call the wrapper, it is executed in one AppDomain, but when the wrapper creates the instance of the component, the AppDomain is changed to the Default AppDomain, changing also the configuration file used.
I hope to give enough information (and understable!!!;P) If you need further information, please, don't hesitate asking me.
Thanks,
Ivan.
Iván Fernández
|
|
|
|