Hi...
I'm trying to get a file address that i stored "manually" in an SQL server database using c#, i stored in the database the string "c:\projects\vids\simpsonslidetector.flv" and when i try to retrive, it ignores everything except "simpsonslidetector"... this is used as webservice, the webservice receives an int so it can match with a certain id in the table and when finds that id, returns the string (in this case not the whole string, in other cases with "simplier" strings it return well):
the table name on the database is 'info' and as 3 colums: id(int), name(nvarchar(100)), address(nvarchar(100))...what type of data should i use for the address?
also i have other methods that connect to the database to return a value or list of values, and goes fine, the only problem is the address string (i think the cause of not getting the result i want, is because, for some reason the reader does not receive the formatted string stored in the database ("c:\projects\vids\simpsonslidetector.flv")).
this is the code i use to retrieve the string:
[WebMethod]
public String getAddressByID(Int32 id)
{
String strReader = "";
SqlConnection conn = new SqlConnection(strCon);
conn.Open();
String readCmd = "SELECT address FROM info WHERE id = " + id.ToString();
SqlCommand cmd = new SqlCommand(readCmd, conn);
strReader = (String)cmd.ExecuteScalar();
conn.Close();
if (strReader == null)
{
return "No Result";
}
else
{
return strReader;
}
}
Loading
VulpesPosted Jun 1, 2011, 4:15 AM
Guest UserPosted Jun 1, 2011, 10:36 AM
thanks for your answers, PutchPT
Posted Jun 1, 2011, 1:01 AM
This will return the folder name where the application exe is present.
Hope this helps you.
Sam HobbsPosted May 31, 2011, 9:15 PM
Since we are supposed to "close" a thread by indicating it is answered, the thread might not even be seen by the person that can answer the additional questions. They might not look at the thread just because it is so big from the original question.
Also, keeping one question for one thread helps others to find answers.
Guest UserPosted May 31, 2011, 4:26 PM
1a- in the first time i had the information in the column with the string filename;
1b- launched the webservice, invoked the service and the result was correct
2a- and then i changed the string to filenameXPTO
2b- launched the webservice, invoked the service and guest what, the result was filena instead of filenameXPTO
3a- so i closed the server (ASP.NET Development Server) and the bowser, and cleaned the cookies and other information using CCleaner program
3b- then launched the webservice again without changing anything in the database, and the result was filenameXPTO
3c- then i did the same procedure but this changed the string to c:\projects\vids\simpsonslidetector.flv , and the return result is OK...
so, if anyone as the same problem try to clean the browsers cookies and restart the server, and test again (i was using firefox v4.0 bowser)...
Murali, thanks for your answer, and also do you know how to insert a string that as a relative path to the project itself, instead of using c:\projects\vids\simpsonslidetector.flv, using somthing like (IN HERE GOES THE FOLDER O THE PROJECT, THAT THE SYSTEM DETERMINES)\vids\simpsonslidetector.flv, so it can be teleported to any plataform...THANKS
cheers, PutchPT
Posted May 31, 2011, 12:08 AM
It is retrieving the complete path from db.
Please let me know what is the exact issue that you're facing ?