I have a SQL 2008 Ent server with the databases "DBOne", "DBTwo", "DBThree" on the server DEVSQLSRV.
Here is my Powershell script:
$DBNameList = (Invoke-SQLCmd -query "select Name from sysdatabases" -Server DEVSQLSRV)
This produces my desired list of database names as:
Name
-----
DBOne
DBTwo
DBThree
I has been my assumption that anything that is returned as a list is an Array in Powershell. However, when I then try this in Powershell:
$DBNameList -contains 'DBTwo'
It comes back has "False" instead of "True" which is leading me to believe that my list is not an actual array.
Any idea what I'm missing here?
Thanks so much!
Emo
I've always used ajax to load() the contents of a DOM element but now I'm trying set a form field value with the result of the following query:
$('#form_field').load(base_url+'ajax/get_yearly_fee', {
'q_value': $(this).val(),
'client_id': $("#fee_client_add").val()
});
What's the best way to do this?
An interesting question was asked to me and I did not know what to answer.. So I'll ask here.
Let's say I subscribed to an ISP and I'm using cable internet access. ISP gives me a public IP address of 60.61.62.63.
What keeps me from changing this IP address to, let's say, 60.61.62.75 and mess with another consumer's internet access?
For the sake of this argument, let's say that this other IP address is also owned by the same ISP. Also, let's assume that it's possible for me to go into the cable modem settings and manually change the IP address.
Under a business contract where you are allocated static addresses, you are also assigned a default gaetway, a network address and a broadcast address. So that's 3 addresses the ISP "loses" to you. That seems very wastefull for dynamically assigned IP addresses where the majority of customers are..
Could they simply be using static arps? ACLs? Other simple mechanisms?
Anyone who worked at an ISP would be willing to explain this a bit?
Hello!
I have a dictionary with non unique values and I want to count the matches of a string versus the values.
Basically I now do dict.ContainsValue(a) to get a bool telling me if the string a exists in dict, but I want to know not only if it exists but how many times it exists (and maybee even get a list of the keys it exists bound to)
Is there a way to do this using dictionary, or should I look for a different collection?
/Rickard Haake
Hi folks,
my admin urls are sat behind a prefix by doing the following.
1#
(r'^admin/', include(admin.site.urls)),
is placed within urls_core.py
2#
(r'^api/', include('project.urls_core')),
is palced within urls.py
All admin URLs work fine except app indexes.
If I go to any URL such as:
/api/admin/core/
/api/admin/registration/
/api/admin/users/
/api/admin/filters/
I receive 'INVALID REQUEST' as my response. Status code is 200 (OK) though.
I have never received this error message before.
Does anyone have a clue? Thanks guys!
I have a fairly pedestrian non-editable NSOutlineView setup. In the bindings for the outline view, I have set the binding to my file's owner (MyDocument FWIW) with a selector of outlineViewWasDoubleClicked
The method exists and is called, but when I call -clickedRow it consistently returns -1 rather than the row number of the row that I double clicked to trigger the method.
My _outlineView is an IBOutlet and I've verified that it is hooked up correctly by using -selectedRow for the method rather than -clickedRow (I would rather use -clickedRow though because it seems unintuitive for the user to have a row selected, double click another row to do something with it and have the method triggered with the row they had selected.)
My best guess right now is that the -clickedRow value is getting cleared out before my method fires, but I don't know where or what might be gobbling it up.
Thanks in advance for any help.
I want a string type that is Unicode and that stores the string directly at the adress of the variable, as is the case of the (Ansi-only) ShortString type.
I mean, if I declare a S: ShortString and let S := 'My String', then, at @S, I will find the length of the string (as one byte, so the string cannot contain more than 255 characters) followed by the ANSI-encoded string itself.
What I would like is a Unicode variant of this. That is, I want a string type such that, at @S, I will find a unsigned 32-bit integer containing the length of the string in bytes (or in characters, which is half the number of bytes) followed by the Unicode representation of the string. I have tried WideString, UnicodeString, and RawByteString, but they all appear only to store an adress at @S, and the actual string somewhere else (I guess this has do do with reference counting and such).
I suspect that there is no built-in type to use, and that I have to come up with my own way of storing text the way I want (which actually is fun). Am I right?
Hello!
[I am rather new to Java and Object Oriented programming]
I have an abstract class Moveable with the method abstract void move() which is extended by the class Bullet and the abstract class Character, and Character is extended by the class Survivor and the class Zombie. In Survivor and Bullet the move() method doesnt require any parameters while in the class Zombie the move() method depends on the actual position of the survivor. The survivor and multiple zombies are created in the class Gui.
I wanted to access the survivor in Zombie - what's the best way of doing this? In Gui i wrote a method getSurvivor() but i don't see how to access this method in Zombie?
I am aware that as a workaround i could just pass a [Survivor survivor] as parameter in move() and ignore it in Bullet and Survivor, but that feels so ... bad practice.
Thank you for your time!
Samuel
[I am not sure what tags to set here, please correct me if i'm wrong]
This program takes string like that 192.168.1.125 and cut every number then converts it to integer, but it returns an error.
import java.lang.String;
import java.lang.Number;
import java.lang.Integer;
class Ip
{
public static void main ( String [] args )
{
int i ;
i = args[0].indexOf ( '.' );
do
{
if ( i != -1 )
args[0].substring ( 0, i );
String str = args[0].substring ( i + 1, args[0].length() );
String str2 = Integer.parseInt ( str );
System.out.println ( str2 );
}
while ( i != -1 );
}
}
This only happens on my local machine (Windows 7, Ruby 1.8.7). Occasionally rails will just stop returning my stylesheets/javascript and I'll get gross looking pages. If I navigate directly to those scripts, sometimes they work, and sometimes I get errors like:
private method `gsub!' called for #<Class:0x76ff830>
What could be causing this? It is usually more a nuisance than anything because of lack of styles, but when I'm trying to test out my javascript it becomes an issue. Thanks!
I have the following foloder tree on my shared hosting server:
www.somesite.com
|
|_ public_html (document folder)
|_ .htaccess (Apache file)
|_ inde.html (page shown by server now when someone looks for www.somesite.com)
|
|_ site_editor (folder)
| |_login.html (site editor control panel)
| |_file1.php
| |_file2.php
| |_ ...
|
|_ website (folder)
|_ index.html (website HOME PAGE)
|_ page1.html
|_ page2.html
|_ etc.
Now when someone looks for www.somesite.com the webserver look for index.html in public_html folder.
I would like the web server to show website/index.html when someone looks for www.somesite.com and I would like his browser bar to show only www.somesite.com/index.html and not www.somesite.com/website/index.html
I would also like the web server to show site_editor/login.html when someone looks for www.somesite.com/site_editor/
Is it possible to accomplish both task by setting .htaccess files in some ways???
Thanks!
I code WinForm application where one of the input is magnetic stripe card reader (CR). I am using code George Mamaladze's article Processing Global Mouse and Keyboard Hooks in C# on codeproject.com to listen keyboard (USB card reader acts same way as keyboard) and I have weird situation.
One card reader CR1 (Unitech MS240-2UG) produces keystroke which I intercept on KeyPress event analyze that I intercept certain patter like %ABCD-6EFJHI? and trigger some logic. Analysis required because user can type something else into application or in another application meanwhile my app is open
When I use another card reader CR2 (IdTech IDBM-334133) keystroke intercepted by hook started from number 5 instead of % (It is actually same key on keyboard). Since it is starting sentinel it is very important for me to have ability recognize input from card reader. Moreover if my app running in background and I have focus on Notepad when I swipe card string %ABCD-6EFJHI? appears in Notepad and same way, with proper starting character) intercepted by keyboard hook. If swiped when focus on Form it is 5ABCD-6EFJHI?
User who tried app with another card reader has same result as me with CR2. Only CR1 works for me as expected
I was looking into Device manager of Windows and both devices use same HID driver supplied by MS. I checked devices though respective software from CR makers and starting and ending sentinels set to % and ? respective on both.
I would appreciate and ideas and thoughts as I hit the wall myself
Thank you
I'm working on an iPhone project where I would like to retrieve an object from an NSMutableArray, remove the object from the array and then use it later. The code looks something like this:
NSMutableArray * array;
// fill the array
NSObject * obj = [array lastObject];
[array removeLastObject];
// do something with obj (in the same function)
array is the only entity with a retain on the object that is being accessed. Is this safe to do? I would assume that this would only work if lastObject autoreleased the object which is something that I can't figure out if it does.
The contents of test.json are:
{"foo": "The quick brown fox jumps over the lazy dog.","bar": "ABCDEFG","baz": [52, 97]}
When I use the following jQuery.ajax() call to process the static JSON inside test.json,
$.ajax({
url: 'test.json',
dataType: 'json',
data: '',
success: function(data) {
$('.result').html('<p>' + data.foo + '</p>' + '<p>' + data.baz[1] + '</p>');
}
});
I get a JSON object that I can browse in Firebug.
However, when using the same ajax call with the URL pointing instead to this php script:
<?php
$arrCoords = array('foo'=>'The quick brown fox jumps over the lazy dog.','bar'=>'ABCDEFG','baz'=>array(52,97));
echo json_encode($arrCoords);
?>
which prints this identical JSON object:
{"foo":"The quick brown fox jumps over the lazy dog.","bar":"ABCDEFG","baz":[52,97]}
I get the proper output in the browser but Firebug only reveals only HTML. There is no JSON tab present when I expand GET request in Firebug.
Dear all,
I'm unable to retrieve the latest inserted id from my SQL Server 2000 db using a typed dataset in asp.NET
I have created a tableadapter and I ticked the "Refresh datatable" and "Generate Insert, Update and Delete statements". This auto-generates the Fill and GetData methods, and the Insert, Update, Select and Delete statements.
I have tried every possible solution in this thread
http://forums.asp.net/t/990365.aspx
but I'm still unsuccesfull, it always returns 1(=number of affected rows).
I do not want to create a seperate insert method as the auto-generated insertCommand perfectly suits my needs.
As suggested in the thread above, I have tried to update the InsertCommand SQL syntax to add SELECT SCOPY_IDENTITY() or something similar, I have tried to add a parameter of type ReturnValue, but all I get is the number of affected rows.
Does anyone has a different take on this?
Thanks in advance!
Stijn
Some of the queries we run have 100'000+ results and it takes forever to load them and then send them to the client. So I'm using ScrollableResults to have a paged results feature. But we're topping at roughly 50k results (never exactly the same amount of results).
I'm on an Oracle9i database, using the Oracle 10 drivers and Hibernate is configured to use the Oracle9 dialect. I tried with the latest JDBC driver (ojdbc6.jar) and the problem was reproduced.
We also followed some advice and added an ordering clause, but the problem was reproduced.
Here is a code snippet that illustrates what we do:
Criteria crit = sess.createCriteria(ABC.class);
crit.add(Restrictions.eq("property", value));
crit.setFetchSize(pageSize);
crit.addOrder(Order.asc("property"));
ScrollableResults sr = crit.scroll();
...
...
do{
for (Object entry : page)
sess.evict(entry); //to avoid having our memory just explode out of proportion
page.clear();
for (int i =0 ; i < pageSize && ! metLastRow; i++){
if (resultSet.next())
page.add(sr.get(0));
else
metLastRow = true;
}
metLastRow = metLastRow?metLastRow:sr.isLast();
sendToClient(page);
}while(!metLastRow);
So, why is it that I get the result set to tell me its at the end when it should be having so much more results?
Hello developers!
I get deadlock error in my mysql transaction.
The simple example of my situation:
Thread1 > set autocommit=0;
Query OK, 0 rows affected (0.00 sec)
Thread1 > SET TRANSACTION ISOLATION LEVEL READ COMMITTED;
Query OK, 0 rows affected (0.00 sec)
Thread1 > SELECT * FROM A WHERE ID=1000 FOR UPDATE;
1 row in set (0.00 sec)
Thread2 > set autocommit=0;
Query OK, 0 rows affected (0.00 sec)
Thread2 > SET TRANSACTION ISOLATION LEVEL READ COMMITTED;
Query OK, 0 rows affected (0.00 sec)
Thread2 > INSERT INTO B (AID, NAME) VALUES (1000, 'Hello world');
SLEEP
Query OK, 1 row affected (4.99 sec)
Thread1 > INSERT INTO B (AID, NAME) VALUES (1000, 'Hello world2');
ERROR 1213 (40001): Deadlock found when trying to get lock; try restarting transaction
B.AID -> FK -> A.ID
I see three solutions:
catch deadlock error in code and retry query.
use innodb_locks_unsafe_for_binlog in my.cnf
lock (for update) table A in Thread2 before insert
Can you give me more solutions ? Current solutions do not fit me.
I have a hard time finding a good question title - let me just show you what I have and what the desired outcome is. I hope this can be done in SQL (I have SQL Server 2008).
1) I have a table called Contacts and in that table I have fields like these:
FirstName, LastName, CompanyName
2) Some demo data:
FirstName LastName CompanyName
John Smith Smith Corp
Paul Wade
Marc Andrews Microsoft
Bill Gates Microsoft
Steve Gibbs Smith Corp
Diane Rowe ABC Inc.
3) I want to get an intersecting list of people and companies, but companies only once. This would look like this:
Name
ABC Inc.
Bill Gates
Diane Rowe
John Smith
Marc Andrews
Microsoft
Smith Corp
Steve Gibbs
Paul Wade
Can I do this with SQL? How?
I have a report which worked perfectly.
I inserted a subreport at the top (basically a cover sheet)
Now the rest of the report runs, but has "no data available" all over it
What is going on?!
Googled for this to no avail. Didn't find anything in the API either. I was expecting some kind of class method or configuration option to set it...
So, rather than calling
from "[email protected]"
for every method, it could be called automatically.
I want to sort out specific files depending on their names, i want a regex that returns true for file names like : 01.mp4, 99.avi, 05.mpg.
the file extensions must match exactly to the ones that i want and the filename must start with characters which can not be longer than 2 characters. the first part is done but the file extensions aren't working. need some help
the regex that I have is
/^[0-9]{1,2}\.[mp4|mpg|avi]*/
but it also returns true for 01.4mp4, 01.4mp4m.
I'm building a data access layer in Excel VBA and having trouble returning a recordset. The Execute() function in my class is definitely retrieving a row from the database, but doesn't seem to be returning anything.
The following function is contained in a class called DataAccessLayer. The class contains functions Connect and Disconnect which handle opening and closing the connection.
Public Function Execute(ByVal sqlQuery as String) As ADODB.recordset
Set recordset = New ADODB.recordset
Dim recordsAffected As Long
' Make sure we are connected to the database.
If Connect Then
Set command = New ADODB.command
With command
.ActiveConnection = connection
.CommandText = sqlQuery
.CommandType = adCmdText
End With
' These seem to be equivalent.
'Set recordset = command.Execute(recordsAffected)
recordset.Open command.Execute(recordsAffected)
Set Execute = recordset
recordset.ActiveConnection = Nothing
recordset.Close
Set command = Nothing
Call Disconnect
End If
Set recordset = Nothing
End Function
Here's a public function that I'm using in cell A1 of my spreadsheet for testing.
Public Function Scott_Test()
Dim Database As New DataAccessLayer
'Dim rs As ADODB.recordset
'Set rs = CreateObject("ADODB.Recordset")
Set rs = New ADODB.recordset
Set rs = Database.Execute("SELECT item_desc_1 FROM imitmidx_sql WHERE item_no = '11001'")
'rs.Open Database.Execute("SELECT item_desc_1 FROM imitmidx_sql WHERE item_no = '11001'")
'rs.Open
' This never displays.
MsgBox rs.EOF
If Not rs.EOF Then
' This is displaying #VALUE! in cell A1.
Scott_Test = rs!item_desc_1
End If
rs.ActiveConnection = Nothing
Set rs = Nothing
End Function
What am I doing wrong?
I have a callout which displays details of a point using a custom view, how can I prevent my mapview from being reloaded when I navigate back to it using the standard navigationcontroller ui devices?
I have a related question, but this is another part of MY puzzle.
I would like to get the OLD VALUE of a Column from a Row that was UPDATEd... WITHOUT using Triggers (nor Stored Procedures, nor any other extra, non-SQL/-query entities).
The query I have is like this:
UPDATE my_table
SET processing_by = our_id_info -- unique to this instance
WHERE trans_nbr IN (
SELECT trans_nbr
FROM my_table
GROUP BY trans_nbr
HAVING COUNT(trans_nbr) > 1
LIMIT our_limit_to_have_single_process_grab
)
RETURNING row_id
If I could do "FOR UPDATE ON my_table" at the end of the subquery, that'd be devine (and fix my other question/problem). But, that won't work: can't have this AND a "GROUP BY" (which is necessary for figuring out the COUNT of trans_nbr's). Then I could just take those trans_nbr's and do a query first to get the (soon-to-be-) former processing_by values.
I've tried doing like:
UPDATE my_table
SET processing_by = our_id_info -- unique to this instance
FROM my_table old_my_table
JOIN (
SELECT trans_nbr
FROM my_table
GROUP BY trans_nbr
HAVING COUNT(trans_nbr) > 1
LIMIT our_limit_to_have_single_process_grab
) sub_my_table
ON old_my_table.trans_nbr = sub_my_table.trans_nbr
WHERE my_table.trans_nbr = sub_my_table.trans_nbr
AND my_table.processing_by = old_my_table.processing_by
RETURNING my_table.row_id, my_table.processing_by, old_my_table.processing_by
But that can't work; "old_my_table" is not viewable outside of the join; the RETURNING clause is blind to it.
I've long since lost count of all the attempts I've made; I have been researching this for literally hours.
If I could just find a bullet-proof way to lock the rows in my subquery - and ONLY those rows, and WHEN the subquery happens - all the concurrency issues I'm trying to avoid disappear...
UPDATE: [WIPES EGG OFF FACE] Okay, so I had a typo in the non-generic code of the above that I wrote "doesn't work"; it does... thanks to Erwin Brandstetter, below, who stated it would, I re-did it (after a night's sleep, refreshed eyes, and a banana for bfast). Since it took me so long/hard to find this sort of solution, perhaps my embarrassment is worth it? At least this is on SO for posterity now... :
What I now have (that works) is like this:
UPDATE my_table
SET processing_by = our_id_info -- unique to this instance
FROM my_table AS old_my_table
WHERE trans_nbr IN (
SELECT trans_nbr
FROM my_table
GROUP BY trans_nbr
HAVING COUNT(*) > 1
LIMIT our_limit_to_have_single_process_grab
)
AND my_table.row_id = old_my_table.row_id
RETURNING my_table.row_id, my_table.processing_by, old_my_table.processing_by AS old_processing_by
The COUNT(*) is per a suggestion from Flimzy in a comment on my other (linked above) question. (I was more specific than necessary. [In this instance.])