ORDER BY unit_cm DESC LIMIT 3
will actually give you the 3 records with the highest values of unit_cm
To get the smallest values use ORDER BY unit_cm ASC LIMIT 3
in the subquery.
ORDER BY unit_cm DESC LIMIT 3
will actually give you the 3 records with the highest values of unit_cm
To get the smallest values use ORDER BY unit_cm ASC LIMIT 3
in the subquery.
You might have more luck posting under the "MS SQL" forum (this is the MySQL forum).
First advice I can offer is to check your Services applet and see if the Microsoft SQL Server service is listed and running etc.
I can't see anything specifically wrong with the code you have posted. My suggestion would be to try using a StreamWriter, take a look at File.AppendText - this method opens the file once and closes it at the end, rather than open-closing for each line written. The excessive file handling operations may be causing a problem for you, and the StreamWriter will be more efficient in any case.
Also, just had the thought that the Delete of file 2 might be happening before the ReadAllText has finished handling the file. You might try removing that line to test, or adding a delay in before it.
It sounds like a file pointer still pointing to the first file, while you are trying to move it further through the second file (possibly before it is appended to the first). If you are able to post code I could probably be more specific?
You can instantiate an instance of the MS Word application via C# and programatically access all of the functions you would via the graphical interface. Your project needs to reference Microsoft.Office.Interop.Word
and you must have word installed on the machine this will run on (ie; if it will be deployed on a server, the server needs to have Word installed).
To create the application instance:
Microsoft.Office.Interop.Word.Application wordApp = new Microsoft.Office.Interop.Word.Application();
Open the template document
Microsoft.Office.Interop.Word.Document doc = wordApp.Documents.Open(filename); // there are other optional parameters here you can check out
You can then access the doc.CustomXMLParts
object, which should give you what you need.
You need to concatenate the values into the URL string of your link. This is a general example, but if you provide more context about the code you are using (such as if it is databound, produced in code behind etc.) I can give you more specific pointers.
<asp:HyperLink ID="HyperLink1" runat="server" NavigateUrl='<%= "http://mywebsite.com/site/TR?fr_id=1131&pg=entry&utm_source=" + strServerSideVariable1 + "&utm_medium=" + strServerSideVariable2 + "&utm_campaign=ABCD2015" %>'/>
the onclick
event on a standard HTML button invokes javascript, not Java. So your code is looking for a javascript function called addBook
on a javascript object called cart
.
I believe you need to have the form POST
to your servlet in order for the Java code to execute on the server. If you are using a shopping cart package, they will likely have implementation example code you could check to see how this should be called.
Can you post some code? looks like you have a object type where it expects a defined variable.
You could try casting the datasource table you are passing in as an object (it could be just a resolution issue with the constructor definition expecting an object type, even though theoretically anything is an object).
Dim datasource As New ReportDataSource("USACity_mCity", CType(DS, Object))
I realise you have probably already moved on from this, but for posterity sake...
CommandName=<%#Eval("Category")%>
you need quotes when specifying server values, which is probably the cause of the parsing error.
CommandName='<%#Eval("Category")%>'
1) Are you using Windows or Forms based authentication?
The way I have done this, is to use the Page.User to look up the username in the database, since the authentication is already taken care of you can assume is valid by the time it hits page code whether it is present in the database or not. I put this code in the masterpage, so it ran regardless of the landing page.
2) Personally, I design security around the role, and assign a user whichever roles they require. This has the benefit of being able to easily reassign roles to different users as they change or move around, without having to write new roles based on each individuals job description.
It is also possible there is a bios setting to disable the bluetooth radio. If you have upgraded to Windows Vista/7/8 it may have done things to your bios inadvertantly. I'd say it would be worth a check...
honeybee2090: As I mentioned there are several environmental factors that may cause signal interference or black spots. Depending on the geographical features of the area you wish to cover (hills, valleys, trees, buildings, powerlines etc.) you may need to install some repeaters, or have a transmitter that can provide a shaped signal designed to best cover your particular area. There are companies that specialise in this kind of setup, who will come and perform signal analysis and design a custom system for you - depending on how much you are willing to spend of course.
The other factor, which I also mentioned before, is that the transmitter in your typical laptop wifi card is not designed for long range comminication. You will need to cover your whole area with repeaters that are close enough for standard wifi card range, OR add a portable router or high-power transmitter to use with your laptop inside the coverage zone.
Hopefully this all makes sense.
@Namrta_1 you need to start a new thread to ask your question, don't hijack this one.
@Rakesh8642 That goes for you too, though I doubt you will get an answer to that question on this forum.
You need to have a high powered antenna on both ends, since each end needs to transmit as well as receive in order to have a valid connection.
There are also other factors, some environmental, that can affect the signal, such as; line of sight, weather, signal interferance.
You would probably do better (assuming you have fixed endpoints) with a parabolic antena (directional) rather than an omnidirectional.
What result are you trying to achieve? Connecting two buildings, or complete area coverage?
You'd be better off using a loop
He'd be better off using a single regex like Atli originally posted, much faster execution, less steps, and more elegant code to read.
I would just redirect SO referrals back to SO or to www.google.com. After a month or two, I think your traffic will go back up again.
You may only want to do that for the crawler bots, so you can still keep the human traffic that clicks through to your site.
Click-throughs that find the answer here rather than SO will be naturally more likely to encourage users to return to your site in the future, whereas the bots may attribute the content here to the link source site for ranking.
Of course you could also lose crawler traffic this way as well, though I imagine daniweb is crawled sufficiently often on its own.
You just need to remove the comma from line #2. JOINs don't need to be separated by commas the way a table list is.
@Rahul47
If a subquery returns more than one row it needs to be compared via IN
as =
will throw an error.
SELECT * FROM form1 f1, form2 f2
WHERE f1.k8regNo IN ( SELECT f2.form2_ID FROM form2 f2, form4 f4
WHERE f2.form2_ID IN ( SELECT f4.form2_ID FROM form4 f4, form3 f3
WHERE f4.k9regNo=f3.k9regNo));
However, subqueries are also an extremely inefficient way of doing this.
Also, re your last post, it is not poor practice not to specify the conditions of a join for readability sake (particularly if she is learning).
@sagisgirl
An updated version of my last example with all tables included:
SELECT *
FROM form1 t1
JOIN form2 t2 ON t1.k8regNo = t2.k8regNo
JOIN form4 t4 ON t2.form2_ID = t4.form2_ID
JOIN form3 t3 ON t4.k9regNo = t3.k9regNo
ORDER BY moveDt
This will return a dataset of all tables joined without filtering of any kind. Without knowing more about the data and the purpose of the query it is impossible for me to make recommendations about the types of joins to use, or other criterea (the resultant dataset may be quite large).
OK @sagisgirl
Have a read of that article I linked in my last post, its the mysql man page for proper join statements.
As an example, the query you posted could be written like this:
SELECT *
FROM form1 t1
JOIN form2 t2 ON t1.k8regNo = t2.k8regNo
-- more joins can be added here...
ORDER BY moveDt
NOTE: the type of join (INNER, LEFT, RIGHT) will affect the result set, so check what they do in the man article to decide which type you need. Or you can try them to see the difference.
You should index on any fields involved in joins. You can also have multiple indexes based on fields used in conditions (where clause) for different queries, but you should test the performance as not all indexes will prove sufficiently beneficial to warrent the overhead.
Also consider the type of join needed for the query, as this will also affect performance as well as the resultant dataset.
Review your datatypes used for columns, for instance is an int(11)
(the default integer size) necessary, or will a smallint
or unsigned
or int(6)
be adequate, char
instead of varchar
etc. where possible.
I recommend removing the CHAR
typecast, as this is a costly operation to perform during the query, and usually be done (often implicitly) cheaper post-query execution or in external code.
This is the only advice I can think of without further information such as table structures. Hope it helps.
You have set up your checkbox's as a control array, which means that $_POST['generation']
will itself be an array (not a single value) and must be iterated to find the selected value for insertion in the database. You will need some additional logic to handle this, you can't just pass the array to the SQL.
I assume you are talking about handling those exceptions? Catching exceptions is generally the same regardless of the type. This tutorial has some try-catch
code examples.
Fpdf will work without any external references, it can create the pdf document without having a reader installed. Probably your browser is trying to display the pdf after it's created and that is what is causing it to try to download the reader.
Because id_buku
is being compared to a string value, which is ok. The table name fk_00_m_buku
is not a string, and if you were to add limits to this query they need to be integers not strings.
In the previous query you were creating the table name and limit values as strings, which wont work. String values for comparison (WHERE clause) do need to have quotes.
I feel like maybe I'm not explaining this clearly enough, but not sure how else to put it. You need to take a look at the result SQL query of those you are producing so that you can better see the differences.
your initial query
$table = "t_book";
$start = 1;
$amount = 15;
$sql = "select * '".$table."' limit '". $start ."' , '". $amount ."'";
echo $sql;
//output result is...
select * 't_book' limit '1' , '15'
//Correct syntax should be...
select * from t_book limit 1 , 15
second example
$id_book = "A";
$sql = "select * from fk_00_m_buku where id_buku='". $id_book ."'";
//output is OK ...
select * from fk_00_m_buku where id_buku='A';
NOTE
This second query is treating the book_id as a string, if this is supposed to be a number (is an integer in the database) MySQL is capable of implicitly converting '1'
to 1
for the comparison - however, it is better practice to not use quotes and pass the value as an integer yourself.
You only need to use quotes '
when you …
You don't need single quotes around your variables inserted in the sql string - there weren't single quotes in the original, and adding them makes the table name and limiters string values.
Echo your sql string to the page so you can see it and copy/run it manually to check that it works.
Have a read of the MySQL Join documentation, specifically the section that covers Left/Right joins.
What I would use here is a LEFT JOIN
which allows the parent record (ie: dealer_item) to be shown with a null record where no data exists in the child record (dealer_product). More left join can be used to add more "optional" child tables to the query in the same way.
Have a go at rewriting the joins and I can help further if you have trouble with syntax or anything.
@Msanches; Firstly, let me address your comments on advertising by saying that many long time users are happy to have ads displayed in order to support the site. Many online communities achieve this by disabling ads for paying members, so I find it extremely generous and convenient that Dani allows free (but verified) members to disable ads.
Also, Stack overflow does have ad banners as well - the content of which appears to be mostly their own, which demonstrates only that they have reached the point where advertising revenue is no longer necessary to support their continued operation, but is no less annoying than any other ads.
Secondly, while I agree that "stole" is a strong (and perhaps inaccurate) word to use, if you had read past the title you would see that it is not actually used in the article at any point, and that she is in fact presenting evidence of possible collusion between Google and SO - whatever view you take of this theory, I think most of us recognised that the terminology used in the title was somewhat metaphorical.
Furthermore, "preference" has no baring on Googles search results. They track usage history and clickthroughs - but most people click through all links that appear to be vaguely interesting on the first page of a result set, and Google has no way of knowing whether that site was actually useful or not. The sites shown on that first page are algorithmically determined to be relevant based on …
I feel that all this business of personalized searches is also annoying in the same way: I'm not searching the web to find things I already know about. I'd wish there was a button to reverse it completely (as in, "give the results that are as far removed as possible from what I've previously visited").
I agree with that sentiment completely. I remember reading something a while back where a Google engineer was talking about the "personalised" search features and mentioned that there are over 50 different metrics used to track user activity for this purpose, including IP address, geolocation and other data that is somewhat more difficult to strip from your browser headers.
I almost always use incognito mode for searches in order to remove as much personal data and history from skewing the results as possible, but it is still ridiculously localised. IMHO the only time this is useful is in searching for a local business such as "pizza"
and in most other cases amounts to a form of censorship.
Dani, I found this site years ago via a Google search, but honestly can't say the last time I have seen DW in a result set - I do notice it has become a rarety. In fact my search results are serviced almost exclusively by a small set of websites including the stackexchange family, wikipedia and youtube - anything beyond that I have to really dig around for.
It annoys me to no end that certain …
mysql_query returns a resource datatype on success, which is not simply printable like you are trying to do.
You need to call either mysql_fetch_array or mysql_fetch_assoc passing the $result
to that function, which will return each row as an Array structure that can be iterated and printed as any typical array.
Example:
$sql = "Select FirstName from Person Where LoginID = (Select LoginID from UserLogin Where Username = '$username')"
$result = mysql_query($sql,$con);
while ($row = mysql_fetch_assoc($result)) {
echo $row["FirstName"];
}
Thanks, disabling the viewstate for the grid solved the problem. I didn't realise the grid was posting the entirity of itself back each time (and since viewstate is ON by default).
Interestingly I wouldn't even get an exception in debug mode, the browser just got a connection reset.
I don't really see how your comment about the databinding occurrences relates to this, unless theres something I'm missing? I have the datasources set up in this case to bind automatically in the aspx page - ie: I'm not calling databind manually at all in code behind, so asp.net takes care of knowing when the controls need to be refreshed.
Hi All
I have googled this exception extensively, and all the discussions I've found seem to be related to file uploading and exceeding the allowed file size limit. In my case however, I am not uploading anything, it is a simple postback.
I have a gridview displaying the results of an SQL query. This works correctly and displays the data as expected. Also, on the page are a couple dropdowns used to filter the data via control parameters on the SQL data source. However, any postback created on the page cause the above exception.
I have tested the query and all the filter parameters work as expected. I have tested removing various controls and cannot determine a single cause or point of failure, as the error occurs regardless of how the postback is triggered.
Any suggestions appreciated.
@broj too true... a part of me will certainly miss the relic that has been my accomplice on many a project over the last decade or so.
@Al That is a hefty block of text, I agree, though it bothered me little (I didn't read most of it, but it didn't bother me). On the other hand I've noticed several occurences of their syntax highlighting being incorrect, which I feel is vital for the type of site it is.
No doubt much of this will be improved before it goes "live" anyway.
I mostly like the new design, nice and clean. It seems to be a bit easier to find stuff by navigating compared to the original as well.
I actually hadn't scrolled all the way to the bottom of a page until you mentioned the photostrip - had to check it out. Does seem somewhat out of place with the rest of the site... meh, it's not likely that I'll scroll that far very often anyway.
Must say though, I'm a little dissapointed in the heavy reliance on javascript, particularly for navigation.
On a side note, I'm not sure how you are intending to use those fields, but you may want to check the manual on date & time data types
Typically, timestamp
is used to auto-generate the current time (in unix timestamp format) when the record is updated. If you want to store specific values, you may be better served to use the datetime
type.
Just a thought.
I don't think you have to specify a field size for timestamp
type columns. This appears to be where the error message is orriginating, so I would try removing it so those fields read simply as:
`msgstartdt` timestamp NOT NULL ,
`msgdttime` timestamp NOT NULL ,
You will have to expand the border (probably both form and container) to see the hidden controls, then copy/paste them from the container onto the form.
Is that your entire css? You haven't specified any other margin or float values or anything for other elements?
Beginnerdev is correct in saying this:
txtRoomComment.text.
If there is a ' character present in that field, you would have been terminating the sql statement
In addition to the syntax changes above, you should apply some parsing/checking for characters that may break your sql. This can be done with a simple Replace
but there are several characters that may have adverse affects. It is common to have a function that prepares string / user input data for database insertion, which handles this type of thing.
Can you post your table structure. There is obviously something not quite right.
RE: your original method
WHEN I PUT THE ExecuteNonQuery inside the try block i get SYNTAX ERROR IN INSERT INTO STATEMENT
That is what I would expect to see since your SQL is a bit off.
"@Amt/Day" is set as a text feild
The datatype is not relevant, @Amt/Day
is not a valid parameter name, you need to remove the slash: ie @AmtDay
When i remove the the blocks from the column i get SYNTAX ERROR IN INSERT INTO STATEMENT
Thats because you need the square brackets.
The following are sytax errors in your INSERT SQL;
'
the parameters as they are already of the appropriate datatype. You have quoted the whole lot which will try to insert a single literal string instead of the parameter values.You're corrected SQL is:
cmd.CommandText = "INSERT INTO Rooms ([RoomID], [First Name], [Middle Name], [Last Name], [Room Type], [Amt/Day], [Comments]) VALUES (@RoomID, @FirstName, @MiddleName, @LastName, @RoomType, @AmtDay, @Comments)"
Also, you will need to block the column names in your insert statement as you had done previously in the commented out line, ie: INSERT INTO Rooms (RoomID, [First Name], [Middle Name], [Last Name], [Room Type], [Amt/Day], Comments) VALUES ...
That's what I can see from a quick glance over your code. If you try these changes and then provide any error messages still received I/someone will help further.
What is the error?
Also, why is the execute not inside the try block?
I'm going to take a stab in the dark here and guess that your issue has something to do with having a slash in your parameter name "@Amt/Day"
- try removing that and see what happens.
Server side, yes. Only the submit button that was clicked will be set in the POST data.
I agree with diafol, if you truncate the table and keep the modified schema, then re-import the file into that table it should work.
Did you specify column types or let it auto generate? Can you post the table schema?
I believe it is your logout button.
<a href="index.jsp" id="btnLogout" onclick="<%session.invalidate();%>">Logout</a>
It is a while since I've worked in jsp, so someone may correct me, but I believe this is executing the session.invalidate()
function and printing the result into the javascript onclick
call. You are not able to use javascript events to call server side functions in this way.
To test if this is correct, remove temporarily remove the logout button (or at least the call to session.invalidate
) and try to run the page again.
Have a look at this post or google for how to call server side code from a hyperlink. But I think you will have to post the request to the server in order to achieve the functionality you require. I don't believe it can be done inline as you are trying to do.
Probably he has an event declared in the ASP/HTML code with no corresponding function in the code behind.
You can do it all in the loop if you handle the parameters properly.
private void autofillyr(int incrementBy, int maxyr, int no_year)
{
for (int i = no_year; i < maxyr; i += incrementBy)
{
year.Items.Add(new ListItem(i.ToString(), i.ToString()));
}
}
and the function call...
protected void Page_Load(object sender, EventArgs e)
{
...
autofillyr(1, 2050, 1900);
}
actually, i repurposed your no_year
parameter as start year since it is unclear what the purpose of this parameter is.
I would susggest doing the days function the same way since
if (incrementBy <= max) // this line is irrelevant
try...
private void autofilldate(int incrementBy, int max) //don't need `itemcount`
{
for (int i = 1; i < max; i += incrementBy)
{
day.Items.Add(new ListItem(i.ToString(), i.ToString()));
}
}
You haven't posted your month function, but it can be done the same way. In fact you could use the same function to fill all 3 dropdowns (as per the Year function I just posted) call them with appropriate start
, max
, and increment
values, just pass the dropdown itself as another parameter. I would also make the increment an optional parameter with default of 1
.
have a look at these pages for various server packages (including links).
https://en.wikipedia.org/wiki/List_of_AMP_packages
https://en.wikipedia.org/wiki/Comparison_of_WAMPs