Monday, March 31, 2014

Save DataPackageView.Properties.Thumbnail to disk

How to save DataPackageView.Properties.Thumbnail to disk as .jpg file?

Save DataPackageView.Properties.Thumbnail to disk

Hi,


Try some codes below:




// Lets say the byte array represents the data we want to present as a storage file.
var fileBytes = new byte[200];var streamReference =DataPackageView.Properties.Thumbnail;
// Creating the streamed storage file.
var streamedStorageFile = await StorageFile.CreateStreamedFileAsync("MyFileName.jpg", async stream =>
{
await stream.WriteAsync(fileBytes.AsBuffer());
await stream.FlushAsync();
stream.Dispose();
}, streamReference);

Please refer to the link get more information:


http://ift.tt/1fIFQzX


Best Wishes!




We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.

Click HERE to participate the survey. Thanks<br/> MSDN Community Support<br/> <br/> Please remember to &quot;Mark as Answer&quot; the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.


SSRS Weekly View Calendar empty textboxes

What is the expression for the Subject textbox ? Is it MAX(Fields!Subject.Value) ?


Regards, RSingh


SSRS Weekly View Calendar empty textboxes

Thats because you dont have any data to be diplayed for those days. SInce you're pivoting on day values you'll still get the columns with blank values in them.


Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://ift.tt/19nLNVq http://ift.tt/1iEAj0c


SSRS Weekly View Calendar empty textboxes

No it is just Subject Column which is coming from DataSet


KAdir


Sunday, March 30, 2014

Problem with async method from .NET

I am always getting an empty string from this method:



private static string TranslateRequest(string input, string languagePair)
{
string result = "";
string url = String.Format("http://ift.tt/1pwJ3ZJ;, input, languagePair);

WebClient webClient = new WebClient();
webClient.Encoding = System.Text.Encoding.UTF8;

//HtmlAgilityPack.HtmlDocument document = new HtmlAgilityPack.HtmlDocument();
//document.LoadHtml(result);
//webClient.BaseAddress = url;

webClient.AllowReadStreamBuffering = true;
webClient.DownloadStringAsync(new Uri(url));


webClient.DownloadStringCompleted += (sender, e) =>
{
webClient.CancelAsync();
result = e.Result;
};

return result;
}

When I use this method in console application (in console application I can use synchronous method for downloading string), I get the result, but when I am using this code in Windows Phone 8 application (where I don't have synchronous method for downloading string; this pasted code is from Windows Phone project), I always get the empty string, like something wrong is happening on other thread.


Can anyone test this method in Windows Phone project and see what is the answer for this problem?




Development Technician, Microsoft Certified Professional


Problem with async method from .NET

No use. Still problems with DownloadStringAsync. It downloads nothing and I have checked Uri with debugger and everything is fine.


Can you please create some random Windows Phone project and try it for self?




Development Technician, Microsoft Certified Professional


Problem with async method from .NET


No use. Still problems with DownloadStringAsync. It downloads nothing and I have checked Uri with debugger and everything is fine.



Is this based on the value of e.Result checked inside the DownloadStringCompleted handler?



Is There any difference in Set @Var=ColmnName and Select @Var =Column from Table. I am using it in SSIs for Dynamic Packages

Refer the below links to get a good idea:


http://ift.tt/1gSgEw6


http://ift.tt/1gSgC7i


Camera Capturing Image is Not working in windows 8 apps

Hi,


Would you set the device capability in the app manifest? To enable webcam access, the app must include the Webcam DeviceCapability in the application manifest:


1.In Microsoft Visual Studio, in Solution Explorer, open the designer for the application manifest by double-clicking the package.appxmanifest item


2.Click Capabilities.


3.Check the box for Webcam


See the link below to get more information:

http://ift.tt/1pwJ4x0


Best Wishes!




We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.

Click HERE to participate the survey. Thanks<br/> MSDN Community Support<br/> <br/> Please remember to &quot;Mark as Answer&quot; the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.



Report Builder Wizard and Parameter Creation with values from other data source e.g. data set or views for non-IT users or Business Analysts

Hi Asam,



If we want to create a parameter depend on another dataset, we can additional create or add the dataset, embedded or shared, that has a query that contains query variables. Then use the option that “Get values from a query” to get available values. For more details, please see:http://ift.tt/1gSgBjX

http://ift.tt/MQsaM0



As to the Report Builder features, we can refer to the following articles:http://ift.tt/1pwJ1kB

http://ift.tt/1gSgEfw



Hope this helps.



Thanks,

Katherine Xiong




Katherine Xiong

TechNet Community Support



SharePoint 2010 REST Upload file

I am looking to upload a file into a sharepoint 2010 document library.


1. Must use REST. (listdata.svc). I don't want to use CSOM or any other mechanism.


2. Must use C# (no javascript).


3. if possible, must use Http library only and not any proprietary pre-packages or autogenerated code like DataConext or something.


I want to use pure HTTP Connection, use C# code and use REST end point and upload a document into a document library.




val it: unit=()


SharePoint 2010 REST Upload file

Hello,


You might want to take a look at this link to upload file using rest service:


http://ift.tt/1pwJ285


http://ift.tt/1pwJ288


Although you can also use copy.asmx web service for same purpose.




Hemendra:Yesterday is just a memory,Tomorrow we may never see

Please remember to mark the replies as answers if they help and unmark them if they provide no help


SharePoint 2010 REST Upload file

i have seen these... but they are using the DataContext class provided by .NET.


If I was calling this from a non microsoft platform then I will only have a class called HttpUrlConnection and all REST operators must be done on that rather than on Datacontext.




val it: unit=()


SharePoint 2010 REST Upload file

Hello,


In that case copy.asmx web service will be good option. You can consume this service and upload file in SP without any context.


http://ift.tt/1pwJ0gz


http://ift.tt/1pwJ0gB




Hemendra:Yesterday is just a memory,Tomorrow we may never see

Please remember to mark the replies as answers if they help and unmark them if they provide no help


jQuery-Script only working when WebPart is in Edit Mode

Hi there,



so I developed some custom functionality with SPServices that works fine in my dev-environment. Now Im trying to deploy it in the productive environment and Ive struggled for several hours but cant get it to work.


This is my code: http://ift.tt/1gSgAMX


I insert the code inside of a simple form webpart.

When the webpart / website is in edit mode, the code executes fine.

When its not in edit mode, the jquery functions work, but the spservices functions do not seem to work. I get the error "Das Objekt unterstützt diese Eigenschaft oder Methode nicht." (in english its something like "The object does not support this property or method."). Line number of the error then points to the first occurrence of $.SPServices(). (Firefox Screenshot of Console: http://ift.tt/1pwJ1B8)



I searched nearly the whole Internet and tried different solutions.

I wrapped the $(document).ready(function() {}) like this: ExecuteOrDelayUntilScriptLoaded(function() {}, "sp.js");



And I tried writing the code directly to the webpart page via sharepoint designer. It does not work then either and I even cant enter edit mode.


I found out, that the masterpage-Template is also referencing a jQuery-Instance (v 1.4.2), so I tried disabling the reference in my script, but the result is the same.


I also tried referencing the scripts via absolute URLs, without success.


The references to the scripts seem to work (I can click them in sharepoint designer). I just dont know why it is not working. If you have any further suggestions or have any idea how to tear this problem down, or find out whats maybe causing it, please let me know because Im really clueless right now...



Thank you very much!



"Could not open" error when opening files from Sharepoint library

Check the word and excel services on CA site.


http://ift.tt/1pwIZt7


http://ift.tt/1jF5WqM


"Could not open" error when opening files from Sharepoint library

Hello Corvin,


Is this happening with all libraries or single library? If issue is occurring with all libraries then it seems there is problem with office activeX so please try to repair your office version.


http://ift.tt/1gSgxR9


If you still face same issue then try more suggestion as per this link:


http://ift.tt/1pwIYp6


Let us know your result




Hemendra:Yesterday is just a memory,Tomorrow we may never see

Please remember to mark the replies as answers if they help and unmark them if they provide no help


"Could not open" error when opening files from Sharepoint library

This is happening with all libraries. I'll take a look at your suggestions, thanks

"Could not open" error when opening files from Sharepoint library

Sorry, but I don't see how this is relevant. I'm not the administrator of the instance and I'm not trying to program anything around ShP, just trying to use it.

I want to do text classification and sentiment analysis in windows 8 app in c# language?

I want to do text classification and sentiment analysis in c# for windows 8. I want some opensource libraries for it which can be used in this environment. Can anyone help me?

I want to do text classification and sentiment analysis in windows 8 app in c# language?

Hi,


In windows store app, there is no direct API to text classification and sentiment analysis. You should find 3th part product or you should implement by yourself.


Best Wishes!




We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.

Click HERE to participate the survey. Thanks<br/> MSDN Community Support<br/> <br/> Please remember to &quot;Mark as Answer&quot; the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.


Saving a InMemoryAccessStream as jpg in Windows Store app

Hi,


I am having a InMemoryStream of one JPEG image.


I want to save this stream to local application data folder as a jpeg file.


Searched many of the class's in MSDN could not find the apt one.


Please share the sample code to save InMemoryStream as jpeg file.


Thanks,


Bhash


Saving a InMemoryAccessStream as jpg in Windows Store app

Hi,


The InMemoryRandomAccessStream has a method of GetInputStreamAt which can give you an IInputStream. And Windows.Storage.Stream also includes a DataReader class that you create based on an IInputStream object and then read numerous .NET objects from the stream as well as arrays of bytes.


http://ift.tt/1gRQyJL , http://ift.tt/WXVCkT



DataReader dataReader = new DataReader(inputStream);
await dataReader.LoadAsync((uint)size);
byte[] buffer = new byte[(int)size];
dataReader.ReadBytes(buffer);

Now you have a buffer containing all the read bytes. Then you can now save this buffer to a file http://ift.tt/1gRQz02



var file = await Windows.Storage.ApplicationData.Current.LocalFolder.CreateFileAsync("MyWav.wav", Windows.Storage.CreationCollisionOption.ReplaceExisting);
await Windows.Storage.FileIO.WriteBytesAsync(file, buffer);

Best Wishes!






We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.

Click HERE to participate the survey. Thanks<br/> MSDN Community Support<br/> <br/> Please remember to &quot;Mark as Answer&quot; the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.


scheduled report to be emailed

Hi,

I have a simple ssrs 2012 report which does not use a shared dataset.

It uses a dataset shares in the report.

How can this report be sceduled to run at a certain time and be emailed to someone?

Thanks

scheduled report to be emailed

You need to create a subscription for that


see


http://ift.tt/1rJftCr




Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://ift.tt/19nLNVq http://ift.tt/1iEAj0c


scheduled report to be emailed


You need to create a subscription for that


see


http://ift.tt/1rJftCr




Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://ift.tt/19nLNVq http://ift.tt/1iEAj0c



When I click on new subscription, I get the message as follows:

"subscription can not be created because the credentials used to run the report are not stored.


scheduled report to be emailed

Hi arkiboys,


Just as the error message said, we should use stored credentials security in the report server to connect to data source. When a report runs as a background process, the report server is the agent that executes the report. Because there is no user context in place, the report server must get credential information from the report server database in order to connect to a data source. SSRS requires a Login to connect to the data source to process the report when subscription will be occurring at its scheduled time.


To set the stored credentials in report server, please see the following steps:



  1. Report>Properties> Click on the Data Sources tab and you will see following options:

    • A shared data source

    • A custom data source



  2. Select second one, then click on option “Credentials stored securely in the report server” and provide credential information.

  3. Check the “Use as Windows credentials when connecting to the data source”, we also need to click the Apply the apply the setting to the relevant report, otherwise, the setting we specified would be canceled.




Besides, we can also using the shared data source which is having credential saved into report server.


If there are any other questions, please feel free to ask.


Thanks,

Katherine Xiong


If you have any feedback on our support, please click here.


Katherine Xiong

TechNet Community Support



scheduled report to be emailed

see the screenshots given here


http://ift.tt/1gRQtWg


http://ift.tt/1geSztz




Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://ift.tt/19nLNVq http://ift.tt/1iEAj0c


scheduled report to be emailed


Hi arkiboys,


Just as the error message said, we should use stored credentials security in the report server to connect to data source. When a report runs as a background process, the report server is the agent that executes the report. Because there is no user context in place, the report server must get credential information from the report server database in order to connect to a data source. SSRS requires a Login to connect to the data source to process the report when subscription will be occurring at its scheduled time.


To set the stored credentials in report server, please see the following steps:



  1. Report>Properties> Click on the Data Sources tab and you will see following options:

    • A shared data source

    • A custom data source



  2. Select second one, then click on option “Credentials stored securely in the report server” and provide credential information.

  3. Check the “Use as Windows credentials when connecting to the data source”, we also need to click the Apply the apply the setting to the relevant report, otherwise, the setting we specified would be canceled.




Besides, we can also using the shared data source which is having credential saved into report server.


If there are any other questions, please feel free to ask.


Thanks,

Katherine Xiong


If you have any feedback on our support, please click here.


Katherine Xiong

TechNet Community Support




Hi,

I would like to use the shares datasource. and not the custom data source

HOw is this done please?

scheduled report to be emailed


see the screenshots given here


http://ift.tt/1gRQtWg


http://ift.tt/1geSztz




Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://ift.tt/19nLNVq http://ift.tt/1iEAj0c



Hi,

The second link helped me to setup subscription so I schedule the report to send email but I then get failure sending email. Not sure where to look for detailed error. thanks


scheduled report to be emailed

whats the error you got for subscription?


http://ift.tt/1d3D72F


http://ift.tt/1gRQsBM




Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://ift.tt/19nLNVq http://ift.tt/1iEAj0c


scheduled report to be emailed


whats the error you got for subscription?


http://ift.tt/1d3D72F


http://ift.tt/1gRQsBM




Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://ift.tt/19nLNVq http://ift.tt/1iEAj0c



It says, "Failure sending mail"

scheduled report to be emailed

Hi arkiboys,


We can refer to the blog which is suggested by Visakh to look for the detailed error message. As per my understanding, the first possibility is that maybe you haven’t configure the subscription or doesn’t configured correctly.


Reference:

Configure a Report Server for E-Mail Delivery (Reporting Services)


Hope this helps.


Thanks,

Katherine Xiong


If you have any feedback on our support, please click here.


Katherine Xiong

TechNet Community Support



Generate a alphanumeric id for primary key min 4 digits

It is a very good article,


but does not solve my purpose, according to those logics, i have to create an identiy value first (integer) then pass to UDF to create unique value.


What i want to do is generate a random alphanumeric value first and then insert into the record.


All this is because the current sql server 2012 generates integer auto increment values with huge gaps.


100, 102....

1000,1001, 1002...


sequences also experiences the same issue


thanks


Generate a alphanumeric id for primary key min 4 digits

a1n8e


b24u9


8duv4


it is random alphanumeric


Generate a alphanumeric id for primary key min 4 digits

Random alphanumeric generation:



DECLARE @letters char(36) = 'abcdefghijklmnopqrstuvwxyz0123456789'
SELECT CONCAT(
SUBSTRING(@letters, CONVERT(INT,(ROUND(RAND(CAST(NEWID() AS VARBINARY)) * 36,0,-1))),1),
SUBSTRING(@letters, CONVERT(INT,(ROUND(RAND(CAST(NEWID() AS VARBINARY)) * 36,0,-1))),1),
SUBSTRING(@letters, CONVERT(INT,(ROUND(RAND(CAST(NEWID() AS VARBINARY)) * 36,0,-1))),1),
SUBSTRING(@letters, CONVERT(INT,(ROUND(RAND(CAST(NEWID() AS VARBINARY)) * 36,0,-1))),1))
;
GO 100
/*
2xfs
3uqv
plpv
...
*/

Reference blog:


http://ift.tt/1hPhR2w





Kalman Toth Database & OLAP Architect SELECT Video Tutorials 4 Hours

New Book / Kindle: Exam 70-461 Bootcamp: Querying Microsoft SQL Server 2012





Setting design time data for a binding that uses a value converter

Hi,


I am trying to set up sample data to be used while I design a UI. I have successfully achieved this by using the tools in blend to create sample data based on my ViewModel.


For simple bindings this has worked perfectly, but I can not figure out how to set up the sample data to display when a value converter is used.


The bindings (even with converters) all work perfectly at run time.


I decided that copying my code here probably wouldn't help but if there is anything you need or want to see, let me know!


Any help anyone could offer would be great and thanks in advance.


Daniel


Return a Value from a Task

hello,


i'm trying to retreive data from a Task via a web service but it generate an error while that


it execute the asynchro function but can't retreive data with Task.result


How can i fix it


thanks for advance


Return a Value from a Task

i used this but it genetrate an error while retreiving data



void async SomeMethod()
{
ServiceClient proxy = new ServiceClient();
Task<T> results = await proxy.CallAsync(param1, param2);
T result = results.Result;// here it generates the error
if (result.Success)
{
// Do something with result
}
}

Return a Value from a Task

await will unwrap the task and reads it return. if there is something went wrong the exception will be throw. so your code will look more like this:



void async SomeMethod()
{
try
{
ServiceClient proxy = new ServiceClient();
var results = await proxy.CallAsync(param1, param2);
// Do something with result
}
catch
{
//exception handling
}
}






Microsoft Certified Solutions Developer - Windows Store Apps Using C#


excludes few special characters in Regex.

this doesn't except numbers at beginning


explosion spritesheet is not working

Hi,


I want to do a simple explosion on a collision.Here is my code..



public explosion(Texture2D newTexture, Vector2 newPosition)
{
texture = newTexture;
position = newPosition;
timer = 0f;
interval = 40f;
currentFrame = 1;
spriteWidth = 60;
spritHeight = 60;
isVisible = true;
}


public void Update(GameTime gameTime)
{
timer += (float)gameTime.ElapsedGameTime.TotalMilliseconds;
if (timer > interval)
{
currentFrame++;
timer = 0f;
}
if (currentFrame == 32)
{
isVisible = false;
currentFrame = 0;
}
sourceRect = new Rectangle(currentFrame * spriteWidth, 0, spriteWidth, spritHeight);
origin = new Vector2(sourceRect.Width/2, sourceRect.Height / 2);
}
public void Draw(SpriteBatch spriteBatch)
{
if (isVisible == true)
{

spriteBatch.Draw(texture, position, sourceRect, Color.White, 0f, origin,1.0f, SpriteEffects.None,0);

}
}



during collision I am loading like this--



foreach (Enemy e in this.em.Enemies)
{
if (i.BoundingRectangle.Intersects(e.BoundingRectangle))
{
explList.Add(new explosion(cm.Load<Texture2D>("Exp"), new Vector2(e.position.X, e.position.Y)));
e.OnHit();
}
}



problem is instead of appearing one by one frames,frames are moving to the right side one by one in the rectangle.I am totally new to XNA .Pls help...........




dj_Fox


explosion spritesheet is not working

For XNA questions, this is the better forum:


http://ift.tt/1iOkHbd


One thing you needto understand about XNA is that the update function will be called a unknown amount of times per second. It could be 2 times or 120 times or anything in between. And it might varry during execution.

If you want stable movement/animation/etc, you have to actually count how much time passed since a button was first pressed/an animation first started. And only do something in those Update calls where the time has passed.




Let's talk about MVVM: http://ift.tt/1fpEgna Please mark post as helpfull and answers respectively.


How to test async function with Unit test

change it to:



[TestMethod]
public void TestDeleteFile()
{
Assert.IsTrue(DataAccess.RemoveUnitFile("Units").Result);
}





Microsoft Certified Solutions Developer - Windows Store Apps Using C#


The Best Place For Loops?

I have a C# program in which it runs a form, and in the form it checks for information constantly to a server. So after the user logs in, I want to close the form, but I don't want the loop to stop. I get this weird bug where I make the new form show the information of the account, but it stops half way, and gives the circling icon when you hover over it and the login form never closes. I am positive its the loop. I want to have the loop in the Program.cs, But if I do that I have a difficult time gathering data from the form.


So, I was wondering if I could still have it run even if its closed, or can someone teach me how to gather information from a form from the Program.cs?


The Best Place For Loops?

You want to make an application wide resource - the data wich is regulary polled by a for loop and the for-loop itself should be a class instance that all forms share/is idependant of any form.

Unlike WPF, WinForms never got a proper support for Application wide varriables, so you have to create a fix with a static class:


http://ift.tt/1gd31Si


http://ift.tt/1gPTUwM


A more advanaced technique would be to have one non-static class for the data and the loop. Plus a second, static class that can hold multiple instances (each in a seperate field) of this data/loop class. That way you can have application wide resources without running into normal limitations of static.

There are otehr appraoches like Singleton Pattern or jsut relaying the isntance via the a overloaded Constructor.


Change Notification might be worth a look for this, as it simplyfies cases where you have many stakeholders in changes to a value/property:

http://ift.tt/KE9HyP




Let's talk about MVVM: http://ift.tt/1fpEgna Please mark post as helpfull and answers respectively.



sharepoint 2010 wcf using rest api for list item insert

Check below links for Integration of WCF REST service in SharePoint, its a step by step guide for SharePoint 2013 but it will also be useful for SharePoint 2010.


Document: Integration of HTTP/ HTTPs WCF Services (REST & SOAP) in SharePoint 2013


Code: WCF REST Service Integration in SharePoint 2013


There is no transactions in SharePoint Object model like ADO.NET but once you submitted data from your page, then it will goes to server for further proceedings. So insert in looping will working but if their if code throw any exception then it will stop inserting.




Adnan Amin MCT, SharePoint Architect | If you find this post useful kindly please mark it as an answer.


Copy Data From OdbcConnection to SQLStatment Thru C# Code




protected void Button1_Click(object sender, EventArgs e)
{
this.cn = new OdbcConnection();
this.Jda_Cmd = new OdbcCommand();
this.Jda_Cmd.Connection = this.cn;
this.cn.ConnectionString = "DSN=Imports_Img;UserID=user2;Password=pass2;Data Source=172.16.4.5;Transport Product=Client Access;SSL=DEFAULT;DEFAULT COLLECTION='BINDAWOOD'";
string str = ("SELECT ibhand FROM MM410LIB.INVBAL WHERE INUMBR = 79610 AND ISTORE=14");
this.Jda_Cmd.CommandText = str;
{
this.cn.Open();

OdbcDataReader reader2 = this.Jda_Cmd.ExecuteReader();
//connection2.Open();
while (reader2.Read())
{
this.DB_Cmd = new SqlCommand();
this.DB_Cmd.Connection = this.DB_cn;
SqlConnection connection2 = new SqlConnection();
SqlCommand db_cn = new SqlCommand ("insert into invbaldb ('sku') values ('" + reader2[0] + "')", connection2);
//SqlCommand command2 = new SqlCommand("insert into invbaldb ('sku') values ('" + reader2[0] + "')", connection2);
//DB_cn.ExecuteNonQuery();
db_cn.ExecuteNonQuery();
}
reader2.Close();
//connection2.Close();
}
}

I want to copy my data from OdbcConnection to SqlStatment thru C# code. Thru one button I want to do this...

I'm not much expert in c# but just little bit programming, can some one add/edit some codes our statement/help so i can complete my program.



I do thru this code but data is not fetching....

Copy Data From OdbcConnection to SQLStatment Thru C# Code

Try bulkcopy


http://ift.tt/1kKIdpW




jdweng


Can we access same function in c# dataaccess layer in different thread

Hi,


In my code actually three thread are there. three threads accessing one function in dataaccess layer.Based on the parameter passing from thread different stored procedure will execute in data access layer and will return list collection from data access layer.Recently I heard about dead lock. Please advice if any chances are there in my above situation.


Trying to join two views that have different column types

I suggest to JOIN two views based on varchar column rather than trying to get varchar into integer, e.g.


from View1 INNER JOIN View2 ON View1.Region_City =


RIGHT('0000'+CAST(View2.Region as varchar(4)),4) + RIGHT('0000' + CAST(View2.City as varchar(4)),4)




For every expert, there is an equal and opposite expert. - Becker's Law





My blog




My TechNet articles


Trying to join two views that have different column types

Please share your complete script and function definition to help better.

Same StoredProcdure giving different results at different time

Everyone is right, we only can guess and I'm trying to do it. You say from sunday toi saturday grouped by month but in this case how do you handle the differents months/week? I mean, a month can start and finish on Wedsneday, Friday, Thursday...etc.


It could be this the issue?


Can Execute Report But Fails in Query Builder

I was able to track down the problem:


As it turns out, I was using STROTOSET and CONSTRAINED when the parameters do not allow multiple values.


I made the change in the MDX and everything looks good! Still not sure how the original query works in the report but fails in Query Builder...go figure!


Thanks anyway...!




A. M. Robinson


SQL Server 2008 R2- SSRS - Data dissapears and columns hide or switch places

How are you utilizing existing tablix to add a new tablix ?


Post the design structure of the report. Is there any report parameter associated with tablix ?




Regards, RSingh


How does Check Names in the Target Audience picker work?

Can anyone tell me how the Check Names button in the Target Audience picker works? We are having problem with a specific audience in one of our web applications. I don’t think the problem is the actual audience though:


The Target Audience is a global target audience named ”XYZ”. It is compiled and contains member. When an article is tagged with this audience all works fine as long as we use the Audience Picker dialog. But, when using the Check Name button the audience is not saved. This happens when I edit properties on the article (not customized UI) and also when I edit the article in a customized UI. No ULS messages.


I have read that the Target Audience Picker searches for matches in AD Distribution groups, SharePoint groups and Global Audiences. When we write “XYZ” in the audience field and presses the Check Names button one suggestion is displayed, named “XYZ”. When I write “XYZ N” and press the Check Names button several suggestions are displayed: 4 “XYZ” and a couple of other suggestions “XYZ xx…” etc. We have no SharePoint groups starting with “XYZ”, we have no AD Distribution Groups starting with “XYZ”, and we have only one Global Audience starting with “XYZ”. Where are all the “XYZ” suggestions coming from? Can anyone help, please?


We are using SharePoint 2010.


Best regards Heidi Lillebuen


Dynamically insert the database name in the connection string

Hi,


I want to enable the usr to insert the name of the database. Than this name I want to use in the connection string in this format



string connString = @"
server = server1;
integrated security = false;
database = the inserted databaseName by the user //??
user id = user;
password = password;

Can anybody help me please?


Thanks




Dynamically insert the database name in the connection string


I want to enable the usr to insert the name of the database. Than this name I want to use in the connection string in this format



string connString = @"
server = server1;
integrated security = false;
database = the inserted databaseName by the user //??
user id = user;
password = password;



Again, just build the string in steps as needed.



Assuming that you really *want* to keep the newlines and spaces that your example will

create because of the @" then you can do something like this:



Console.Write("Enter database name: ");
string dbn = Console.ReadLine();

string connString = @"
server = server1;
integrated security = false;
database = "
+ dbn + @";
user id = user;
password = password;";
Console.WriteLine(connString);

Sample input/output:



Enter database name: My database

server = server1;
integrated security = false;
database = My database;
user id = user;
password = password;

- Wayne



Dynamically insert the database name in the connection string

thanks a lot

How to Group discontinued time periods

Hi Erland:


Thanks and it worked. Really appreciated your help.


Cheers


Johnny


SQL Server 2008 R2- SSRS - Data dissapears and columns hide or switch places

How are you utilizing existing tablix to add a new tablix ?


Post the design structure of the report. Is there any report parameter associated with tablix ?




Regards, RSingh


CATALOG TABLE IN SSRS

Hi,


Kindly provide the purpose of using the Catalog table in reportserver DB.


Thanks,

Sandy


Access HTML Control in Code Behind without using runat=server

great Sir, Hats Off, it took me whole day to solve this puzzle.

Saturday, March 29, 2014

explosion spritesheet is not working

Hi,


I want to do a simple explosion on a collision.Here is my code..



public explosion(Texture2D newTexture, Vector2 newPosition)
{
texture = newTexture;
position = newPosition;
timer = 0f;
interval = 40f;
currentFrame = 1;
spriteWidth = 60;
spritHeight = 60;
isVisible = true;
}


public void Update(GameTime gameTime)
{
timer += (float)gameTime.ElapsedGameTime.TotalMilliseconds;
if (timer > interval)
{
currentFrame++;
timer = 0f;
}
if (currentFrame == 32)
{
isVisible = false;
currentFrame = 0;
}
sourceRect = new Rectangle(currentFrame * spriteWidth, 0, spriteWidth, spritHeight);
origin = new Vector2(sourceRect.Width/2, sourceRect.Height / 2);
}
public void Draw(SpriteBatch spriteBatch)
{
if (isVisible == true)
{

spriteBatch.Draw(texture, position, sourceRect, Color.White, 0f, origin,1.0f, SpriteEffects.None,0);

}
}



during collision I am loading like this--



foreach (Enemy e in this.em.Enemies)
{
if (i.BoundingRectangle.Intersects(e.BoundingRectangle))
{
explList.Add(new explosion(cm.Load<Texture2D>("Exp"), new Vector2(e.position.X, e.position.Y)));
e.OnHit();
}
}



problem is instead of appearing one by one frames,frames are moving to the right side one by one in the rectangle.I am totally new to XNA .Pls help...........




dj_Fox


Dynamically insert the database name in the connection string

Hi,


I want to enable the usr to insert the name of the database. Than this name I want to use in the connection string in this format



string connString = @"
server = server1;
integrated security = false;
database = the inserted databaseName by the user //??
user id = user;
password = password;

Can anybody help me please?


Thanks




Dynamically insert the database name in the connection string


I want to enable the usr to insert the name of the database. Than this name I want to use in the connection string in this format



string connString = @"
server = server1;
integrated security = false;
database = the inserted databaseName by the user //??
user id = user;
password = password;



Again, just build the string in steps as needed.



Assuming that you really *want* to keep the newlines and spaces that your example will

create because of the @" then you can do something like this:



Console.Write("Enter database name: ");
string dbn = Console.ReadLine();

string connString = @"
server = server1;
integrated security = false;
database = "
+ dbn + @";
user id = user;
password = password;";
Console.WriteLine(connString);

Sample input/output:



Enter database name: My database

server = server1;
integrated security = false;
database = My database;
user id = user;
password = password;

- Wayne



Beginning form problems

Hello all,


I am currently in my first semester of C# programming and just starting the form portion. Our assignment was to turn a rock, paper scissors console game developed earlier in the semester and turn it into a forms app. I have most of it operational, however, no matter the outcome, the draw label appears instead of the win or lose label. Not sure if it is an if, else if problem or what. Also I have been researching, but can not find anything to help me reset the game to play again. If you could look at my code and offer suggestions where to start or where i am going wrong it would be appreciated.



using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace RockPaperScissors

{
public partial class rockPaperScissors : Form
{
public rockPaperScissors()

{
InitializeComponent();
int compChoice;
Random randomNumber=new Random();

compChoice = randomNumber.Next(0, 3);

switch (compChoice)
{
case 0:

pbCompChoice.Image = Properties.Resources.rock;

break;

case 1:

pbCompChoice.Image = Properties.Resources.sillouttepaper;

break;
case 2:

pbCompChoice.Image = Properties.Resources.scirrorssilloutte;

break;

}
}//End Rock Paper Scissors







private void pbRock_Click(object sender, EventArgs e)
{
pbYourChoice.Image = Properties.Resources.rock;
PlayGame();
pbCompChoice.Visible = true;
}

private void pbPaper_Click(object sender, EventArgs e)
{
pbYourChoice.Image = Properties.Resources.sillouttepaper;
PlayGame();
pbCompChoice.Visible = true;
}

private void pbScissors_Click(object sender, EventArgs e)
{
pbYourChoice.Image = Properties.Resources.scirrorssilloutte;
PlayGame();
pbCompChoice.Visible = true;
}//End pbRock Click

public void PlayGame()
{
if ((pbYourChoice == pbPaper && pbCompChoice == pbRock) || (pbYourChoice == pbRock && pbCompChoice == pbScissors) || (pbYourChoice == pbScissors && pbCompChoice == pbPaper))
{
lblWin.Visible=true;
}

else if ((pbYourChoice == pbScissors && pbCompChoice == pbPaper) || (pbYourChoice == pbPaper && pbCompChoice == pbScissors) || (pbYourChoice == pbRock && pbCompChoice == pbPaper))
{
lblLose.Visible = true;
}

else
{
lblPush.Visible = true;
}

bttnPlayAgain.Visible = true;
}

private void bttnPlayAgain_Click(object sender, EventArgs e)
{
//pbYourChoice.Visible = false;
//pbCompChoice.Visible = false;
//new Random();

bttnPlayAgain.Visible=false;
}





Beginning form problems

A created a new method startGame which will be called in the constructor class and in the PlayAgain event.



using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace RockPaperScissors
{
public partial class rockPaperScissors : Form
{
public rockPaperScissors()
{
InitializeComponent();
startGame();
}//End Rock Paper Scissors


private void startGame()
{
int compChoice;
Random randomNumber = new Random();

compChoice = randomNumber.Next(0, 3);

switch (compChoice)
{
case 0:

pbCompChoice.Image = Properties.Resources.rock;

break;

case 1:

pbCompChoice.Image = Properties.Resources.sillouttepaper;

break;
case 2:

pbCompChoice.Image = Properties.Resources.scirrorssilloutte;

break;

}


}




private void pbRock_Click(object sender, EventArgs e)
{
pbYourChoice.Image = Properties.Resources.rock;
PlayGame();
pbCompChoice.Visible = true;
}

private void pbPaper_Click(object sender, EventArgs e)
{
pbYourChoice.Image = Properties.Resources.sillouttepaper;
PlayGame();
pbCompChoice.Visible = true;
}

private void pbScissors_Click(object sender, EventArgs e)
{
pbYourChoice.Image = Properties.Resources.scirrorssilloutte;
PlayGame();
pbCompChoice.Visible = true;
}//End pbRock Click

public void PlayGame()
{
if ((pbYourChoice == pbPaper && pbCompChoice == pbRock) || (pbYourChoice == pbRock && pbCompChoice == pbScissors) || (pbYourChoice == pbScissors && pbCompChoice == pbPaper))
{
lblWin.Visible = true;
}

else if ((pbYourChoice == pbScissors && pbCompChoice == pbPaper) || (pbYourChoice == pbPaper && pbCompChoice == pbScissors) || (pbYourChoice == pbRock && pbCompChoice == pbPaper))
{
lblLose.Visible = true;
}

else
{
lblPush.Visible = true;
}

bttnPlayAgain.Visible = true;
}

private void bttnPlayAgain_Click(object sender, EventArgs e)
{
//pbYourChoice.Visible = false;
//pbCompChoice.Visible = false;
//new Random();

bttnPlayAgain.Visible = false;
startGame();
}
}

}









jdweng


Beginning form problems

Thanks for the help. That helped fix the play again problem, but no joy in the label issue. Any other ideas? I have messed with trying to assign each choice as an variable, but then none of the other methods can use them. I have kind of deduced that it is a problem in my if, else if statements that are not being met so it is always resorting to the else portion, but I have ran out of ideas. Any suggestions would be appreciated.

Beginning form problems

no joy in the label issue. Any other ideas? ... I have kind of deduced that it is a problem in my if, else if statements that are not being met so it is always resorting to the else portion ...

The way to confirm or eliminate that possibility is the set a breakpoint at the first if()

and step through the code examining the path taken and the contents of the relevant variables.



As to the labels, I notice that you appear to be setting their visibility to true but I don't

see any place that you're making their visibility false. Is that correct?



Typically, if you want only one to be visible at a given time then you would set its visibility

to true and set all of the others to false.



- Wayne


Beginning form problems

I have set all of their visible properties to false in the properties windows when I created the labels, so that they would only become visible during the if statements.

Beginning form problems

I have set all of their visible properties to false in the properties windows when I created the labels, so that they would only become visible during the if statements.

That's fine for the initial execution of that code, but once you have set the visibility to

true it will stay that way until either the program is restarted or you set it back to false.



So if you execute that code multiple times in one execution of the program you will eventually

have more than one visible.



- Wayne


Beginning form problems

Thanks i tried it that way and still no luck. I also tried this with no luck either. I am trying to figure it out, just not familiar enough I guess.


if ((pbYourChoice.Image == Properties.Resources.sillouttepaper && pbCompChoice.Image == Properties.Resources.rock) || (pbYourChoice.Image == Properties.Resources.rock && pbCompChoice.Image == Properties.Resources.scirrorssilloutte) || (pbYourChoice.Image == Properties.Resources.scirrorssilloutte && pbCompChoice.Image == Properties.Resources.sillouttepaper))
{
lblWin.Visible = true;
}

else if ((pbYourChoice.Image == Properties.Resources.scirrorssilloutte && pbCompChoice.Image == Properties.Resources.rock) || (pbYourChoice.Image == Properties.Resources.sillouttepaper && pbCompChoice.Image == Properties.Resources.scirrorssilloutte) || (pbYourChoice.Image == Properties.Resources.rock && pbCompChoice.Image == Properties.Resources.sillouttepaper))
{
lblLose.Visible = true;
}

else
{
lblPush.Visible = true;
}

bttnPlayAgain.Visible = true;


Beginning form problems

i tried it that way and still no luck. I also tried this with no luck either. I am trying to figure it out, just not familiar enough I guess.



Have you set a breakpoint and followed the logic flow and examined the contents of variables

as I suggested earlier? Use the debugger, it's your friend in cases such as this.



- Wayne



How to fix the error: “Extender controls may not be registered after prerender” when add multi user controls

I have a Admin page. In this page, I have a div, that will contain 2 user controls in it. The Manager.aspx file like that:



<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="Manager.aspx.cs" Inherits="Admin.Manager" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
<title>Admin Manager</title>
</asp:Content>
<asp:Content ID="Content5" ContentPlaceHolderID="contentRight" Runat="Server">
<div class="grid_16" runat="server" id="divUserControl"></div>
</asp:Content>

In code behind of Manager.aspx.cs, I will add dynamically user controls like that:



protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
var userControls = new List<Control> {};
var userManager = TemplateControl.LoadControl("~/MyControls/UserManager.ascx");
userControls.Add(userManager);
var roleManager= TemplateControl.LoadControl("~/MyControls/RoleManager.ascx");
userControls.Add(roleManager);
Sessions.UserControl = userControls;
}
SelectControl();
}

private void SelectControl()
{
var userControls = Sessions.UserControl;
divUserControl.Controls.Clear();
if (!string.IsNullOrEmpty(Request.QueryString["uc"]))
{
var query = int.Parse(Request.QueryString["uc"]);
switch (query)
{
case 1:

divUserControl.Controls.Add(userControls[0]);
break;
case 2:
divUserControl.Controls.Add(userControls[1]);
break;
default:
divUserControl.Controls.Add(userControls[0]);
break;
}
}
else
{
divUserControl.Controls.Add(userControls[1]);
}
}

I had searched google to find solution, and insert the code below in the Manager.aspx.cs:



protected override void OnPreRender(EventArgs e)
{
base.OnPreRender(e);
SelectControl();
}

Or the solution:



protected override void OnInit(EventArgs e)
{
base.OnInit(e);
if (this.DesignMode == true)
{
this.EnsureChildControls();
}
this.Page.RegisterRequiresControlState(this);
}

in the user control UserManager.ascx.cs.


But It's still raise error.



Extender controls may not be registered after PreRender.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.InvalidOperationException: Extender controls may not be registered after PreRender.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:


[InvalidOperationException: Extender controls may not be registered after PreRender.]
System.Web.UI.ScriptControlManager.RegisterExtenderControl(TExtenderControl extenderControl, Control targetControl) +349151
System.Web.UI.ScriptManager.RegisterExtenderControl(TExtenderControl extenderControl, Control targetControl) +69
System.Web.UI.ExtenderControl.RegisterWithScriptManager() +143
System.Web.UI.ExtenderControl.OnPreRender(EventArgs e) +19
AjaxControlToolkit.ExtenderControlBase.OnPreRender(EventArgs e) in f:\TeamCity\buildAgent\work\80acd78aa4c25314\Server\AjaxControlToolkit\ExtenderBase\ExtenderControlBase.cs:365
System.Web.UI.Control.PreRenderRecursiveInternal() +80
System.Web.UI.Control.PreRenderRecursiveInternal() +171
System.Web.UI.Control.PreRenderRecursiveInternal() +171
System.Web.UI.Control.PreRenderRecursiveInternal() +171
System.Web.UI.Control.PreRenderRecursiveInternal() +171
System.Web.UI.Control.PreRenderRecursiveInternal() +171
System.Web.UI.Control.PreRenderRecursiveInternal() +171
System.Web.UI.Control.PreRenderRecursiveInternal() +171
System.Web.UI.Control.PreRenderRecursiveInternal() +171
System.Web.UI.Control.PreRenderRecursiveInternal() +171
System.Web.UI.Control.PreRenderRecursiveInternal() +171
System.Web.UI.Control.PreRenderRecursiveInternal() +171
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +842


How to fix the error: “Extender controls may not be registered after prerender” when add multi user controls

ASP.Net questions are best asked in the ASP.Net Forum, wich is totally seperate from this one:


http://forums.asp.net/


But maybe the page-lyfecycle will make waht happesn a bit clearer (it's a very important thing to udnerstand in ASP):


http://ift.tt/KE9CLu




Let's talk about MVVM: http://ift.tt/1fpEgna Please mark post as helpfull and answers respectively.



TextBox should refresh after clicking on it.

Please specify wich Display Technology you use (WinForms, WPF, ASP.Net). In general, Texboxes have Events for gain/loss of Focus (with wich the keyboard cursor is meant) that yo could use:


http://ift.tt/P4PfeG


http://ift.tt/1fz4VgC


Note that loss of focus is generally more important - you want to validate, recalculate, parse input and the like when the Focus is lost, not when it is gained.




Let's talk about MVVM: http://ift.tt/1fpEgna Please mark post as helpfull and answers respectively.



About this thread

Yep..Seems a little strange to me too!


Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://ift.tt/19nLNVq http://ift.tt/1iEAj0c


About this thread

Its strange!!, I too not able to see that marked within.

About this thread

It is a corrupted thread.


2 hours later....it looks like the thread has been fixed.





Kalman Toth Database & OLAP Architect SELECT Video Tutorials 4 Hours

New Book / Kindle: Exam 70-461 Bootcamp: Querying Microsoft SQL Server 2012









About this thread

Thank you everyone for looking into this.


Finally. It seems to be ok.




Regards, RSingh


Problem with OleDBConnection and WindowForm

Hi bonnie,


your blog is very usefull thx you for that :D When i said bugged i had in mind that forms changes their sizes to lower and elements like textboxes and buttons looks so much messy i mean not like in designer in VS 2k13. All loks good until i open connection.


Here are screens, i cant [img] them. Look at textbox 3:


http://ift.tt/1iLGCja


And here are screens from forms resizes:


before connect:


http://ift.tt/1hlKWWA


After:


http://ift.tt/1iLGErq


I rly dont know what is reason why it changes sizes and bug other elements always after OledBconnection.open() even if connection fail.


Again ty for help :)


Problem with OleDBConnection and WindowForm

I'm glad my blog post helped you with one problem, but I'm afraid I won't be much help with your other one. In your first screenshot, I can see the problem with the third label and textbox. Probably your spacing is just a few pixels different than your other label/textbox combinations and it just doesn't show up in the IDE (the Designer).


As for your other problem ... I don't see any difference, other than the screen being a little larger overall ... unless that's just because of the way you captured the screenshot.




~~Bonnie DeWitt [C# MVP]


http://ift.tt/1bPbIRj


Friday, March 28, 2014

How to delete Redundant Record but keep one as it is among Redundant records

Try the below method:



create Table Test(Col1 int,Col2 int)
Insert into test Values
(1,1),(1,2),(1,3),(1,3),(1,4)

Select * From test

--First test the value as below
;with cte as
(Select *,Row_Number()over(partition by Col1,Col2 order by Col1,Col2 asc) Rn
From test
)Select * From cte where rn=1

--Actual delete after confirming your data
;with cte as
(Select *,Row_Number()over(partition by Col1,Col2 order by Col1,Col2 asc) Rn
From test
)Delete From cte where rn>1

Select * From test

Drop table test


SSRS Data SOurce Test Conection error

Hi All,


I have SQL 2012 SSRS installed. When iam trying to Use DataSource type as Oracle from BIDS test connection is succesful.


But when i test the connection in report manager iam getting a error. Please help.


The error is





Attempt to load Oracle client libraries threw BadImageFormatException.
This problem will occur when running in 64 bit mode with the
32 bit Oracle client components installed.


SSRS Data SOurce Test Conection error

see if this helps


http://ift.tt/1dTq8RU


http://ift.tt/1rJwP29


As I understand you need to have 32 bit SSRS to run it




Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://ift.tt/19nLNVq http://ift.tt/1iEAj0c



SQL query related...

I don't have idea about linq but you achive it using dt.Select as





string id;
string dtDate;

DataRow[] maxRow = dt.Select("Column1 = MAX(Column1)");

If (maxRow.Length > 0)
{
id = maxRow[0]["Column1"].ToString();
dtDate = maxRow[0]["Column2"].ToString();
}







Ashish Pandey


SQL query related...


var table = new DataTable();
table.Columns.Add("Column1", typeof(int));
table.Columns.Add("Column2", typeof(DateTime));
table.Rows.Add(6565, DateTime.UtcNow.AddDays(6565));
table.Rows.Add(1212, DateTime.UtcNow.AddDays(1212));
table.Rows.Add(8514, DateTime.UtcNow.AddDays(8514));

var maxColumn1 = table.AsEnumerable().Max(x => x.Field<int>("Column1"));
var results = table.AsEnumerable().Where(x => x.Field<int>("Column1") == maxColumn1);



The last two lines can be consolidated, but will leave that exercise to you.

SQL query related...

While applying the above sample I get the following error:


Error 6 'System.Data.DataTable' does not contain a definition for 'AsEnumerable' and no extension method 'AsEnumerable' accepting a first argument of type 'System.Data.DataTable' could be found (are you missing a using directive or an assembly reference?)D:\Project...


Please suggest why it says so.


SQL query related...

AsEnumberable() is an extension method of System.Data.DataTable. It is found in the Assembly System.Data.DataSetExtensions.dll. This assembly should be registered in your GAC. All you need to do is add a reference to this assembly in your project and you should be good.


This assembly contains other helpful functions such as AsDataView which turns a DataTable into a DataView and CopyToDataTable which copies a set of DataRows to the specified DataTable.


Cheers,

Rob


SQL query related...

Thanks alot, the error is resolved.


Regards,


Naureen


SQL query related...

Thankyou for your help.


I have tried to implement it as it is and it works.


But When I try to do it on my actual data table it gives me error (Missing operand after operator).


Actually my column names are a bit complicated such as:


ABC$B/XYZ/04-45$ABC-XYZ$ABC XYZ (its a column name)


so when I apply it:


DataRow[] maxRow = dt.Select("ABC$B/XYZ/04-45$ABC-XYZ$ABC XYZ = MAX(ABC$B/XYZ/04-45$ABC-XYZ$ABC XYZ)");


It raises the exception (Missing operand after operator).


Please guide me how to correct this error.


Also is it possible that I can give column index instead of column name in the above select query?


Hope to see your reply soon.


Regards,


Naureen.


SQL query related...

Try this


Put [ before column name and ] after column name.



string id;
string dtDate;

DataRow[] maxRow = dt.Select("[Column1] = MAX([Column1])");

If (maxRow.Length > 0)
{
id = maxRow[0]["Column1"].ToString();
dtDate = maxRow[0]["Column2"].ToString();
}





Ashish Pandey



C# constructor Object reference not to set an instance of an object

HI I am trying to use web api in order to return custom json response keys. For this i have return a custom class to return json response

Custom Class:



using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Net.Http.Formatting;
using System.Web;
using MvcApplication1.Models;
using Newtonsoft.Json.Serialization;

namespace MvcApplication1.Generic
{
public class JsonResponseHandler
{

public static Dictionary<string, List<Dictionary<string, string>>> rootDictionary;

public static JsonMediaTypeFormatter formatter;


static JsonResponseHandler()
{


// TODO: Complete member initialization

Dictionary<string, string> responseDictionary = new Dictionary<string, string>()
{
{ "status", "true"}, { "error_code", "200"}, { "message", "not found"}, { "request-_type", "login"}

};
//Response Array
List<Dictionary<string,string>> responseArray= new List<Dictionary<string,string>>();

responseArray.Add(responseDictionary);


//Data objects array
IList<Person> result = new List<Person>();
result.Add(new Person
{
Name = "Ugo",
DOB = DateTime.Now,
Address = "Lattanzi",
});
result.Add(new Person
{
Name = "adfasdf",
DOB = DateTime.Now,
Address = "asdfasdf",
});




List<Dictionary<string,string>> dataDictionariesArray= new List<Dictionary<string,string>>();

//Converting dataobjects to dictionary
foreach(Person person in result)
{

Dictionary<string,string> dataObjectsDictionary= new Dictionary<string,string>();

dataObjectsDictionary.Add("Name", person.Name);
dataObjectsDictionary.Add("DOB", person.DOB.ToString());
dataObjectsDictionary.Add("Address", person.Address);


dataDictionariesArray.Add(dataObjectsDictionary);
}


//Root dictionary
//Dictionary<string, List<Dictionary<string, string>>> rootDictionary = new Dictionary<string, List<Dictionary<string, string>>>();
rootDictionary.Add("response", responseArray);
rootDictionary.Add("data", dataDictionariesArray);



//Formatter

// JsonMediaTypeFormatter formatter = new JsonMediaTypeFormatter();
var json = formatter.SerializerSettings;
var format = new HttpResponseMessage(HttpStatusCode.OK);
json.DateFormatHandling = Newtonsoft.Json.DateFormatHandling.MicrosoftDateFormat;
json.DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc;
json.NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore;
json.Formatting = Newtonsoft.Json.Formatting.Indented;
json.ContractResolver = new CamelCasePropertyNamesContractResolver();
json.Culture = new CultureInfo("it-IT");
}

}
}

API Controller Action method for getting all the persons



public HttpResponseMessage Get()
{
Response response = new Response();
response.errorCode = 100;

return Request.CreateResponse(HttpStatusCode.OK, JsonResponseHandler.rootDictionary, JsonResponseHandler.formatter);

}

I need output in this json format:



{
"response": [
{
"status": "true",
"error_code": "200",
"message": "not found",
"request-_type": "login"
}
],
"data": [
{
"name": "Ugo",
"dob": "28-03-2014 PM 12:48:23",
"address": "Lattanzi"
},
{
"name": "adfasdf",
"dob": "28-03-2014 PM 12:48:23",
"address": "asdfasdf"
}
]
}


C# constructor Object reference not to set an instance of an object


// JsonMediaTypeFormatter formatter = new JsonMediaTypeFormatter();
var json = formatter.SerializerSettings;

You have commented out formatter initialization.

Red X in results is SSMS

IITW SSMS written in C# so there is possible some bugs , if you restart SSMS does it happen again?


Best Regards,Uri Dimant SQL Server MVP, http://ift.tt/1iQ9JkR



MS SQL optimization: MS SQL Development and Optimization

MS SQL Consulting: Large scale of database and data cleansing

Remote DBA Services: Improves MS SQL Database Performance

SQL Server Integration Services: Business Intelligence


Red X in results is SSMS

Also had this issue. Restarting SSMS fixed it.

Problems with xp_cmdshell

Two possibilities:


1) The batch file resides on a different machine from which SQL Server is running from.


2) The BAT file includes a relative path, for instance ..\TEMP which does not exist from the default folder for xp_cmdshell (which is C:\Windows\Syste32).





Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se

Problems with xp_cmdshell

I've just installed SSMS on the server and ran it from there directly.


Now I get a different error:


'C:\BackupScripts\Backup.bat" "FULL" "SQL01" "MH" "SQL_UAT' is not recognized as an internal or external command,


It looks like its dropping the double quotation marks at the beginning and end of the command...


Problems with xp_cmdshell

Ive had a trawl through the batch file and there are no relative paths mentioned.


Problems with xp_cmdshell

Run


EXEC xp_cmdshell 'DIR C:\'


Do you see the BackupScripts folder?





Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se

Stress test webview display on frame switch

Hi Matt,



Yes for me it's a scenario to check because if a user use this app to show pictures he can navigate more than 100 times.


Since this morning I have caught two time a ressource exception when I try to display my webview. But it seems that in C# metro app we can't manage directly ressources. So I can't release ressources use by my webview. I ve see making tests that it wasn't directly the webview which crash but the frame which can't load the webview.


Morethan I ve try to change navigation method of Page class making it sync, async, in an other thread pool... But nothing fix this issue.


Stress test webview display on frame switch

Can you reproduce the problem on other machines?


Matt Small - Microsoft Escalation Engineer - Forum Moderator

If my reply answers your question, please mark this post as answered.



NOTE: If I ask for code, please provide something that I can drop directly into a project and run (including XAML), or an actual application project. I'm trying to help a lot of people, so I don't have time to figure out weird snippets with undefined objects and unknown namespaces.


Stress test webview display on frame switch

Yes on 4 devices: 2 computer with windows 8.0, 1 with windows 8.1 and on a winrt surface



If you want my package to test by yourself please give me a place to post my package and the version you want (arm, x86, x64)


Stress test webview display on frame switch

Please post to OneDrive, x86.


Matt Small - Microsoft Escalation Engineer - Forum Moderator

If my reply answers your question, please mark this post as answered.



NOTE: If I ask for code, please provide something that I can drop directly into a project and run (including XAML), or an actual application project. I'm trying to help a lot of people, so I don't have time to figure out weird snippets with undefined objects and unknown namespaces.


Stress test webview display on frame switch

http://ift.tt/1hBRz3z


Stress test webview display on frame switch

I got it, what do I do?


Matt Small - Microsoft Escalation Engineer - Forum Moderator

If my reply answers your question, please mark this post as answered.



NOTE: If I ask for code, please provide something that I can drop directly into a project and run (including XAML), or an actual application project. I'm trying to help a lot of people, so I don't have time to figure out weird snippets with undefined objects and unknown namespaces.


Stress test webview display on frame switch

Hi,


Sorry I ve forgot to give you the notification file.


Here you can take it : http://ift.tt/1hBRwEQ


Download it and in your application package on folder "LocalState" past it.


After that you could see the webview in the app.


To produce the error just change page until notification display fail.


App is crashing while trying to launch from the Toast notification

Hi,


Am developing a windows 8.1 app (C#). Here am using TimeTrigger background tasks. Inside that Run method of the background task, am scheduling toast notifications, once in every 2 mins.


Once installed, the app is firing toasts as expected.


Here am facing an issue. If I ignore the first toast, then click on the second toast, the app is crashing. But if I click on the first toast, the app is launching properly without any problem.


I don't understand whats the problem here?


Any help is really appreciable


Thanks


Rajesh


App is crashing while trying to launch from the Toast notification

do you have small project that reproduce the problem? there shall be a mistake in your code but hard to help with the current information you provide.


try to do better logging, and did you try to debug it?




Microsoft Certified Solutions Developer - Windows Store Apps Using C#


App is crashing while trying to launch from the Toast notification

Hi,


There is not enough information to detect why the problem occurs. You should put some codes in forum.


Best Wishes!




We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.

Click HERE to participate the survey. Thanks<br/> MSDN Community Support<br/> <br/> Please remember to &quot;Mark as Answer&quot; the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.


scheduled report to be emailed

Hi,

I have a simple ssrs 2012 report which does not use a shared dataset.

It uses a dataset shares in the report.

How can this report be sceduled to run at a certain time and be emailed to someone?

Thanks

Use AddAttachment

Hi,

Can you please share the way to use



AddAttachment



to attach one physical file to the mail, when using SmtpMail?



Many Thanks & Best Regards, Hua Min


Use AddAttachment

If you drill down SmtpClient ->MailMessage. You can get the answer


http://ift.tt/1lBohWY




Mark Answered, if it solves your question and Vote if you found it helpful.

Rohit Arora


Use AddAttachment

hi


Try this



try
{
MailMessage mail = new MailMessage();
SmtpClient SmtpServer = new SmtpClient("smtp.gmail.com");
mail.From = new MailAddress("your_email_address@gmail.com");
mail.To.Add("to_address");
mail.Subject = "Test Mail - 1";
mail.Body = "mail with attachment";

System.Net.Mail.Attachment attachment;
attachment = new System.Net.Mail.Attachment("your attachment file");
mail.Attachments.Add(attachment);

SmtpServer.Port = 587;
SmtpServer.Credentials = new System.Net.NetworkCredential("username", "password");
SmtpServer.EnableSsl = true;

SmtpServer.Send(mail);
MessageBox.Show("mail Send");
}
catch (Exception ex)
{
Console.WriteLine(ex.ToString());
}



Ref


http://ift.tt/1hBJFXP;


http://ift.tt/1rJfxC7


http://ift.tt/1hBJFXT


Mark as answer if you find it useful




Shridhar J Joshi Thanks a lot



Use AddAttachment

Sorry, I'm talking about using SmtpMail and SmtpClient, to send out mail and now I need to attach one file to the mail as well.


Many Thanks & Best Regards, Hua Min


Creating a program that stores data

How can create a simple program that stores data like my friend's names, their contact numbers, and birth months..


This assignment is important... Please help


Creating a program that stores data

And that data will be from the user.

how to hide stored proc and tables schema

Hello,


Stored procedure / user defined function can be encrypted; but with a hack you may get them decrpyted as well.


For table and views there is no such Option available.




Olaf Helper


[ Blog] [ Xing] [ MVP]

how to hide stored proc and tables schema

You may also create a user group with select permission on certain tables or all tables and put him in to the group. He may see the tables & other objects like SP & functions, but cannot read anything from it.




Dr.Subramani Paramasivam


how to hide stored proc and tables schema

You may create a view which would get/contain the info required for your client.


And create a login in your server and provide access only to the view and share the login to your client.


This way you can restrict others from seeing your procedures and other objects.


how to hide stored proc and tables schema

When you are giving backup file of your database to 3rd party.It means you are literally giving him everything in the database.you can't restrict him from viewing the database objects


Regards Chaithu.. If it is usefull,Mark this as Answer.


how to hide stored proc and tables schema

However, this works perfectly if the user is the owner of the database. Look

that …


• Create a new SQL login "login1"

• Create a user named “login1” in master database

• Grant CREATE DATABASE to login1

• While impersonating login1, create a database called “dbteste”

• Revoke CREATE DATABASE permission from login1

• Revoke VIEW ANY DATABASE permission from PUBLIC

• Register this server as login1

• From the “login1” session, expand database tree. Now, you should see

master, tempdb, dbteste

• Grant VIEW ANY DATABASE to PUBLIC

• From the “login1” session, you should see all the databases




Best Regards,Uri Dimant SQL Server MVP, http://ift.tt/1iQ9JkR



MS SQL optimization: MS SQL Development and Optimization

MS SQL Consulting: Large scale of database and data cleansing

Remote DBA Services: Improves MS SQL Database Performance

SQL Server Integration Services: Business Intelligence