Posts

Showing posts from May, 2015

c# - ASP.NET MVC 2 client-side validation triggering incorrectly -

Image
i using dataannotations enable client-side validation in asp.net mvc 2 project. having issue url validation regex passes unit test, fails in actual website. model [regularexpression(urlvalidation.regex, errormessage = urlvalidation.message)] public string url { get; set; } regex = "(([\w]+:)?//)?(([\d\w]|%[a-fa-f\d]{2,2})+(:([\d\w]|%[a-fa-f\d]{2,2})+)?@)?([\d\w][-\d\w]{0,253}[\d\w]\.)+[\w]{2,4}(:[\d]+)?(/([-+_~.\d\w]|%[a-fa-f\d]{2,2})*)*(\?(&?([-+_~.\d\w]|%[a-fa-f\d]{2,2})=?)*)?(#([-+_~.\d\w]|%[a-fa-f\d]{2,2})*)?" message = "invalid url" view <div class="editor-label"> <%: html.labelfor(model => model.url) %> </div> <div class="editor-field"> <%: html.textboxfor(model => model.url) %> <%: html.validationmessagefor(model => model.url) %> </div> result url = http://www.chicagoshakes.com/main.taf?p=7,8 passing unit test [test] public void getvarurlpasses() {

php - How do I check for emulated prepared statements in ADOdb? -

i've been using adodb many years database abstraction , query caching layer. lately switched prepared statements, security, , became curious way (or not) implemented. quote documentation prepare method: “ returns array containing original sql statement in first array element; remaining elements of array driver dependent. if there error, or emulating prepare( ), return original $sql string. ” testing statement variable with: $stmt = $db->prepare("select * pages id = ?"); print_r($stmt); on connections opened ‘mysql’ or ‘mysqli’ parameter original query string returned – meaning prepared statement emulated, guess. connection opened ‘pdo_mysql’ returns (from print_r()): array ( [0] => select * pages id = ? [1] => pdostatement object ([querystring]=>select * pages id = ?) ) can take definite proof of real prepared statement? if not, know of quick , dirty way check server-side (something in query log, or maybe in mysqlproxy)? tried read

javascript - Keep Colorbox always centered on scroll -

when using thickbox if user scrolled vertically thickbox stay centered. colorbox if scroll lose site of colorbox , see grayed out background. how can update colorbox have same functionality maintains position on screen regardless of user scrolling. http://colorpowered.com/colorbox/core/example1/index.html http://jquery.com/demo/thickbox/ resize window have vertical scrollbar , scroll , can see difference. thanks i may bit late, fyi can use "fixed" option in colorbox declaration. option "false" default. if set "true" result want: $('#my_box').colorbox({ fixed: true });

sql server 2005 - What would make a table "slow?" -

what make 1 table substantially slower another? easiest illustrate: query 1: select top 1000 * call c join call_task ct on c.call_no=ct.call_no left join memo_clt m on m.doc_ref=ct.record , m.doc_type='clt' , m.line_no=1 left join memo_clt m2 on m2.doc_ref=ct.record , m2.doc_type='clt' , m2.line_no=2 query 2: select top 1000 * call c left join ext_document_detail edd on edd.doc_type='clh' , edd.doc_ext_no=21 , edd.doc_ref=c.record left join ext_document_detail edsource on edsource.doc_type='clh' , edsource.doc_ext_no=22 , edsource.doc_ref=c.record the structure of tables similar, , i'm accessing ext_document_detail similar join compared memo_clt table. yet second query takes 40 seconds, while other 1 takes 0 seconds. both have clustered index on 3

controls - A Panel To Block a View Android -

greetings! i'm building app requires internet use , whole tab doesn't work without it. when select tab checks if there internet , if there isn't panel slide (or appears) on controls nothing can done until connection internet established. how achieve this? thanks -mitchell i think covering controls weird since make empty useless tab. there 2 better ways of doing this. first when tab gains focus can disable or enable controls based on detection of network connection. other add or remove whole tab based on detection of connection.

c# - How to get specific Range in Excel through COM Interop? -

i have following problem. have read excel file through com interop. new programming com interop. i search specific string using this: this.sheet = (excel.worksheet)this.excelapp.workbook.sheets.item[this.sheetname]; this.sheet.activate(); excel.range firstrow = this.sheet.range["a1", "xfd1"]; excel.range foundrange = firstrow.find( this.stringisearch, type.missing, type.missing, excel.xllookat.xlwhole, excel.xlsearchorder.xlbycolumns, excel.xlsearchdirection.xlnext, false, false, type.missing); no want use foundrange starting point range. something this excel.range myrange = this.sheet.range[foundrange + 2 rows, + 1 column & lastrow]; i don't see way this. there one? okay, after sleep have found answer. int startcolumn = header.cells.column; int startro

c# - Find uncalled code -

possible duplicate: what tools , techniques use find dead code in .net? does know of tool can find functions not being called? clarification: functions not being called in solution. should not matter if public, private etc. there several tools available varying degrees of depth. resharper ncover fxcop

c++ - What is wrong with my syntax in this 1 line bit of code (pointers and references and dereferences oh my)? -

the code having trouble line: result.addelement(&(*(setarray[i]) + *(rhs.setarray[j]))); the + operator in class overloaded (there variety of overloads can fit in set, have similar header): const rational rational::operator+(const rational &rhs) const the setarrays in code above both arrays of pointers, + operator requires references, might problem. addelement, method of result, has header: bool set::addelement(multinumber* newelement) the multinumber* in header parent class of rational, mentioned above. don't think of specific code matters. i'm pretty sure syntax issue. my compiler error is: 68: error: invalid conversion 'const multinumber*' 'multinumber*' thank help! this code has more serious issues can fix adding const or typecast somewhere. the result of code crash somewhere down line, because you're passing pointer temporary. once finish line of code calls addelement , pointer left dangling, , trying use obje

asp.net - Automatic fix for tempdb error related to 'ASPStateTempSessions' -

as per this how-to , i've configured iis on xp-sp3 dev box sql server 2008 express save asp.net session state information. i'm using sql server because otherwise on every recompile, losing session state obnoxious (having re-login). but, i'm facing annoying issue in every time restart sql there's error, , 1 or 2 other similar friends: the select permission denied on object 'aspstatetempsessions', database 'tempdb', schema 'dbo'. to fix error, open management studio , edit user mapping login/dbo i'm using on aspstate db, , re-add tempdb user deny permissions. apparently, once right permissions there, asp.net able automatically create tables uses. can't run createtemptables sproc until right security there. the question... there way not have re-do on every restart of sql server? i don't care right keeping temp data across restarts, not have go through manual step web app working on localhost, uses session state variables t

osx - Java memory leak when running on Red Hat but no memory leak on Mac OS X -

i have java webobjects app showing memory leak problems when running on red hat had no such problems when running on mac os x. jvms similar. mac os x 10.6.5 using java 1.6.0_22 64 bit apple red hat el 5.0 using java 1.6.0_20 64 bit sun i configured heap dump when ran out of memory, , analysing eclipse memory analyzer tool suggests problem in part of code creates thread sends http request web service. reason creating thread implement timeout on request because web service not available. does have ideas? wohttpconnection connection = new wohttpconnection(host, port); worequest request = new worequest(strmethod, strquery, strhttpversion, nsdheader, content, null); webservicerequester therequester = new webservicerequester(connection, request); thread requestthread = new thread(therequester); requestthread.start(); try { requestthread.join(inttimeoutsend); //timeout in milliseconds = 10000 if ( requestthread.isalive() ) {

cocoa - Applescript not accepting arRsync sdef commands? -

i'm using opensource gui frontend rsync called "arrsync". works great, there's no way automate it. what i'm trying use applescript run preset (which define in application) using following simple script: tell application "arrsync" runpreset "presettest1" the problem applescript thinks "runpreset" variable, not command. i've tried tell/end-tell variation of above, no dice. 'runpreset' command part of arrsync.sdef you can find arrsync project here i've tried opening both info.plist files inside app , ticking 'scriptable' box (or setting 'true' of without property list editor) i'm still stuck. i'm scripting noob when comes cocoa :p appreciated the arrsync binary missing scripting dictionary. build source, first making following changes: edit info.plist in project, setting "scriptable" option true. fix project's script dictionary, arrsync.sdef. code runprese

xamarin.ios - Setting MonoTouch.Dialog UITableView position? -

is there way set position of monotouch.dialog dialogviewcontroller? have subclassed dialogviewcontroller , added uitoolbar @ top , want shift table view down corresponding pixels. public class myviewcontroller : dialogviewcontroller { uitoolbar toolbar; public sessionslistviewcontroller (rootelement rootelement) : base(rootelement) { this.toolbar = new uitoolbar(new rectanglef(0,0,768,44)); this.toolbar.items = new uibarbuttonitem[0]; this.add(toolbar); } } i never able change position of tableview in monotouch.dialog. it's not problem of library though, how tableviewcontroller works, inherited mt.dialog. the tableviewcontroller class supposed manage positioning of tableview automatically, , you're not supposed work around that. if create tableview different position, miguel.de.icaza mentioned about, tableviewcontroller rearrange tableview during willappear method. when not using mt.dialog, best way work aound this, , examp

c# 3.0 - Validate Input DateTime C# -

how can validate datetime (input) in format of dd/mm/yyyy hh:mm in c# i need throw error if specified format doesn't match above one. have @ using datetime.tryparseexact method converts specified string representation of date , time datetime equivalent using specified format, culture-specific format information, , style. format of string representation must match specified format exactly. method returns value indicates whether conversion succeeded.

Jquery linking button to specific content -

i have concept similar of accordian. have button, when clicked, slides down div specific id. have around 3 of these on page. how write 1 function automatically chooses correct div slide down? i've seen plugins use rel attribute achieve this. in actual jquery code, how accomplish this? eg code: <a rel="#c1">slide 1</a> <a rel="#c2">slide 2</a> <div id="c1"></div> <div id="c2"></div> you like $("a").click(function() { var divselector = $(this).attr("rel"); $(divselector).slidedown(); }); if want bit more fancy, group items (or give them class) , following other containers slide up. <div id="sliders"> <a rel="#c1">slide 1</a> <a rel="#c2">slide 2</a> </div> <div id="slidees"> <div id="c1"></div> <div id="c2"><

wpf - Nullable database property but texbox still shows red border when content deleted -

hi binding wpf textbox entity framework property follows: <textbox grid.column="1" grid.row="0" margin="5,2" text="{binding path=myentityobject.sizelower, mode=twoway}" /> it binds fine property , when change it, saves db expected. if delete content of textbox red error border around it. dont have validator in place guessing texbox complaining value not being nullable. in fact property in db nullable, cannot understand why error. the system generated ef property definition follows: <edmscalarpropertyattribute(entitykeyproperty:=false, isnullable:=true)> <datamemberattribute()> public property sizelower() nullable(of global.system.int64) return _sizelower end set onsizelowerchanging(value) reportpropertychanging("sizelower") _sizelower = structuralobject.setvalidvalue(value) reportpropertychanged("sizelower") onsizelowerchanged()

asp.net mvc close previous session for same user -

hi need close previous session same user. if user logon on computer , logon on b must close session a. have no ideas :( lot. start new session session.abandon(); and depending on inner workings of application logout user. of course not needed if store logged in user in session. abandoned first call anyway. edit if need access other sessions of same user have resort other session state modes inproc. in case db state mode trick. check msdn resource it. you have create separate table like: create table usersession ( userid int not null references dbo.user(userid), sessionid varchar(100) not null, primary key (userid, sessionid) ) go when user logs in have to: update usersession tabel , either remove existing user sessions. add current session. when user logs out remove record usersession table. you have custom ihttpmodule authentication. particular module should check whether record exists current session. if doesn't should lo

c# - Array of fixed-length BitArrays -

i'm in trouble bitarray . the goal simulate stack of 8 80bit bitarrays, numbered 0 7. i need able access them index, , think simple array enough me. when initialising bitarray object, need specify number of bits contain, gives me bitarray test = new bitarray(80); how can array of it, knowing need specify length value? i've tried several things, bitarray[] stack = new bitarray(80)[]; but error when trying give length... any thoughts? thanks in advance unfortunately, framework doesn't appear have "canonical" array-initialization pattern, far know. one way, using linq, be: var stack = enumerable.range(0, 8) .select(i => new bitarray(80)) .toarray(); or: var stack = enumerable.repeat<func<bitarray>>( () => new bitarray(80), 8) .select(f => f()) .toarray(); alternatively, bitarray[] stack = new bitarray[8]; for(int

php - htaccess URL redirect -

i redirect url(a) url(b). when url(b) loading, need run code , might redirect url(c). example :- paypal notification url, need run code in background when user browses specific type urls. any ideas on how this? you can redirect b redirect 301 b , , in b's script don't send headers until have redirect (or don't). if have redirect, send header("location: " + $c) , exit() .

how to check if user has closed the dialog by clicking on cross icon in jquery UI dialog -

i have 2 dialog boxes. user selects value in first 1 , reflected in dom of page. first dialog box closed , displayed. if user clicks on cross button in right hand top corner close dialog, want revert changes made in previous dialog box. on ok button, have stuff setting values. on button, i'm closing dialog. on close event, till have code reset form. but, if user cancels dialog box, how know, how close event triggered i.e. ok button or cross button ? you can find "x" button it's class, .ui-dialog-titlebar-close , attach click handler when creating dialog, this: $("#test").dialog({ //dialog options... }).parent().find(".ui-dialog-titlebar-close").click(function() { alert("closed title bar x, clear other form here"); }); you can test here .

.net - Generic type conversion -

i'm having serious design problems due generics issues. perhaps has suggestions. edit: so, know not done, i've changed example code, because i've realized original pseudo-code did not explain problem. following code more closely resembles real example dealing with. hope problem clearer it. apologize ahead bit lengthy, experience, problems generics show when try build more complex structure. so: class program { static void main(string[] args) { iconnector<iservice> connector = connectorbuilderfactory.newbuilder<iservice>("someendpoint").makereliable().getconnector(); connector.connect(); } } public interface iservice : iconnectionmaintainable { void dosomething(); } public interface iconnectionmaintainable { datetime getservertime(); } public interface iconnector<t> { t channel { get; } void connect(); void dis

How to save data in C/C++? -

in internet there databases(mysql, oracle etc.) can send informations submitted html input fields php or other server side language. how working in c/c++? how can let user input , them save inputted value? you can either: make use of standard file handling functions / classes . embed tiny database . talk database server using a standard interface . btw, these common languages.

actionscript 3 - How to design layout in Action Script 3.0? -

i want design registration form using actionscript, have designed labels , text boxes using label.x = "10" label.y="40" text.x = "50" text.y ="40"... align correctly. want design layout such labels , text boxes aligned properly. or examples or docs ? if use flex can use hbox/vbox , set dimensions in percent. otherwise create helper class (like positionutils) out. // position displayobjects in list margins 0, 5 , 10 positionutils.alignvertical([txtheader,txtbody, btnsend], [0,5,10]);

webserver - what is difference between web server and application server -

i confused in web server , application server. can tell me difference between these two. in practice, there little difference , people use term interchangeably. the subtle difference me is: a web server serves web pages , static content. not dynamic content. an application server can web server (with dynamic content), though might not @ all. offers api programmers. as usual, wikipedia has best definitions. web server : the computer application helps deliver content can accessed through internet. application server : an application server software framework dedicated efficient execution of procedures (programs, routines, scripts) supporting construction of applications. ... an application server acts set of components accessible software developer through api defined platform itself.

java - Getting tabindex value for UIComponent -

i'd tabindex of current uicomponent in generic way. gettabindex() available few components. there way of getting without casting component proper type? i thinking getting tabindex attribute current component how to this? use uicomponent#getattributes() . object tabindex = component.getattributes().get("tabindex"); if (tabindex != null) { // ... }

html - Button image moves up slightly when being clicked (in Internet Explorer) -

does know why image may move/jerk while being clicked (only happens in ie)? our button: <button class="join" name="register" value="" onclick="window.location = 'location'" tabindex="4"></button> this class: button.join { background: url(../images/join.png); border: 0; height: 56px; width: 178px; cursor: pointer; } button tags hassle styled correctly cross-browser. long you're using javascript onclick there's no real reason use button tag. try using anchor tag, targeting states , setting position of image. <a class="join" href="#" id="register" onclick="window.location = 'location'" tabindex="4">button</a> a.join:link, a.join:visited a.join:hover, a.join:active { background: url(../images/join.png) 0 0 no-repeat; border: 0; text-indent: -999em; /*

iphone - use % operator in xcode -

i'm trying make function use % operator in objective c function is: -(void) image1:(uiimageview *)img1 image10:(uiimageview *)img10 image100:(uiimageview *)img100 score:(nsinteger *)sc { nsinteger* s100,s10,s1; s100 = sc % 100; s10 = (sc - s100 * 100) % 10; s1 = (sc - sc % 10); nslog(@"%d",s1); } but got errors.. can guide me solution you can't implicitly create objects that. want s100, s10, s1 , sc c-style variables, you've declared s100 , sc pointers, though going hold objective-c objects. suggest change nsinteger* nsinteger in both cases. not things starting in ns objects.

Find value in dropdown and then select it through jquery -

i want find out value present in dropdown list , select value selected object in dropdownlist. im using jquery if want select option value can use $("#dropdownid").val(yourvalue); working demo

How to put a DevExpress extended component (RibbonPageGroup) on the toolbox for WinForms -

i have extended devexpress component (not control), ribbonpagegroup, used around application. see in toolbox in vs2010 designer "it won't appear" here. assume has inheritance hierarchy of extended component. doesn't derive control. am going wrong way extending type extends component. or can make possible appear on toolbox , drag , drop on ribboncontrols. any answer appreciated. tia, joep. answer devexpress: [toolboxitem(true), designtimevisible(true)] public class myribbonpagegroup : ribbonpagegroup {... however, should mention not visual component, when being placed onto form, appear @ bottom of screen other non-visual components. it surprises me it's not visual component. when add pagegroup via ribbonpage "accelerator" pop-menu new pagegroup appears. intention create custom pagegroup print , printpreview button public layoutcontrol (which available / settable in designer). because use combination of print(preview) on many fo

c++ - Is it possible to delete a file that is opened by a process under windows? -

for testing , simulation purposes delete file open process. the createfile docs state possible open file in mode ( file_share_delete ) allows file open handle pointing to deleted operation. (and tried , confirmed via createfile(file_share_delete) + deletefile.) what know is, whether possible @ file opened without above mentioned flag deleted somehow? as far understand deletefile docs not possible functions, as the deletefile function fails if application attempts delete file open normal i/o or memory-mapped file. is there other way delete file open, not have file_share_delete flag set? there no way this. the closest way schedule delete on reboot using movefileex target filename of null , , movefile_delay_until_reboot in dwflags parameter.

hotkeys - Define application-wide hot key in mixed wpf/win32 app -

i've got wpf (prism) app, uses whole lot of other wpf assemblies , win32 dlls containing other windows (wpf , win32). when user presses function key (f2-f12) want open spezific program functions. something this: routedcommand commandf4 = new routedcommand(); commandf4.inputgestures.add(new keygesture(key.f4)); application.current.mainwindow.commandbindings.add(new commandbinding(commandf4, callcommandf4)); the problem is: work while mainwindow has focus. if open secondary wpf window (or win32 window) keybinding not apply anymore. is there way add applicationwide global hotkey f4 (or other key)? or @ least wpf-wide hotkey? you can try think write hook keyboard , attached hook listen keyboard messages application's thread. this example inspiration: http://www.codeproject.com/kb/cs/globalhook.aspx . just take note if use .net 4.0 when use setwindowshookex instead of using assembly.getexecutingassembly().getmodules()[0] as hmod param, use: proc

c# - entity framework query -

i' ve got tables: customer, order, product customer has gor lot of orders, each order has got lot wof products. how can write query products customer ? need use datasource, bye var products = customer in customers order in customer.orders product in order.products select product; just use linq selectmany.

c++ - Can I return early from a variable-argument function? -

suppose have 2 c++ functions debug output: void trace( const wchar_t* format, ... ) { va_list args; va_start( args, format ); varargtrace( format, args ); va_end( args ); } void varargtrace( const wchar_t* format, va_list args ) { wchar buffer[1024]; //use ::_vsnwprintf_s format string ::outputdebugstringw( buffer ); } the above uses win32 outputdebugstringw() , doesn't matter. want optimize formatting when there's no debugger attached formatting not done (i measured - speedup significant): void trace( const wchar_t* format, ... ) { if( !isdebuggerpresent() ) { return; } //proceed va_list args; ..... } will fact return once isdebuggerpresent() returns null affect except formatting skipped? i mean no longer call va_start , va_end - matter? skipping va_start , va_end cause unexpected behavior changes? the requirement on return if have used (executed) va_start() , must use va_end() before return

Getting NullPointerException in GWT app but not sure how -

getting uncaught exception escaped java.lang.nullpointerexception: null i getting error when calling private final observerregistrationimpl<events.wordlistevent> wordlistadditionobservers = new observerregistrationimpl<events.wordlistevent>(); public void addwordlists(arraylist<wordlist> wordlists) { for(wordlist wl : wordlists) { gwt.log( "model: adding wordlist: "+wl.getname()); this.wordlists.add(wl); //error happens on line below this.wordlistadditionobservers.notifyobservers(this, new events.wordlistevent(wl)); } } i checked in debug mode , saw wordlistadditionobservers , w1 , this objects. none null. wrong? here observerregistrationimpl class public class observerregistrationimpl<t> implements observable<t> { private list<observer<t>> observers = new arraylist<observer<t>>(); @override public void addobserver(observer<t> o) {

python - How to integrate Redis with SQLAlchemy -

i'm learning use sqlalchemy connected sql database 12 standard relational tables (e.g. sqlite or postgresql). i'd use redis python couple of tables, particularly redis's fast set manipulation. realise redis nosql, can integrate sqlalchemy benefit of session , thread handling sqlalchemy has? is there redis sa dialect? couldn't find it, means i'm missing basic point. there better architecture should @ use 2 different types of database? while possible set orm puts data in redis, isn't particularly idea. orms designed expose standard sql features. many things standard in sql such querying on arbitrary columns not available in redis unless lot of work. @ same time redis has features such set manipulation not exist in standard sql not used orm. your best option write code interact directly redis rather trying use inappropriate abstraction - find code data out of redis quite bit simpler sql code justifies using orm.

php - How to sort by numbers first with Oracle SQL query? -

i have table 'title' field varchar2 , want select rows , sort them first number , alphabet happens. for instance, using simple order title in end: abc def 321 but want this: 321 abc def the weird thing sql developer shows "right" order, numbers first. on app (php using oci8) shows numbers last. not oracle expert, supposed able without altering session with select * my_data sort nlssort(title,’nls_sort=binary_ai’) where can change nls_sort= fit needs (here list of values ) keep in mind docs says force table scan, might beneficial filter them first (but if selecting table scan going use anyway). the reason why sql developer exhibits different behaviour because changes session.

iphone - UITextField identifier to resignFirstResponder -

i working in iphone project, , have uitableview each cell has uitextfield edit information. problem is, if touch textfield keyboard shown , if click on button of navigation controller, need resign keyboard , save new information. idea save in nsmutabledictionary placeholder of textfield key , value indexpath of it. have nsmutabledictionary save key uitextfield , value indexpath. reason is, method textfielddidendedition receive uitextfield parameter , need know field pressed update database. i hope clear. thanks could use key value observing (kvo) on text property of uitextfield automatically update model when it's value changes? see apple's key value observing programming guide more information.

sql server - How would I determine if a varchar field in SQL contains any numeric characters? -

i'm working on project have figure out if given field potentially company name versus address. in taking broad swipe @ it, going under assumption if field contains no numbers, odds name vs. street address (we're aiming 80% case, knowing have done manually). so question @ hand. given table with, sake of simplicity, single varchar(100) column, how find records have no numeric characters @ position within field? for example: "main street, suite 10a" --do not return this. "a++ billing" --should returned "xyz corporation" --should returned "100 first ave, apt 20" --should not returned thanks in advance! sql server allows regex-like syntax range [0-9] or set [0123456789] specified in like operator , can used string wildcard ( % ). example: select * address streetaddress not '%[0-9]%'; the wildcard % @ start of like hurt performance (scans likely), in case seems inevitable. another msdn reference .

c# - How to store HTML code in ASP.NET MVC2 Model -

i have comment model string property this: [column] public string text { get; set; } comment text can have html tags inside (i know it's bad, have to). when update object, mvc 2 escapes html tags. updating method is: [httppost] public actionresult edit(int id=0) { comment comment= id == 0 ? new comment () : commentrepository.comments.first(x => x.id == id); tryupdatemodel(comment); if (modelstate.isvalid) { commentrepository.save(comment); return redirecttoaction("view/" + comment.id); } else { return view(comment); } } how can update comment text without escaping? p.s. have problem column type: when switch column text in sql server express varchar text , updating model fails: the data types text , nvarchar incompatible in equal operator. exception details: system.data.sqlclient.sqlexception: data types text , nva

javascript - window.open with headers -

can control http headers sent window.open (cross browser)? if not, can somehow window.open page issues request custom headers inside popped-up window? i need cunning hacks. can control http headers sent window.open (cross browser)? no if not, can somehow window.open page issues request custom headers inside popped-up window? you can request url triggers server side program makes request arbitrary headers , returns response you can run javascript (probably saying goodbye progressive enhancement) uses xhr make request arbitrary headers (assuming url fits within same origin policy) , process result in js. i need cunning hacks... it might if described problem instead of asking if possible solutions work.

asp.net - Error - Object reference not set to an instance of an object -

when run following code thows following error: "object reference not set instance of object." protected sub createuserwizard1_load(byval sender object, byval e system.eventargs) handles createuserwizard1.load dim sqldata new system.data.sqlclient.sqlconnection("data source=.\sqlexpress;attachdbfilename=|datadirectory|\aspnetdb.mdf;integrated security=true;user instance=true") dim cmdselect new system.data.sqlclient.sqlcommand("select top 1 employeeid a1_admins order id desc", sqldata) dim label11 label = createuserwizard1.createuserstep.contenttemplatecontainer.findcontrol("label11") sqldata.open() dim dtrreader system.data.sqlclient.sqldatareader = cmdselect.executereader() if dtrreader.hasrows while dtrreader.read() label11.text = dtrreader("employeeid") end while end if dtrreader.close() sqldata.close() end sub end class how can fix this? it'

.net - WPF control not displaying in ElementHost in WinForms app -

i have problem wpf control i'm trying host in elementhost in winforms app. control lookless custom control developed in separate test project, wpf app. in there works fine, in winforms app blank grey box elementhost displayed. here's c# code creating, populating, , adding elementhost parent control: // wpf control m_tabhostpanel = new tabhostpanel(); m_elementhost = new elementhost { child = m_tabhostpanel, dock = dockstyle.top, height = 34 }; this.controls.add( m_elementhost ); the parent control contains other winforms controls added , removed @ runtime, needed. these hosted singly dock set dockstyle.fill. thus, every time add 1 send elementhost of z-order make sure renders correctly: m_elementhost.sendtoback(); thus, know i'm not running airspace problem, or that. the 1 thing did wonder this: in original project styles lookless controls merged resource dicti

jquery ui autocomplete - open event (handling no results) -

i wanted use open event return "no results found" when ui == null in firebug looks after open event fired ui list empty if there results. my source xml file i'm attempting: open: function(event,ui) { if( ui.item == null ) { console.log("no results"); } } add autocomplete.js: if(retmatch.length == 0) { var noresult = new array(); noresult[0] = { label: "no results found", title: "no results found", description: "your search did not return results. please refine search criteria. if believe message in error please fill out support case." } return noresult; } to: $.extend

onclick - get information from click on any object in the image in matlab -

Image
i work on image segmentation based on color object.. need user click value on object in order use information (click value)in process. how can value in matlab. 1 can me please. regards i'm not sure if answers question, plot objects (i.e. lines , patches , images , etc.) have buttondownfcn callback execute when press mouse button while pointer on object. here's simple example (using nested functions , function handles ) of how use buttondownfcn callbacks information objects selected. first, save function in m-file: function colorfcn = colored_patches selectedcolor = [1 0 0]; %# default selected color figure; %# create new figure axes; %# create new axes patch([0 0 1 1],[0 1 1 0],'r',... %# plot red box 'buttondownfcn',@patch_callback); hold on; %# add existing plot patch([2 2 4 4],[1 2 2 1],'g',...

c# - how to get nunit results to a database -

hi trying nunit results database while running. need way see if test has passed or failed on teardown can write code insert values database based on if passes or fails. so possible information in teardown if current running test in passing or failing state, information such test name , if has failed reason failure. thanks in nunit @ or post 2.4.4, can testresult happens using eventlisteners - need write results db testfinished method. void testfinished(testresult result); the name of test of recent teststarted call: void teststarted(testname testname); to have implement nunit addin implements eventlisteners interface.

How can I set the location for the cobertura data file when using the cobertura maven plugin? -

i using cobertura maven plugin 2.4. don't see option set location store datafile (cobertura.ser) particular folder. have @ http://jira.codehaus.org/browse/mcobertura-57 arnaud heritier added comment - 09/dec/07 4:16 pm fixed cobertura 1.9 default cobertura.ser file in: ${project.build.directory}/cobertura/cobertura.ser it can changed in plugin config with: <plugin> <artifactid>cobertura-maven-plugin</artifactid> <configuration> <datafile>${basedir}/target/test-harness/check/cobertura.ser</datafile> </configuration> </plugin>

templates - Magento: Building a store URL in CMS-syntax, using a variable -

i building e-mail template. want build url this: http://store.com/path/to/page?shipmentid=123 this code builds correct url: {{store url='path/to/page' _query_shipmentid=123}} but 123 part should dynamic. need pull variable: {{var shipment.id}} is possible? i'm looking this: {{store url='path/to/page' _query_shipmentid=shipment.id}} use $ prefix let magento know variable. code should work: {{store url='path/to/page' _query_shipmentid=$shipment.getid()}}

python - How to retrieve these elements from a webpage? -

i have webpage in html these elements: <div class="content_page"> <a href="/earth" class="nametessera" >earth</a> </div> <div class="content_page"> <a href="/world" class="nametessera" >world</a> </div> <div class="content_page"> <a href="/planet" class="nametessera">planet</a> </div> ... i need retrieve /earth, /world, /planet, etc. need retrieve links of tag class "nametessera". how can python ? short answer: use beautifulsoup parse page, urls , use urlib2 or pycurl download mentioned urls. [edit:] adding on examples below use the href contained in div >>> alldiv = soup.findall('div', { "class" : "content_page" }) >>> div in alldiv: print div.a ... <a href="/earth" class="nametessera">earth</a> &

css - FBML, visible-to-connection, else, extra white space -

on facebook, using fbml box add-on, can create tab contains custom code. 1 of things can hide content people don't "like" , reveal content once click "like" button. done via code: <fb:visible-to-connection> <div class="fan">content fans</div> <fb:else> <div class="no-fan">content non-fans</div> </fb:else> </fb:visible-to-connection> the problem facebook applies visibility:hidden hidden content, means content gone, white space remains. can set margin-top of .no-fan negative value, move content, therefore hiding white space. works quite well. works flawlessly if height of content of .fan equal .no-fan. in case aren't. .fan content longer , therefore once "like" us, bottom image gets cut off (on .fan). seems equivalent of overflow:hidden, taking height of .no-fan content. when force height of .fan content, revealed, when not fan, there white space above .no-fan content. i

cocoa touch - Maintain state in a multi view app -

i have appdelegate initiates view controller switches between 2 uiviews. my question want maintain state. gather done in appdelegate applicationwillterminate. question how access button text , tableview data 2 views , best way persist table data?. to persist current screen, try using nsuserdefaults: [[nsuserdefaults standarduserdefaults] setinteger:0 forkey:klastopenedscreenkey]; for others, if you're using core data store , editing store table data access , modification, long save managedobjectcontext, reloading should take care of itself. make sure save data after modifying store code this: nsmanagedobjectcontext *moc = [self managedobjectcontext]; nserror *error; if (![moc save:&error]) { nslog(@"couldn't save!"); } edit: if you're not in appdelegate, , haven't set managedobjectcontext instance variable, use line of code instead: nsmanagedobjectcontext *moc = [[[uiapplication sharedapplication] delegate] managedobjectcont

iphone - Write some text in (or on) UIStatusBar -

i know, it's strange question ^^, i know if there way write text in (or on) uistatusbar. in particular want write text on status bar when user press uibutton. thanks! i'm not sure if can draw directly status bar, should able draw on top of in custom view. can get status bar's frame using: cgrect statusbarframe = [[uiapplication sharedapplication] statusbarframe]; and can get application's main window (presumably status bar's superview) using: uiwindow *mainwindow = [[uiapplication sharedapplication] keywindow]; you should able add custom view directly key window in status bar's frame. example of app appears "modify" status bar, take @ reeder .

deployment - Visual Studio Setup Project that upgrades an existing app -

is possible make setup project in visual studio *does not install * upgrades app exists on user's disk ? example: user has version 1.1 of product , want send em setup / installer upgrades 1.1 1.2 ? regards, madseb sure. first create installer new version. if old version installed msi package: find old msi upgradecode after building new msi open orca go "property" table , set upgradecode of old msi this way new package should automatically uninstall old one if installed custom package: in new package add custom action removes old version (for example launches old version uninstaller or manually deletes application resources) make sure custom action runs before "installinitialize" action in "installexecutesequence" table (you can edit action sequence orca)

Limit Integration tests run by autotest (Rails) -

i'm using autotest, , have added hooks run integration tests. while working, time make change impacts of integration tests, integration tests rerun. behavior i'd change, if possible. (i'm using rspec webrat tests, no cucumber) with non-integration tests, pattern reruns tests in same spec file (or describe block?) if change test or describing. so, have page_controller.rb , page_controller_spec.rb. autotest knows if change 1 of files, runs tests in page_controller_spec, then, if passes, runs tests. i'd similar integration tests -- run tests in file failing test first, run tests if pass. my .autotest file looks this require "autotest/growl" require "autotest/fsevent" autotest.add_hook :initialize |autotest| autotest.add_mapping(/^spec\/integration\/.*_spec\.rb$/) autotest.files_matching(/^spec\/integration\/.*_spec\.rb$/) end end your .autotest source of problem :) says any file in /spec/integration directory, all

ide - Out of memory error with netbeans and eclipse -

i created c++ project in netbeans , getting out of memory error on ubuntu 10.10. tried increasing heap space in netbeans.conf file. didn't work. same problem eclipse well. can suggest workaround or alternate ides c++ development ? are sure it's ide issue , not programmatic one? did check invalid memory access, memory leaks, doubly freeing memory, using new memory allocation , delete freeing up, thread accessing stack memory of different thread?

asp.net mvc 2 - Getting parameters in controller -

i have url this somesite.com/home/{param1}/{param2}/{param3}/{param4} how define controller's action values of these params? you should able use request("parametername") retrieve value.

Cross-compile for linux on windows -

i've found little info cross-compiling linux binaries in windows, questions opposite situation. has experience or pointers share? i'd prefer mingw on cygwin, if can choose. assume specific linux target available: have include headers , binaries. i haven't done myself, have considered setting virtual machine, , compiling on that? use "network" share, both windows system , linux virtual system can see same directories. virtual machine solution, becomes easier target specific distributions , architectures. best of luck, regardless.

oop - What is the name of this pattern? -

at first called in isnapshotservice, does countrysnapshot snapshot = snapshotservice.createsnapshot<country, countrysnapshot>(country); for work country must this public class country : isnapshottable<countrysnapshot> { public countrysnapshot createsnapshot(isnapshotservice snapshotservice) { } } and countrysnapshot must this public class countrysnapshot : isnapshotfor<country> { } i used name "snapshot" because intended service create immutable snapshots of classes end-of-period snapshot of system accounting purposes. has occurred me result not immutable snapshot, example stocklocation might create stockaudit (which not snapshot.) so, keeping in mind no longer create snapshots need come better names these 3 interfaces. isnapshotservice isnapshottable - country implements indicate can create countrysnapshot isnapshotfor - countrysnapshot implements show created country any suggestion welcome. thanks seems lot memento .

ruby on rails - Mongoid embeds_one form_for path error for new objects -

can have same model class collection resource in 1 , singular resource in other? update !!! i think mongoid issue, editing existing photos works. new throw path errors orm mongoid beta 20 routes.db resources :products resources :photos collection post 'sort' end end end resources :companies resource :photo end photos_controller.rb before_filter find_or_build_photo def find_or_build_photo # these have many photos if !params[:story_id].blank? or !params[:product_id].blank? @photo = params[:id] ? @parent.photos.find(params[:id]) : @parent.photos.build(params[:photo]) end # these have 1 photo if !params[:company_id].blank? @photo = @parent.photo ? @parent.photo : @parent.build_photo(params[:photo]) end end i "undefined method photo_path" etc. errors in view form_for helper. theorie -> because there "photos"-controller , no "photo&qu

Levels in R Dataframe -

i imported data .csv file, , attached dataset. problem: 1 variable in integer form , has 295 levels. need use variable create others, don't know how deal levels. what these, , how deal them? when read in data read.table (or read.csv? - didn't specify), add argument stringsasfactors = false. character data instead. if expecting integers column must have data not interpretable integers, convert numeric after you've read it. txt <- c("x,y,z", "1,2,3", "a,b,c") d <- read.csv(textconnection(txt)) sapply(d, class) x y z ##"factor" "factor" "factor" ## don't want factors, characters d <- read.csv(textconnection(txt), stringsasfactors = false) sapply(d, class) # x y z #"character" "character" "character" ## convert x numeric, , wear nas non numeric data as.numeric(d$x) #[1] 1 na #warning message: #nas

php - How to use tokenized autocomplete on multiple fields without conflicting -

i need run autocomplete script on multiple fields in form. created separate js , php files each field , seems pull values php file ok, when don't have match correctly displays no results, when have match suggestion box disappears in first field. last field works correctly. i'm assuming there var conflict between script instances here , need find way around it. i've tried playing around if else statements in both php file , js file try , use 1 can't work. you can view script @ http://www.erecoverydev.com/autocomplete2/js/jquery.tokeninput.js my php file is: <? mysql_pconnect("localhost", "username", "password") or die("could not connect"); mysql_select_db("mydb") or die("could not select database"); $param = mysql_real_escape_string ($_get["q"]); $query = sprintf("select cb_activities jos_comprofiler cb_activities regexp '^$param'"); $arr = array(); $rs = mysql_query

c# - Generate a printable HMAC Shared key in .Net -

i'm using hmacsha512 hash data using shared key. since key shared i'd printable characters ease of transport. i'm wondering best approach generating these keys. i'm using getbytes() method of rngcryptoserviceprovider generate key, byte array returns contains non-printable characters. i'm wondering if secure base64 encode result or erode randomness , make things less secure? if isn't approach can suggest one? i understand limiting keys printable characters limiting overall breadth of key space (ie: lopping off 1 of 8 bits), ok that. if can handle not auto-generating key http://www.grc.com/passwords source of random key material. base64 wouldn't reduce underlying entropy of byte array. generate key , use in raw form, base64 encode transport need be. you'd base64 decode raw form before use in new location. there no loss of entropy in operation. base64 encoding reduces entropy 6-bits per byte instead of 8, result of coding longer, ove

routes - CakePHP 1.3 Routing problem -

it can't correct route following: router::connect('/ctl/act/subact/:mode/:sort' , array('controller' => 'ctl', 'action' => 'act_subact', 'mode' => null , 'sort' => null)); -- $html->link('go',array('controller'=>'ctl','action'=>'act_subact')) -- <a href="/ctl/act_subact/">go</a> how can do? env:cakephp 1.3.6 php5.2.5 on apache2 the route /ctl/act/subact/:mode/:sort means there must :mode , :sort parameter. route not match url /ctl/act/subact/ . if there optional parameters, need denote asterisk: /ctl/act/subact/* . route match urls /ctl/act/subact/ , /ctl/act/subact/foo , /ctl/act/subact/foo/bar . if need these optional parameters named parameters, you'll need create several routes each possible "length": router::connect('/ctl/act/subact/:mode/:sort', array('controller' =>

PHP HTML DOM Parser -

possible duplicate: how parse , process html php? i'm looking html dom parsers php. i've found php simple html dom parser . there others should looking at? yes. simple html doc fine, order of magnitude slower built in dom parser. $dom = new domdocument(); @$dom->loadhtml($html); $x = new domxpath($dom); foreach($x->query("//a") $node) { $data['dom']['href'][] = $node->getattribute("href"); } use that.

android - Using Cursor with ListView adapter for a large amount of data -

i using custom cursoradapter data sqlite database , show in listview. database contains 2 columns 8.000 rows. looking way query , show data fast possible. have done asynctask here code: private class prepareadapter extends asynctask<void,void,customcursoradapter > { @override protected void onpreexecute() { dialog.setmessage("wait"); dialog.setindeterminate(true); dialog.setcancelable(false); dialog.show(); log.e("tag","posle nov madapter"); } @override protected customcursoradapter doinbackground(void... unused) { cursor cursor = mydbnameshelper.getcursorquerywithallthedata(); madapter.changecursor(cursor); startmanagingcursor(cursor); log.e("time","posle start managing cursor" + string.valueof(systemclock.elapsedrealtime()-testtime)+ " ms"); testtime=systemclock.elapsedrealtime(); madapter.initindexer(cursor); return madapter; } protected void onp