|
At least I'm pretty sure there isn't a sql problem, the stored procedure works fine in query analyzer, but when I attempt to use it in my program it throws a SqlException:
Line 1: Incorrect syntax near 'NIDB_NIDBArticle_Search'.
Here is the SP:
<br />
CREATE PROCEDURE dbo.NIDB_NIDBArticle_Search<br />
(<br />
@term varchar(100)<br />
)<br />
AS<br />
SELECT<br />
a.article_id AS [ID],<br />
a.main_entry AS MainEntry,<br />
auth.last_name + ', ' + auth.first_name AS Author,<br />
ed.last_name + ', ' + ed.first_name AS Editor,<br />
a.assigned_word_count AS AssignedWordCount,<br />
s.status AS CurrentStatus <br />
FROM<br />
ARTICLE a<br />
JOIN [USER] auth ON a.author_id = auth.user_id<br />
JOIN [USER] ed ON a.editor_id = ed.user_id<br />
JOIN ASSIGNMENT m ON a.article_id = m.article_id<br />
JOIN LK_STATUS s ON m.status_id = s.status_id<br />
WHERE<br />
a.main_entry LIKE '%' + @term + '%'<br />
And here is the method, throws the exception when it attempts to fill the DataTable
<br />
public static DataTable Search(string term)<br />
{<br />
SqlCommand cmd = new SqlCommand("NIDB_NIDBArticle_Search", conn);<br />
SqlParameter parm = new SqlParameter("@parm", SqlDbType.VarChar);<br />
parm.Value = term;<br />
cmd.Parameters.Add(parm);<br />
SqlDataAdapter ad = new SqlDataAdapter();<br />
ad.SelectCommand = cmd;<br />
DataTable dt = new DataTable();<br />
ad.Fill(dt);<br />
conn.Close();<br />
<br />
return dt;<br />
}<br />
Any suggestions? I usually use Enterprise Library but for some reason I kept getting an infinite loop when I try to use it in this Windows form.
|
|
|
|
|
Set the CommandType property of the command to CommandType.StoredProcedure.
---
b { font-weight: normal; }
|
|
|
|
|
Yes that fixed... I feel foolish because I was thinking about that before I was finished then got distracted. When I came back it never poped back in my head.
|
|
|
|
|
i am using WMEncoder 9 sdk to encode a video from a camera, now i want to detect a voice on the screen so that i can know sound is recording or not, GetAudioLevel method is given in sdk but not implemented, is there work around anyone know.
Shajeel
|
|
|
|
|
Hi
Can anyone offer any advice on how to achieve on demand/paged population on tree controls for performance. How is this usually done in .NET?
Thanks in advance...
|
|
|
|
|
You add a "dummy" child node for every node whose real children have yet to be loaded. When a node is expanded you check if it has a dummy node, and if it does, remove the dummy node and add the real child nodes. The dummy node might have Text of "*" or some value which is meaningless in the context of your application.
The "advanced demo" in the sample app for my TreeViewWalker article uses load-on-demand: http://www.codeproject.com/cs/miscctrl/TreeViewWalker.asp[^]
Josh
|
|
|
|
|
private void DeactivateControls(ControlCollection ctl)<br />
{<br />
<br />
foreach (Control ctrl in ctl)<br />
{<br />
if (ctrl is MyTextBox)<br />
((MyTextBox)(ctrl)).EnabledSpecial = false;<br />
<br />
else<br />
(ctrl).Enabled = false;<br />
<br />
if (ctrl.HasChildren)<br />
DeactivateControls(ctrl.Controls);<br />
}<br />
}
MyTextBox.EnabledSpecial is still true after I try to set it to false in this method. What do I do wrong?
-- modified at 8:20 Friday 7th April, 2006
|
|
|
|
|
That depends on what the property EnableSpecial does. Without seeing that code, who knows what is going on?
"On two occasions, I have been asked [by members of Parliament], 'Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out?' I am not able to rightly apprehend the kind of confusion of ideas that could provoke such a question."
--Charles Babbage (1791-1871)
My: Website | Blog
|
|
|
|
|
I didnt show the enabledSpecial since I know that's not where the problem lies, it works in many other places.
|
|
|
|
|
If you know that that's not where the problem lies, and there's nothing wrong with the code you posted (except overuse of brackets), and you're sure there's a MyTextBox in the control tree, and you're sure you're calling the method, then obviously your code must work. So there's no problem.
using System.Beer;
|
|
|
|
|
well, all that is right except the no problem part =)
|
|
|
|
|
Do you call the method? How? Does the control that you want to change exist under the control collection you send to the method?
---
b { font-weight: normal; }
|
|
|
|
|
this is how I call;
protected override void OnEnabledChanged(System.EventArgs e)<br />
{<br />
if(this.Enabled)<br />
{<br />
this.Enabled = true;<br />
ActivateControls(this.Controls);<br />
}<br />
else<br />
{<br />
this.Enabled = true;<br />
DeactivateControls(this.Controls); <br />
}
and yes, it exists. Ive debugged my way in there, and everything looks right except enabledspecial is still true after the setting to false.
|
|
|
|
|
Here's your problem. If you'd have debugged, you'd have spotted your OnEnabledChanged event getting fired twice when you disable the control.
picture when that event is called, and the control just got disable. therefore this.Enabled == false
Your else clause fires. So you reenable the control. This will cause your event to fire again, but this time you'll be activating the controls.
using System.Beer;
|
|
|
|
|
thanks for your response, you seem to be on to something.
|
|
|
|
|
In addition to what the other posters said, you are casting your object 2x, first by checking the type using the 'is' keyword, then casting it to that type. A better, more efficient way is to use the 'as' operator:
MyTextBox controlAsTextBox = ctrl as MyTextBox;
if(controlAsTextBox != null)
{
....
}
Tech, life, family, faith: Give me a visit.
I'm currently blogging about: How 'bout a little guitar now?
The apostle Paul, modernly speaking: Epistles of Paul
Judah Himango
|
|
|
|
|
The user has many reports done in MS Word. The secretaries type the reports and then the managers have to read the reports and either approve them or refer them back for correction. After approval they need to be printed.
My initial idea is to do a windows application using C# and SQL Server. In the database I store the path to the report documents and this also allows me to add a column to this database table holding a flag, which will indicate whether the document needs to be corrected, has been approved, or can be printed. In that way when the application is started and the list of documents are displayed in ListView (for example) the user can see at first glance which documents are ready for printing, etc. The user can then also select which documents to list (i.e. the approved ones, the ones for printing, or the ones in the archive).
I have managed to write code that will open a document by opening MS Word from within the C# application. However that opens the document external to the C# application and this does not allow me to be able to set a flag once I have read/edited the document and closed MS Word. What I would like to do is open the word document onto my windows form (without losing the formatting) in some way and be able to edit it or even create a new one and still save it as a .doc document. Then once it was saved for example an option pops up whereby the document can be flagged as “Approved”, etc.
Is it possible doing it the way I have thought? Can you direct me to examples of how to get the document opened within the C# form? Any better ideas or suggestions will also be greatly appreciated.
Thanks.
Kobus
|
|
|
|
|
i didn't read what this control can do but perhaps it helps...
http://www.codeproject.com/cs/miscctrl/winwordcontrol.asp
|
|
|
|
|
public static StringBuilder ParseMultipleSelections(string parameterString)
{
CurrentDelimValues = searchParams[parameterString].ToString().Split('~');
}
// searchParams is a Hashtable
// I want to pass the string I'm looking for
// in the Hashtable so that
// the variable: parameterString
// is converted to the string
Much Thanks...
|
|
|
|
|
Did you post this only as information, or do you have a question also?
If you don't make
a line break every
other word, it's
much easier to
read what you
write.
What is it that you want to convert, and how?
---
b { font-weight: normal; }
|
|
|
|
|
To get the value in a Hashtable you use a string: Hashtable["myString"].ToString().
I want to be able to change "myString" to a variable so that I can create a method where "myString" can change based on the variable being passed.
Thanks again.
|
|
|
|
|
Yes, that is what you did in the code that you showed. Is there a problem with this?
---
b { font-weight: normal; }
|
|
|
|
|
I'll have to retest. I'm pretty sure I got an error. Since I'm up against a deadline, I just figured out a different way of accomplishing the same thing.
Thanks for your help.
|
|
|
|
|
Hi All,
Given:-
class A
{
}
class DerivedFromA : A
{
}
If i have an instance of A, but i want to "upgrade it" to be a DerivedFromA, is there any way to do that? C# doesn't seem to allow conversion operators between derived types. The only other way I can see to do it is to have a method in DerivedFromA like this:-
public static DerivedFromA(A theInstance)
{}
which could then do the conversion. But that gives me access issues - i can't copy protected members from A to the new DerivedFromA instance.
Any ideas?
thanks
Jon
using System.Beer;
|
|
|
|
|
No, you can't cast an object to a class the inherits from the class of the object. You can only cast an object to any of it's base classes.
Jon Hulatt wrote: i can't copy protected members from A to the new DerivedFromA instance.
Yes, you can. You can access any protected members from the derived class. That is exactly what the protected keyword does, it allows access only from members of the class and from members of any derived classes.
---
b { font-weight: normal; }
|
|
|
|