|
he want to use MSSQL, not MySQL,
Glad to discuss with you and best wishes.
|
|
|
|
|
oops. I read it as MySQL. My bad
|
|
|
|
|
|
Hi there i am a little stuck and need some assistance
The gist is i am calling a stored procedure from my executable, it takes to parameters FileName and FileType and returns an error/success code.
Based upon that error code i need to do some work.
In esscence this is the form i want
EXEC @Return_Code = the_StoredProcedureToCall ‘C:\\File.csv’, ‘FileType’
where @Return_Code = return status code
Within my C# i have the following.
private int callStoredProc(string fullPath, string type)
{
string connectionString = System.Configuration.ConfigurationManager.AppSettings["ConnectionString"];
string strRowAffect;
SqlConnection con = new SqlConnection(connectionString);
try
{
con.Open();
}
catch (Exception e)
{
this.lstEventsOccurred.Items.Add("ERROR: Database Connection could not be established in callStoredProc(): " + fullPath);
this.lstEventsOccurred.Items.Add("Exception Produced: " + e.Message.ToString());
return -1;
}
SqlCommand command = new SqlCommand("the_StoredProcedureToCall", con);
command.CommandType = CommandType.StoredProcedure;
SqlParameter retVal = command.Parameters.Add("@Return_Code", SqlDbType.Int);
retVal.Direction = ParameterDirection.ReturnValue;
SqlParameter inputFileName = command.Parameters.Add("@InputFilePathName", SqlDbType.VarChar, 120);
inputFileName.Direction = ParameterDirection.Input;
inputFileName.Value = fullPath;
SqlParameter fileType = command.Parameters.Add("@FileType", SqlDbType.VarChar, 120);
fileType.Direction = ParameterDirection.Input;
fileType.Value = type;
this.lstEventsOccurred.Items.Add("Calling:" + command.ExecuteNonQuery().ToString());
strRowAffect = command.ExecuteNonQuery().ToString();
con.Close();
return (int)retVal.Value;
}
Something is incorrect and having the darndest time figuring it out.
Thanks in advance
|
|
|
|
|
First of all why are you returning -1 if there is no sql server available. Will your application work with no database?
Doesn't the return value have to be "@return_value" or something like that? Is that your issue?
Also, it you want to code this correctly try coding with "using" blocks. Using (conn = new sqlconnection()) etc...
Good luck.
I didn't get any requirements for the signature
|
|
|
|
|
the -1 is just an intercept if i cannot create a connection.
the return code from the stored proc will be a distinct value and never a -1 thus the -1 for the connection.
Can I use the ExecuteNonQuery() - Since i am only interested in the return code supplied.
Also it is my understanding the params need to be in a distinct order and defined?
I have changed the code around a little to...
For brevity i left the connection part out. Also i am 100% confimred the stored proc is working.
Another wrote that, but we tested extensively prior to implementing within this section of code.
And yes, if the DB cannot be connected this is ok.
SqlCommand command = new SqlCommand("the_storedProc", con);
command.CommandType = CommandType.StoredProcedure;
SqlParameter param = new SqlParameter();
param = command.Parameters.Add(new SqlParameter("@FilePath", SqlDbType.VarChar, 120));
param.Direction = ParameterDirection.Input;
param.Value = fullPath;
param = command.Parameters.Add(new SqlParameter("@FileType", SqlDbType.VarChar, 120));
param.Direction = ParameterDirection.Input;
param.Value = type;
param = command.Parameters.Add(new SqlParameter("@Return_cd", SqlDbType.Int, 8));
param.Direction = ParameterDirection.Output;
command.ExecuteNonQuery();
|
|
|
|
|
never mind i resolved the issue.
|
|
|
|
|
I have a little issue with the datasets in Visual Studio 2008. I am trying to do some reporting. I have created my datasets and they are linked to the Application Settings for the connection string to the SQL Server.
Well the problem is that I built my application to store that information in the registry. So it gets and sets the COnnection String in the Windows Registry.
So how do I specify those datasets to read from registry, or not even that, just get the information for the connection string from my RegistryAccess class I created? Which gets the connectionstring and returns the string?
|
|
|
|
|
Jacob D Dixon wrote: So it gets and sets the COnnection String in the Windows Registry
The most common place to store connection string information is in the config file, even has a special section for it, connectionStrings
Jacob D Dixon wrote: So how do I specify those datasets to read from registry
You don't specify this in the DataSet. DataSet is just the result from some other operation
only two letters away from being an asset
|
|
|
|
|
I'd like to extract a specific data from an HTML web page. I have created an XPath expression to do it for me.
The problem is that the HTML page is corrupted and the XmlDocument throws XmlException at me. How to make it working like a browser: ignore errors and continue loading? A free html cleaning lib might help, but I couldn't find anything useful.
Any help appreciated.
Greetings - Gajatko
Portable.NET is part of DotGNU, a project to build a complete Free Software replacement for .NET - a system that truly belongs to the developers.
|
|
|
|
|
|
Thanks for answering my post.
I tried both Tidy .NET and Tidy COM but they didn't satisfy me. I prefer Html Agility Pack suggested by Bruce.
Greetings - Gajatko
Portable.NET is part of DotGNU, a project to build a complete Free Software replacement for .NET - a system that truly belongs to the developers.
|
|
|
|
|
You might try using the HTML Agility Pack[^].
It's worked reasonably well for me in the past.
"Walking on water and developing software from a specification are easy if both are frozen." - Edward V. Berard
|
|
|
|
|
Thank you. It works fine.
I have another question.
Well, I want to make a simple word translator using an existing online dictionary (for my home use). The dictionary's homepage is http://www2.ling.pl[^]. The home page can be read successfuly.
However, ling.pl has a nice feature: you can access the dictionary by typing a word after "/". For example http://www2.ling.pl/do[^] would naviagate straight to the "do" word definition. Unfortuantely,
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
throws 404 error. Any ideas how to fix that?
Greetings - Gajatko
Portable.NET is part of DotGNU, a project to build a complete Free Software replacement for .NET - a system that truly belongs to the developers.
|
|
|
|
|
hi
How can I call delegate
such As
private void button1_Click(object sender, EventArgs e)
I want to call button click delegate from another method
how can I do that
and thanks
|
|
|
|
|
Actually that's a method you would call so for example:
button1_Click(this, new System.EventArgs());
However, often the need to call button click from code is a symptom from a design issue.
It would be better if you create a new method and place the logic needed in that method. Button click only calls this method as does your code whenever that logic is needed. This method can be placed in the form itself or to a separate controller class.
|
|
|
|
|
thank you soooooooooooooo much
|
|
|
|
|
I do that to initialize forms sometimes. When controls need to be enabled/disabled based on state of one or more other controls, I call the appropriate event handler since that code does what I need.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
I've also used that in some situations and that's why I wasn't so strict about not calling event handlers. The main point I had was to give some ideas to the OP and if he still decides to call the eventhandler, then it's thoroughly thought and justified decision (as I believe it's in your case).
For some reason I nowadays write eventhandlers for UI elements (clicks, checks etc) so that there are always three lines of code:
1. mouse pointer to wait state
2. actual method call
3. mouse pointer to normal state
Don't know if it has actual benefits (well one is that mouse pointer never flickers), but at least it's coherent code to read
|
|
|
|
|
Hello All,
I am working On an Windows application which require to exit only from within it self and Not from any other External source.. it means user can not stop or kill the application Process by Task Manager. and if he wish to close the application there is only option to close from whithin application. does Any one have a Idea how to so this??
|
|
|
|
|
This is almost like your previous questions. You cannot do this and for very good reasons.
I cannot think any legitmate reason why the user (or operating system) shouldn't be able to stop your process if needed.
|
|
|
|
|
You already asked this question five times and have been given lots of answers, stop it now.
modified 12-Sep-18 21:01pm.
|
|
|
|
|
Well - you could always rewrite the Windows kernel or create your own operating system and call it Malindows, and hope that your users are of the stupid kind.
|
|
|
|
|
Actually yes, I do have an idea to do what you want. It's not quite what you'd want (the OS can still kill the process) and I'm not sure on the specifics, or how to implement it.
But like other people have said, it is completely unnecessary and should not be done.
My current favourite word is: Delicious!
-SK Genius
Game Programming articles start - here[ ^]-
|
|
|
|
|
mnssr wrote: if he wish to close the application there is only option to close from whithin application
Okay - it sounds like you might be trying to create a legitimate application.
Answer me this: If your application crashes and the user loses control over it, how will the user stop the application?
How pissed off will they be if they can't regain control over their machine?
|
|
|
|