Questions tagged [c#-4.0]

1

votes
0

answer
22

Views

Button type button posting data is not saving in DB

i added on message Box and i am posting that data but not adding in my DB. when i am trying to click Confirm button it is not saving in data-base how it will save to data-base can you please help me. enter image description here var leaveManagement= { leaveData: null, showModal: function(data) { lea...
Dinesh
1

votes
2

answer
66

Views

SqlCommand Error Procedure or function 'X' expects parameter '@Y'

As near as I can tell, this is not a duplicate question because I am supplying an alternative that actually DOES work. VS 2012 targeting .NET 4.5 Common code: public const string SP_PLANT = 'hsp_BOM_EXP_SOURCE'; public const string SP_PARM_PLANT = '@Plant_CD'; public const string SP_PARM_PART_NUM =...
B H
1

votes
0

answer
47

Views

C# JSON Deserialize Dictionary<string, Dictionary<string, string>>

JSON Data: { 'MetaData ': { 'Id': '1', 'CreatedBy': 'Ravi', 'CreatedOn': '06/01/2018', 'State': 'Completed', 'Level': 'Curator' }, 'tbDm': { 'textBox1': 'Ravi', 'textBox2': 'Chaitag', 'textBox3': 'Jp', 'textBox4': 'Ch' }, 'tbCO': { 'textBox5': 'Cha', 'textBox7': 'C', 'textBox8': 'ra', 'textBox6': 'j...
Ravi
1

votes
0

answer
141

Views

Unload dynamic compiled dll

I have a little problem. Frist, I have a program, which has a class for compiling assemblies from scripts that could be written inside this program for using programs data. So I cant unload generated assembly. Tried to use AppDomain.Unload, but it shows that file 'Scripts.DLL' is busy. I wich you co...
1

votes
0

answer
34

Views

How to write a mongodb select query using (in) with C#

In Sql: SELECT * FROM inventory WHERE status in ('A', 'D') MongoDB: db.inventory.find( { status: { $in: [ 'A', 'D' ] } } ) How to write above mentioned query in C# with mongoDB.i am new in mongodb.Please any one help me. Thanks in advance.
Revathi Vijay
1

votes
0

answer
49

Views

How to prevent value can not be Null during c# SQLBulkcopy Processing

I am processing a CSV file using ASP.NET C# and it works if I assign 0 to fields that = ''. But if I try to replace with ' ' or '/t' then I get a value can not be Null when inserting into the database. Here is the C# code in question: while (!csvReader.EndOfData) { var fieldData = csvReader.ReadFiel...
Jason
1

votes
0

answer
19

Views

Extra trailing comma in Header

I have a Cordova application connecting to IIS. I am getting an extra comma when I send: $rootScope.httpConfig = { headers: { 'Content-Type': 'application/json', 'authorization': 'bearer ' + response.Token } }; The token has no commas, somewhere in the pipe between the client and the server a comma...
kroleigh
1

votes
2

answer
131

Views

How to inject only one object to constructor using unity DI

How to inject only one object to constructor using Unity DI. Example: public class MyClass{ public MyClass(ILog logger, IProvider provider, IResolver resolver, ItemTypeEnum itemType) { //.... initializing everything } public ItemTypeEnum ItemType { get; set;} //....methods where I will use this item...
Tomasz M
1

votes
2

answer
86

Views

Using StringComparison.OrdinalIgnoreCase to ignore Case

This code is case sensitive, how to make it case insensitive? return HeaderNames.Length == fileLine.Count && HeaderNames .Select(headItem => fileLine[Array.IndexOf(HeaderNames, headItem)] == headItem) .All(i => i); Thanks for your answers/
Da Ja
1

votes
1

answer
23

Views

Grayed form while loading

i have written the following code in c#. but it didn't the way i want it... my current code opens the 'LoadingForm', but when it shows on screen i can see it as 'gray screen with squares' - instead of the Loading_Gif which i have added to that form, hope you help me (By the way, i tried to run the f...
Ahmad Egbaria
1

votes
0

answer
30

Views

not get record from database to itemcode have spaces although i use ltrim

problem when match item code with item code have spaces by ltrim it get null result Details I make SQL query to get latest prices for customer from database correct result is 13.5 price value but it give me null the problem in item code have spaces IN item code in database so that i dont know how...
user3223372
1

votes
1

answer
843

Views

How to solve this error : must specify valid information for parsing in the string

I want to convert a string to enum . My code is like this var categoryEnum = (SiteCategory) Enum.Parse(typeof (SiteCategory), UIController.QueryStringParamInitialValue, true); And QueryStringParamInitialValue() is like this public static string QueryStringParamInitialValue { get { string str = strin...
ratna
1

votes
1

answer
53

Views

C# search sub directory and files [duplicate]

This question already has an answer here: Getting all file names from a folder using C# [duplicate] 7 answers I need to search a root folder for particular subdirectory named 'XYZ','ABC'. And need to get the filenames from these two folder by iterating these two folder one by one. I have used the b...
Ask_SO
1

votes
1

answer
26

Views

Inspite of checking for null with usercontrol checkboxlist is returning object reference not set to an instance of an object

I have a group of 7 checkboxes in checkboxlist user control. I build a string in the selectedIndexchanged event for the boxes checked, pass to ViewState and then pass ViewState to the Property. I do this because in the instance when no checkboxes are selected I want to handle null. The problem is...
Doreen
1

votes
1

answer
78

Views

C# - Create new URI object to point to a Local file

How can I create a URL object that points to a file that is Local to my web application I thought this would work: var myURI = new Uri('~/Content/css/pdfX.css'); but I am getting this error: Invalid URI: The format of the URI could not be determined. Thanks
Ayo Adesina
1

votes
0

answer
66

Views

Microsoft SQL Server compatibility issue (C# Application)

I am developing a C# application on Windows 10, under Visual Studio 2015. I can see that I have installed on that PC Microsoft SQL Server 2005 Compact Edition, 2012 Native Client, 2014 Express LocalDB, 2016 Local DB and other stuff like this. I did not voluntarily installed any of this, they must ha...
Marko
1

votes
0

answer
196

Views

Add Web Reference with certificates on https

I was adding a web service via 'Add Web Reference' to my project. The web service was only accessible on https with a client certificate.When I did 'Add Web Reference' I got a 'The underlying connection was closed: An unexpected error occurred on a send'. I found an other way to add the web service...
bernova
1

votes
0

answer
216

Views

How to use async in ASP.Net MVC for Mono

I am creating an ASP.Net MVC project in Mono using Visual Studio 2017 for Mac. I added the basic controllers, view, models, etc and it's working fine. However, as soon as make the Index method async I am getting the following error: System.InvalidOperationException The view 'Index' or its master was...
MikePR
1

votes
1

answer
39

Views

how to take checkpoint record and process remaining data from foreach c#

I have multiple files to be process from list. If because of any reason list is interrupted , when next time we execute program it takes the last executed records and start process the further records instead start from 0 index. CamlQuery camlQuery = new CamlQuery(); camlQuery.ViewXml = @' '; camlQ...
Neo
1

votes
0

answer
131

Views

How to get voice stream from Bot client(emulator) using Microsoft Bot framework

I have an issue regarding bot building (Microsoft Bot Framework). The scenario should be like this- for the the first step I need to test on bot emulator(client). The requirement would be to get the voice from client as a stream (as well as need kind of event that can handle is user speaking or not)...
Ariful Islam
1

votes
0

answer
156

Views

Multi-layer perceptron (neural network) - what am i missing?

I am trying to implement my own multi-layer perceptron, unfortunately i make some mistake i can't find. Link to full program is here (it is light, simple c# console application). I am learning from this book , the code I am trying rewrite from batch to sequential form is at this github. Link to my...
Bartek Wójcik
1

votes
1

answer
33

Views

get number from string.format c#

I have use string.format: string strfm = 'PC{0:ddMMyy}.{1:d3}/{2:MM}H' and number : 1 =>string str = string.format('PC{0:ddMMyy}.{1:d3}/{2:MM}H',DateTime.Now,1,DateTime.Now) result str = PC070518.001/05H => str = strfm + number, how to result number{1:d3} from str and strfm, Thank you!
smart duong
1

votes
0

answer
98

Views

ZipFile.CreateFromDirectory C# send to MemoryStream

How would I basically use ZipFile.CreateFromDirectory to send back zipfile to memory stream instead of a output path. Or would I have to use ZipArchive and generate the zip file myself? Seems kind of odd there isn't a method for stream. Here's basically what I'm trying to do using (MemoryStream ms...
jefflahh
1

votes
0

answer
64

Views

Form/Windows/Passport authentication vs Authentication Filter in ASP.NET MVC 5

Why we need Authentication Filters if we already having Form/Windows/Passport Authentication in .NET. 1) Types of authentication in ASP.NET MVC 5 2) Authentication Filters in ASP.NET MVC 5 I'm know both are used to authenticate the user but Why we need both? Can we use both? If Yes, How it will wor...
Raj
1

votes
1

answer
23

Views

Checking whether a unique data is present in a json file

I need to check whether a word is present in a JSON file or not. So if I'm searching for 'root', then even though the word 'byroots' contain root, it should give me false. Here's my code using (StreamReader r = new StreamReader('filename.json')) { string json1 = r.ReadToEnd(); if (json1.Contains('r...
1

votes
1

answer
207

Views

NLog Concurrent Requests into different files

As the title suggests, I am trying to log separate requests to my .NET Web API controllers to separate files. With the introduction of {var}, here is what I am trying inside my c# code. private static Logger logger = LogManager.GetLogger('test'); [HttpPost, Route('xyz')] public IHttpActionResult P...
Sandeep
1

votes
3

answer
476

Views

How to generate a unique string from email or username

I want to create a method in c# that will accept my unique email or username and will return me a unique string just like youtube's video id (https://www.youtube.com/watch?v=_MSYfOYFF14). I can't simply use GUID because I want to generate a unique string against every user and it will remain same fo...
Ask
1

votes
0

answer
52

Views

How long is valid MachineKey encrypted string or no expiry for that

What will be the lifetime for encrypted string using machine key as below: //System.Web.Security MachineKey.Protect(streamarray,purpose); MachineKey.Unprotect(string,purpose); How long protected string is valid. I could not find anywhere that mention, but I believe, its valid and no expiry, is it c...
user3711357
1

votes
0

answer
104

Views

How do I move a AutoGenerate,IsolateApps machine key system onto a load balanced server?

I just found, web.config with below settings in all the environments including prod. Now, application is going to start using with load balancing. Would it create problem as its not using static machine keys ? If I change this key now to static validaitnKey and static decrptionKey then it creates an...
user3711357
1

votes
1

answer
54

Views

Converting hex to int while reading a text file

I have few hex numbers that the last digit mean the length of the string after. for example 2E3F00004Sara 41590000AFavhilmnfr Except from: 515900016Mickael Barrie Linwood Which is 22 not 16.. any idea how to get it from the number? Thank you
Monika
1

votes
1

answer
11

Views

C# Thread Access from Button event

Please kindly help me to add the delay to Continues() method. namespace NetworkUtilities { public partial class Form1 : Form { Thread th1; public Form1() { InitializeComponent(); th1 = new Thread(Continues); } private void Continues() { try { for (int j = 0; j < 4; j++) { Ping myping1 = new Ping();...
1

votes
1

answer
171

Views

How to download pdf file from database using asp gridview link button

I have stored binary data into a db. When I'm fetching and trying to download same pdf file I'm unable to do it. Below is my code snippet: protected void grdDownload_Command(object sender, GridViewCommandEventArgs e) { if (e.CommandName == 'Download') { int index = Convert.ToInt32(e.CommandArgument)...
Gurindapalli
1

votes
0

answer
117

Views

File Upload warning Chrome 66 and above to be handled using Selenium Webdriver

Chrome browser allows folder upload (using browse dialog) and recently post version 65 we are seeing a security popup which states that do you trust this site for uploading the files from folder. This popup is causing the Automation to fail, is there any way to handle it using Selenium? like by usin...
essdee
1

votes
0

answer
28

Views

( extension icon bar - chrome browser ) Can we automate this ON /OFF action via selenium web driver

I installed Goggle analytic debugger ( https://chrome.google.com/webstore/detail/google-analytics-debugger/jnkmfdileelhofjcijamephohjechhna ) on chrome browser & getting ON / OFF switch on top right corner( extension icon bar) on chrome browser. Can we automate this ON /OFF action via selenium web d...
parveen
1

votes
0

answer
15

Views

Create simple sounds such as 8-bit through code

I need to build a very rigid text to speech generator choosing my own 8 bit sounds per syllable/char but have not found a single piece of code online to do this in C# other than AudioClip.SetData() method for creating Sine waves which is not what I need. I need more rough sounds like 8-bit or higher...
1

votes
1

answer
50

Views

DataContractJsonSerializer issue if property return type interface with nested property return type

Need to serialize into JSON string and Deserialize the JSON string into object. here my class flow. [DataContract] public class BatchItem_NF : INF { [DataMember] public IDebtor Debtor { get; set; } [DataMember] public IList AllDebtors { get { return _debtors; } } } [DataContract] public class Debtor...
greensoil
1

votes
1

answer
111

Views

is filehelper library able to read xml files

I am using filehelpers library to read and write csv files in my .net project. I need to read and write xml files also using the same library. is it possible with filehelpers library. Thanks in advance!!
Ravindra kumar
1

votes
2

answer
55

Views

Compare object in custom list and return the unmatched object C#

I have two models public class NewrecordModel { public string NewName { get; set; } public string NewFileName { get; set; } public string NewFileVersion { get; set; } } public class OldrecordModel { public string OldName { get; set; } public string OldFileName { get; set; } public string OldFileVer...
user2681579
1

votes
0

answer
133

Views

Change datasource using bartender dynamically using c#

I'm populating fields data from database with bartender but I'm not able to do same while changing database from code, e.g. There is a template called TestLBL.btw and in the template we have configured database field say TestDB.Name field now I've another database say TestDB2 and that have exact sa...
IPS
1

votes
1

answer
43

Views

Insert data from Excel to Database using C#

Hi all I wanted to inserted data from Excel . I have three columns in Excel Excela , Excelb, Excelc .These values i wanted to insert into table throgh stored procedure Here is my code please correct me static void Main(string[] args) { string Path = @'D:\Angular\SIRStatus.xlsx'; OleDbConnection con...
Praveen Chowdary

View additional questions