|
roebuck-code wrote: be in url
What URL?
As Keith has pointed out you should never accept unvalidated input to your Sql statements. Use stored procedures or at least a parameterized query.
If you want to return the command text that was executed, though I can't see why you would, then use SqlCommand.CommandText
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
Mark Nischalke wrote: What URL?
after executing this method,open a page that show me this answer:
<?xml version="1.0" encoding="utf-8" ?>
<string xmlns="http://tempuri.org/">insert into FX_Forecast2 (Symbol,DateTime) values( '4',56/8/8)</string>
in page's url has been written method name.
i want after it be parameters and values.
|
|
|
|
|
|
Manfred R. Bihy wrote: This will work if the parameter names of the function match those of the exposed web service method.
The parameters are appended like any other URL parameters by separating them with a "?"
should i pass parameters in url with coding or these have been passed after executing method?
|
|
|
|
|
roebuck-code wrote: should i pass parameters in url with coding
Yes, you should pass the parameteters in URL and they have to be encoded according to the rules of URL encoding.
roebuck-code wrote: or these have been passed after executing method
You'll have to do some explaining of what that means, as my feeble mind was unable to grasp what you were trying to say.
Cheers!
|
|
|
|
|
Manfred R. Bihy wrote: Yes, you should pass the parameteters in URL and they have to be encoded according to the rules of URL encoding.
what code i should write for passing parameters in url?
Manfred R. Bihy wrote: roebuck-code wrote:
or these have been passed after executing method
You'll have to do some explaining of what that means, as my feeble mind was unable to grasp what you were trying to say.
i thought that parameteres pass in url without my coding.
|
|
|
|
|
Please elaborate on from where you intend to call the webservice method. Write a minimal HTML document that illustrates the basic idea. Like posting the data from a form or calling the url from AJAX. The way this question started out there just isn't enough information to give you any appropriate help.
Regards,
|
|
|
|
|
i have a page in a web service:'default.asmx'
in default.cs(in App_Code) is a web method:
[WebMethod]
public string zakhire(string s,string d)
{
string sql = " insert into FX_Forecast2 (Symbol,A) values( '"+s+"','"+d+"')";
OpenDb();
cmd = new SqlCommand(sql, con);
cmd.ExecuteNonQuery();
con.Close();
return sql;
}
type of fields 'Symbol,A' are nvarchar..
now without knowing about a software that send data to webservice,i run this page in visual studio that test this page.
after running this page and executing the method with my arrival data and press 'invoke' button,a page open and in it's url just is method name:
http:
but i need to parameters and values too.like this:
http:
i had seen in a book that has been written in vb language in visual studio that after executing the method and opening a page,arrival parameters and values been in url with method name.
i hope that explain my need clearly.
totally i have a script in mql language in another software that run this url:
http:
i want to insert this parameters('s' and 'd')in database.
so i build a webservice and wrote in .asmx page that code.
do i think right?
modified on Saturday, January 8, 2011 7:46 AM
|
|
|
|
|
I found the answer:
with Going to web.config and adding this code in system.web section:
<webServices>
<protocols>
<add name="HttpGet"/>
<add name="HttpPost"/>
</protocols>
</webServices>
good luck.
|
|
|
|
|
Try to read string from the registry - i get beck null all the time
Code:
public static string ReadStringFromRegistry( string hive, string key )
{
string strRetVal = null;
try
{
using( RegistryKey regKey = Registry.LocalMachine.OpenSubKey( hive ) )
{
if( null != regKey )
{
strRetVal = regKey.GetValue( key ) as string;
if( String.IsNullOrEmpty( strRetVal ) )
{
strRetVal = null;
Debug.Assert( false, "fail to read from the registry" );
}
}
}
}
catch( Exception e )
{
}
return strRetVal;
}
|
|
|
|
|
Your code is working fine for me, so there is nothing wrong with it. You probably have wrong input strings. Please check if "hive" and "key" are correct.
|
|
|
|
|
Thanks,
In the line
strRetVal = regKey.GetValue( key ) as string;
i get strRetVal as null.
|
|
|
|
|
So, what is the value that you expect to read? And of which type is it?
|
|
|
|
|
I read simple string that i created.
If i try to read some other string ( that i did not created ) from the next hive - i see that the result are ok.
Very Strange...
P.S: using win7 - and i check the premmision of the registry access.
|
|
|
|
|
Have you checked in the registry editor if your created string is somehow different from the one you are able to read? (is it of type REG_SZ?) I just tested creating one key and then read it back and it worked fine with XP.
|
|
|
|
|
|
when you swallow exceptions like you do, you deserve the trouble you're getting.
|
|
|
|
|
Dear All,
I am trying to log the methods using Aspect oriented progamming ( AOP) and custom attributes.
Use a class derived from ContextBoundObject with a custom attribute. IMessageSink and IContextProperty are aslo implemented to catch the sink messages. This sample worked fine.
But the problem is the this custom attributes work on class level only( i have already tried AttributeTargets.Method). So all methods will be logged. but i want only selected method by giving the attribute on methods.
Thanks
|
|
|
|
|
i am using below code to extract the files inside the zip folder.
getting an error while using copyHere method ..
after deleteing the folder i m trying to create a new one . and then copying from the zip file
but still it gives an error "File exist"
Please provide a solution thanks in advance
if (Directory.Exists(unzipFilePath))
{
Directory.Delete(unzipFilePath, true);
Directory.CreateDirectory(unzipFilePath);
}
else
{
Directory.CreateDirectory(unzipFilePath);
}
Shell objShell = new Shell();
Folder shellZipFile = objShell.NameSpace(zipFilePath);
Folder shellUnZipFile = objShell.NameSpace(uzipFilePath);
foreach (FolderItem zipFileitem in shellZipFile.Items())
{
shellUnZipFile.CopyHere(zipFileitem, 0);
}
This error is happening in a particular system
|
|
|
|
|
It seems a little confusing even looking at the MSDN documentation: http://msdn.microsoft.com/en-us/library/aa328748(v=VS.71).aspx[^] which says that true will delete files and subdirectories. However, when you look at the example on the same page it says:
'This operation will not be allowed because there are subdirectories.
for the VB example, and
for the C#.
I suggest you write a quick-and-dirty tester to check if the directory deleted exists after the delete, and if so what it contains. I suspect that the VB example may be correct, and you will have to manually delete files and subdirectories.
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.
|
|
|
|
|
Thanks for the reply
phiscally i checked the folder it was wmpty
and then i inserted below code in copy..
if (File.Exists(String.Format(@"{0}\{1}",unzipFolderName,zipFileitem.Name)))
{
File.Delete(String.Format(@"{0}\{1}",unzipFolderName, zipFileitem.Name));
}
shellUnZipFile.CopyHere(zipFileitem, 0);
|
|
|
|
|
Don't check using Explorer - check if it still exists after the delete in your code, and before you do anything else. (Remember that windows can have invisible files, and hidden files which won't show up in Explorer).
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.
|
|
|
|
|
I had checked through code, explorer by making files visible and all those stuff..
and one more thing in this specific computer.i tried something manually..
like i right clicked the zip file and selected explore. i got an option to
copy the file But when i paste it paste is not happening.
|
|
|
|
|
Have you checked the folder permissions?
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.
|
|
|
|
|
Yes i checkd.. normal settings
|
|
|
|