|
That's JavaScript and this is a C# forum.
This space for rent
|
|
|
|
|
- This is nothing to do with C#;
- You're including both
jquery.Jcrop.js and jquery.Jcrop.min.js - you only need one of those; - You can't use app-relative paths (
~/... ) in a <script> tag;
If you're using WebForms:
<script src="<%= ResolveUrl("~/Scripts/jquery-1.10.2.min.js") %>"></script>
<script src="<%= ResolveUrl("~/Scripts/jquery.Jcrop.min.js") %>"></script>
<link href="<%= ResolveUrl("~/Content/jquery.Jcrop.min.css") %>" rel="stylesheet" />
If you're using MVC:
<script src="@Url.Content("~/Scripts/jquery-1.10.2.min.js")"></script>
<script src="@Url.Content("~/Scripts/jquery.Jcrop.min.js")"></script>
<link href="@Url.Content("~/Content/jquery.Jcrop.min.css")" rel="stylesheet" />
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
|
|
here is my table sql :
user----------term
John..........diligent
Jane..........new
I have a variable : termUser
and I find easily its value by Sql request when the user is saved it in the mysql table and this user see his term on the screen by (due to) the variable : termUser.
I try it by 2 way ( by if condition) and those way are correct results
string termUser = String.Empty;
string catchTerm = String.Empty;
while (dataMySqlReader.Read())
{
catchTerm = (string)dataMySqlReader["user"];
if (catchTerm != null)
{
termUser = (string)dataMySqlReader["term"];
}
else
{
termUser = "callow";
}
if (String.IsNullOrEmpty(catchTerm))
{
termUser = "callow";
}
else
{
termUser = (string)dataMySqlReader["term"];
}
}
If the user is not in the mysql table, I think that SQL return 'NULL', so in this case, I want to affect this variable (termUser) by 'callow' : It's only for to display on his monitor.
But my code can not affect my variable.
I changed also my condition but I have not success by this :
if (String.IsNullOrEmpty(catchTerm))
<pre>
if (string.IsNullOrEmpty(catchTerm) == true)
</pre>
how I can affect my variable termUser by 'callow when the user is not in my table ?
Thanks
|
|
|
|
|
A "null" value in a database is not the same an empty string; you might want to compare to <a href="https://msdn.microsoft.com/nl-nl/library/system.dbnull.value%28v=vs.110%29.aspx">DBNull.Value</a>[<a href="https://msdn.microsoft.com/nl-nl/library/system.dbnull.value%28v=vs.110%29.aspx" target="_blank" title="New Window">^</a>] .
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Eddy Vluggen wrote: A "null" value in a database is not the same an empty string You haven't ever worked with an Oracle DB, have you? 
|
|
|
|
|
Aw, I did, but it has been a while since Oracle 7 and selecting from 'dual'
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
I believe this works in Oracle too?
If issues, please explain, you made me curious...
|
|
|
|
|
Well, look at it from a different perspective. Imagine a questionnaire. Someone left a free-text field empty. Does that translate to a null value or string.Empty ? Hence an empty string and a null string are the same in an Oracle database. If there's a "not null" constraint on the text field, you cannot insert an empty string either.
At first, I thought that's a WTF. But now I think they got it right.
|
|
|
|
|
As Eddy Vluggen mentioned:
if(dataMySqlReader["user"] != DBNull.Value){
}
else{
}
hope this helps.
modified 1-Jun-16 7:32am.
|
|
|
|
|
Won't that produce an InvalidCastException if the field is null?
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Oops, my copy/paste error ...
I'll fix that...
|
|
|
|
|
Thanks but it does not work
|
|
|
|
|
What does "not work" mean exactly?
Did it throw an error? If yes, what was the message?
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
my variable can not affected
|
|
|
|
|
Show us some updated code, maybe we could talk about it
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
What's the error ?
Why doesn't it work?
|
|
|
|
|
But this version works !
it is very strange
string termUser = String.Empty;
termUser = "callow";
string catchTerm = String.Empty;
while (dataMySqlReader.Read())
{
catchTerm = (string)dataMySqlReader["user"];
if (catchTerm != null)
{
termUser = (string)dataMySqlReader["term"];
}
}
|
|
|
|
|
if dataMySqlReader["user"] is null this thing will crash I think...
Note that I updated my previous answer by removing the string cast (that was a copy/paste error)...
also this:
string termUser = String.Empty;
termUser = "callow";
is useless, use:
string termUser = "callow";
|
|
|
|
|
but
My variable [termUser] is affected by "callow" with this code :
it is very strange
string termUser = String.Empty;
termUser = "callow";
string catchTerm = String.Empty;
while (dataMySqlReader.Read())
{
catchTerm = (string)dataMySqlReader["user"];
if (catchTerm != null)
{
termUser = (string)dataMySqlReader["term"];
}
}
|
|
|
|
|
Just an observation:
Unless the SQL query returns exactly one record, the while loop will end up setting catchTerm to the "user" column from the last record returned, and termUser will be the "term" column from the last record where "user" isn't null (or empty).
Is there a reason that the "user" column can't be checked as part of the SQL query?
"Fairy tales do not tell children the dragons exist. Children already know that dragons exist. Fairy tales tell children the dragons can be killed."
- G.K. Chesterton
|
|
|
|
|
I think if the record does not exist, C # does not fit into the while loop
|
|
|
|
|
Yes, but if the SQL query returns more than one record, then the effects I mentioned will happen.
If the SQL query is structured to return only a single record (or none), then there's no issue.
"Fairy tales do not tell children the dragons exist. Children already know that dragons exist. Fairy tales tell children the dragons can be killed."
- G.K. Chesterton
|
|
|
|
|
Suppose I have a hotel app where users can check to see if there is any vacant rooms in my hotel.
The vacancy status changes as old customers checkout and new ones checkin.
Does this situation require the Observer Design Pattern? Also if this is a WCF REST app, how do I simulate multiple people using this app?
modified 31-May-16 12:19pm.
|
|
|
|