|
anybody can write the equivalent code for the following without generic:
public class SampleClass<T, U, V> where T : V { }
thank you in advance.
IT makes life crazy!
|
|
|
|
|
No. Generics introduces a new type of programming; one which is not possible without it. You cannot express that line of code in non-generic code.
Josh
|
|
|
|
|
Thanks Josh.
That line of code is really cool with Generic, but it confuses me. Could you explain something that help me to better understand it?
Albert
IT makes life crazy!
|
|
|
|
|
torontomouse wrote: Could you explain something that help me to better understand it?
Such as?
|
|
|
|
|
First, when you post code, surround it with <pre> tags. This will preserve the formatting and distiguishing it from the rest of your text, making it easier to read.
Second, this is a C# programming forum, not a C programming forum. For questions regarding the C language, move this to the appropriate forum.
Tech, life, family, faith: Give me a visit.
I'm currently blogging about: Goof around music jam with my brothers (with video)
The apostle Paul, modernly speaking: Epistles of Paul
Judah Himango
|
|
|
|
|
I'm trying to make a mdi child window apear always in the back so any other windows to be on top ... can anyone help me?
modified 30-Nov-21 21:01pm.
|
|
|
|
|
hi,
i make a search button and bind data with textboxes, everything is fine, now i make a clear button which will remove textboxes data after when i finished search into the database using search button i use "Clear()" method for all text boxes but now when i press clear button it clears all data in the textboxes but PostalCode and Year is not unbinding the database(not refreshing/clearing). how i can prevent it. remember i'm using two different buttons. and i know the textbox1.DataBindings.Remove()method so plz give me another choice to remove binding from these two fields.
thx
m.reehanmunir
|
|
|
|
|
To remove all databindings from a control you can simply call control.DataBindings.Clear().
You might need to set the Textbox's Text to String.Empty to clear it though.
"Democracy is two wolves and a sheep voting on what to have for dinner" - Ross
Edbert
Sydney, Australia
|
|
|
|
|
<code>
Hi
Tools: C#, .NET 1.1 and Biztalk 2004
I want to execute a policy rule which gets fired based on some input xml and database facts. I am able to pass the input xml facts but how to I pass the database facts information before executing policy. Basically, by passing "Role" information, I want to get "Salary" values which are stored in a database table.
Following is the code snippet:
--------------------------------------------------------------
Input XML:
<ns0:EmpInfo xmlns:ns0="http://EmployeeInfo.EmpInfo">
<Emp>
<Salary></Salary>
<Role>Manager</Role>
</Emp>
<Emp>
<Salary></Salary>
<Role>CIO</Role>
</Emp>
</ns0:EmpInfo>
--------------------------------------------------------------
----------------------------
public string Execute(string sRequestXML, out string sResponseXML, out string sErrorMsg)
{
sResponseXML = string.Empty;
sErrorMsg = string.Empty;
DebugTrackingInterceptor dti = new DebugTrackingInterceptor(@"C:\Biztalk\projects\EmployeeInfo\XSDs\jit.txt");
//create an instance of the XML object
XmlDocument xd1 = new XmlDocument();
xd1.Load(@"C:\Biztalk\projects\EmployeeInfo\XSDs\Copy of EmpInfo_output.xml");
TypedXmlDocument doc1 = new TypedXmlDocument("EmpInfo",xd1);
// create the array of short-term facts
object[] shortTermFacts = new object[1];
shortTermFacts[0] = doc1;
Policy policy = null;
// now execute to see what happens
try
{
//Console.WriteLine("Grabbing the policy ...");
policy = new Policy("EmpInfo");
policy.Execute(shortTermFacts, dti);
FileInfo finfo = new FileInfo(@"C:\Biztalk\projects\EmployeeInfo\XSDs\ProcessedRFP.xml");
StreamWriter writer = finfo.CreateText();
writer.Write(doc1.Document.OuterXml);
writer.Close();
}
catch (Exception ex)
{
FileInfo finfoError = new FileInfo(@"C:\Biztalk\projects\EmployeeInfo\XSDs\Error.xml");
StreamWriter writerError = finfoError.CreateText();
writerError.Write(ex.Message);
writerError.Close();
}
dti.CloseTraceFile ();
policy = null;
return "PASS";
}
</code>
|
|
|
|
|
Hello,
Can anyone help me to find out a tool which will create Dump .SQL file from a SQL Express 2005 .MDF file ? I developed my projects with SQL Express 2005 in my PC and Now I want to deploy in remote Hosting where remote sql server doesn't allow remote connection so I can use any sql manager type software to transfer data.
Thanks and regards
EMRAN
|
|
|
|
|
|
My title probably doesn't quite explain my problem. I found some code for a fully editable grid. It was pointing to the Northwind database, pulling employee information. Okay, no problem. So now I am trying to update the code to fit what I need and I'm getting an error that I can't seem to fix.
Here is the ORIGINAL BindData code:
private void BindData()<br />
{<br />
ds = new DataSet();<br />
ds= SqlHelper.ExecuteDataset(this.connectionString, "dbo.GetEmployees", null);<br />
Session["ds"]=ds;<br />
dt = ds.Tables[0];<br />
Session["dt"]=dt;<br />
DataGrid1.DataSource=dt;<br />
DataGrid1.DataBind();<br />
<br />
}
This code uses a Microsoft SQLHelper.cs class.
Okay, so I created a stored proc called GetPartInfo. Basically there is a text box the user enters a part number, clicks a button and then the grid populates. Based on help from a couple of expert members from CodeProject this what I used to have...
private void BindData2()<br />
{<br />
strPartNumberInputReference = txtPartNumberInput.Text;<br />
string SQLString = "SELECT c.cost, ct.Description AS ctDescription, p.PartNumber, pt.description, dd.DrawingNumber, dd.DrawingRevision, dd.DwgPath FROM costs c INNER JOIN Parts p ON c.PartID = p.Id INNER JOIN PartTypes pt on pt.ID = p.PartTypeID LEFT JOIN DraftingData dd on dd.PartID = p.ID LEFT JOIN CostTypes ct on ct.Id = c.CostTypeId WHERE p.PartNumber = @PartID"; <br />
<br />
SqlCommand cmd = new SqlCommand();<br />
cmd.Connection = new SqlConnection(strConnectSQL);<br />
cmd.CommandText = SQLString;<br />
cmd.Parameters.Add ("@PartID", strPartNumberInputReference);<br />
SqlDataAdapter adapter = new SqlDataAdapter(cmd);<br />
adapter.Fill(ds);<br />
<br />
<br />
dgParts2.DataSource = ds;<br />
dgParts2.DataBind();<br />
txtPartNumberInput.Text = "";<br />
<br />
<br />
}
As you can see I am passing @PartID.
So in my stored procedure I have...
CREATE PROCEDURE [dbo].[GetPartInfo]<br />
@PartID int AS<br />
SELECT c.cost, ct.Description AS ctDescription, p.PartNumber, pt.description, dd.DrawingNumber, dd.DrawingRevision, dd.DwgPath<br />
FROM costs c INNER JOIN Parts p ON c.PartID = p.Id <br />
INNER JOIN PartTypes pt on pt.ID = p.PartTypeID <br />
LEFT JOIN DraftingData dd on dd.PartID = p.ID LEFT JOIN CostTypes ct on ct.Id = c.CostTypeId <br />
WHERE p.PartNumber = @PartID;<br />
GO
Still trying to pass @PartID.
When I tried changing the line...
ds= SqlHelper.ExecuteDataset(this.connectionString, "dbo.GetEmployees", null); to
ds= SqlHelper.ExecuteDataset(this.connectionString, "dbo.GetPartInfo", ("@PartID"));
I get the error that my Input string was not in correct format.
Here is the code for ExecuteDataset:
public static DataSet ExecuteDataset(string connectionString, CommandType commandType, string commandText, params SqlParameter[] commandParameters)<br />
{<br />
using (SqlConnection cn = new SqlConnection(connectionString))<br />
{<br />
cn.Open();<br />
<br />
return ExecuteDataset(cn, commandType, commandText, commandParameters);<br />
}<br />
}
I've tried a bunch of different things and I still get the error. How do I fix this?
Thanks again for all those who help me on this board. Sucks being a newbie.
|
|
|
|
|
I don't see any place where you are setting the actual value for @PartID. I'm not familar with the SqlHelper class but it seems as though you should be passing the value for PartID rather than the name of the paramater name
ds= SqlHelper.ExecuteDataset(this.connectionString, "dbo.GetPartInfo", ( txtPartNumberInput.Text));
|
|
|
|
|
Originally this is how I set @PartID
private void BindData2()<br />
{<br />
strPartNumberInputReference = txtPartNumberInput.Text;<br />
string SQLString = "SELECT c.cost, ct.Description AS ctDescription, p.PartNumber, pt.description, dd.DrawingNumber, dd.DrawingRevision, dd.DwgPath FROM costs c INNER JOIN Parts p ON c.PartID = p.Id INNER JOIN PartTypes pt on pt.ID = p.PartTypeID LEFT JOIN DraftingData dd on dd.PartID = p.ID LEFT JOIN CostTypes ct on ct.Id = c.CostTypeId WHERE p.PartNumber = @PartID"; <br />
<br />
SqlCommand cmd = new SqlCommand();<br />
cmd.Connection = new SqlConnection(strConnectSQL);<br />
cmd.CommandText = SQLString;<br />
cmd.Parameters.Add ("@PartID", strPartNumberInputReference);<br />
SqlDataAdapter adapter = new SqlDataAdapter(cmd);<br />
adapter.Fill(ds);<br />
<br />
<br />
dgParts2.DataSource = ds;<br />
dgParts2.DataBind();<br />
txtPartNumberInput.Text = "";<br />
<br />
<br />
}
I was taking the text from the textbox, and passing it that way. BTW, tried what you wrote but still got the same error.
Oh, the SQLHelper class gave this in the comments:
So I tried that changing my code to:
DataSet ds=ExecuteDataset (connString, CommandType.StoredProcedure, "GetPartID", new SqlParameter ("@PartID"));
But SqlParameter isn't recognized.
-- modified at 15:29 Wednesday 21st June, 2006
|
|
|
|
|
I suspect that this line should be modified
cmd.Parameters.Add ("@PartID", strPartNumberInputReference);
to
cmd.Parameters.Add ("@PartID",sqldbtype.Varchar);
cmd.Parameters["@PartID"].Value = strPartNumberInputReference;
Please tell if that helped
|
|
|
|
|
The saga continues.
Your post is a bit misleading. Your call to ExecuteDataset looks like this:
ds= SqlHelper.ExecuteDataset(this.connectionString, "dbo.GetPartInfo", "@PartID");
But the method signature looks like this:
public static DataSet ExecuteDataset(string connectionString, CommandType commandType, string commandText, params SqlParameter[] commandParameters)
You are not calling the method whose signature you displayed. Notice that you are not passing a CommandType value. If you were to pass CommandType.StoredProcedure, that might help. But, a more immediate error/oversight is that you are not actually passing SqlParameter objects! Your "@PartID" argument is a string, not an SqlParameter object. You need to create a new SqlParameter and pass it the "@PartID" value as it's name. Pass that object into the ExecuteDataset method.
Josh
|
|
|
|
|
Josh, thank you so much for you ongoing (!) help. I've not worked with SQLParameters before. Do you know of a good article or can you give me another push?
|
|
|
|
|
What is it that you need to know? You can create one like this:
SqlParameter param = new SqlParameter( "@PartID", partIDValue );
and then just pass it into a method like any other variable.
Josh
|
|
|
|
|
Then why does it still hate this?
private void BindData()<br />
{<br />
strPartNumberInputReference = txtSearchPart.Text;<br />
ds = new DataSet();<br />
SqlParameter param = new SqlParameter("@PartID", strPartNumberInputReference); <br />
ds=SqlHelper.ExecuteDataset(this.connectionString, "dbo.GetPartInfo", "@PartID");<br />
Session["ds"]=ds;<br />
dt = ds.Tables[0];<br />
Session["dt"]=dt;<br />
dgParts.DataSource=dt;<br />
dgParts.DataBind();<br />
txtSearchPart.Text = "";<br />
<br />
}
|
|
|
|
|
leckey wrote: Then why does it still hate this?
Because it is mean and it's father used to beat it with a baseball bat.
You aren't passing the 'param' object into the ExecuteDataset method. Creating it is one thing, using it another.
Cheers & beers,
Josh
|
|
|
|
|
Thanks again! A new problem has arisen. I get "Object must implement IConvertible." Trying to research this so I can stop bugging CodeProject...In my stored procedure I have
@PartID varchar
Is this the issue?
|
|
|
|
|
The problem is not in the stored procedure. SPs have no concept of IConvertible, that's a .NET thing. Turn on your debugger and see where the exception is thrown. It is impossible to figure out what the issue is based on just that error message alone.
Josh
|
|
|
|
|
Hi,
I'm trying to create a custom control to draw a graph in a canvas in real-time, similarly to an osciloscope. I have a main control loop that performs some calculations and updates the current point coordinates (x and y, with x corresponding to the time). I used to use Flash, but due to performance issues I decided to try out using C# (waht means I'm new to C#).
I'm already able to draw lines on my control, but I'm not able to update the canvas whenever a new point is calculated. The problem is that I don't know how to trigger the paint event. I've already registered it, but I don't know how to call it after the point is calculated.
I hope I made myself clear...
Thanks in advance,
Ze Augusto
|
|
|
|
|
Call Invalidate() on the control. That will post a request for a repaint, but if you really need an immediate repaint you should call Update() after calling Invalidate(). Note, you can also call Refresh(), which basically calls those two methods for you.
|
|
|
|
|
First, thanks for your help. I did what you suggested, and it did solve the repaint issue. Now I can see the lines been updated.
Now, the problem is that the screen is getting erased before the new point is drawn (as it would be expected from your description), but I need to keep the points already drawn and add the new point to the end of the line, forming a continuous curve. Then, when that line reaches the end (right border) of the canvas, I should send the carrier back to the begining (left border) and continue drawing, with a blank region in front of it, as if there was an eraser in front of the current point.
Thanks again!
|
|
|
|
|