C#

94K

Solutions

25K

Contributors

C# is an object-oriented programming language created in conjunction with Microsoft’s .NET framework. Compilation is usually done into the Microsoft Intermediate Language (MSIL), which is then JIT-compiled to native code (and cached) during execution in the Common Language Runtime (CLR).

Share tech news, updates, or what's on your mind.

Sign up to Post

I want to create a excel spreadsheet directly from a SSIS script task which is being pulled from a stored procedure. I'm able to create single sheet workbook with one stored procedure but I'd like to add another another sheet to the same workbook but from a different stored procedure.  I'm taking this from an example from techbrothersIT

using System;
using System.Data;
using Microsoft.SqlServer.Dts.Runtime;
using System.Windows.Forms;
using System.IO;
using System.Data.OleDb;
using System.Data.SqlClient;

namespace ST_563e77770d454d11b11087ae4d41268c
{
    
	[Microsoft.SqlServer.Dts.Tasks.ScriptTask.SSISScriptTaskEntryPointAttribute]
	public partial class ScriptMain : Microsoft.SqlServer.Dts.Tasks.ScriptTask.VSTARTScriptObjectModelBase
	{
    
        public void Main()
        {
            string datetime = DateTime.Now.ToString("yyyy_MM_dd_HHmmss");
            try
            {
                //Declare Variables
                string ExcelFileName = Dts.Variables["User::ExcelFileName"].Value.ToString();
                string FolderPath = Dts.Variables["User::FolderPath"].Value.ToString();
                string StoredProcedureName = Dts.Variables["User::StoredProcedureName"].Value.ToString();
                string StoredProcedureName2 = Dts.Variables["User::StoredProcedureName2"].Value.ToString();
                string SheetName = Dts.Variables["User::SheetName"].Value.ToString();
                string SheetName2 = 

Open in new window

0
I want to create dataset using "Microsoft Rdlc Report Designer" in visual studio 2017.
My sql server is in another machine.
I have access database via LAN .
When i create dataset by clicking on "Dataset" in "Microsoft Rdlc Report Designer", then visual studio hangs and crashes.
Then Visual studio 2017 restart automatically. I have tried several times but same issue.
0
How to write application event logs in individual (not centralised) docker container for windows that has been deployed in Azure service fabric via AWS cicd . what configuration is needed if any ? if it is being logged then  what will be the file path.  ?
0
labelproperties.PNGI have 2 labels

    1) is called lblsuccessmessage
    2) is called lblerrormessage

if an update is successful then i am displaying a success message if not displaying an error message. for some reason the label is not getting displayed even when i debug through the code, it runs over it but nothing is displayed on the screen.

More Code

Code behind

namespace masterpage
{
    public partial class Inp_OEE_Sanitation : System.Web.UI.Page
    {
        

        private static Logger PageLogger = LogManager.GetCurrentClassLogger();

        const string WhichMenuItem = "Sanitation";
        const int HiddenGeneralIDField = 6;
        const int HiddenVStatusField = 7;
        const int HiddenInitialVStatusField = 8;
        string con = ConfigurationManager.ConnectionStrings["OEEDBConnectionString"].ToString();
        string PlantVal = ConfigurationManager.AppSettings["plantvalue"];

        protected void Page_Load(object sender, EventArgs e)
        {
            
           lblSuccessMessage.Text = "Entering Page Load";
            
            Calendarextender3.EndDate = DateTime.Now;

            if (todaydate.Text.Trim().Length == 0)
            {
                todaydate.Text = DateTime.Today.ToString("MM/dd/yyyy");
            }
            if (!IsPostBack)
            {
                HiddenSetDate.Text = todaydate.Text;
                PopulateGridview();
            }
            SetScreenName();

        }
        public 

Open in new window

0
Can some help me convert this C++ code to either java or C#
uint32 SN2ID(const string &szTermSN, string &szTermID)
{
       if(szTermSN.length() == 8 )
       {
              int f1,f2,f3,f4;
              sscanf(szTermSN.c_str(), "%02d%02d%02d%02d", &f1, &f2, &f3, &f4);
              f2 += 128;
              f3 += 128;
              char tmp[10] = "";
              _snprintf(tmp, sizeof(tmp), "%02X%02X%02X%02X", f1, f2, f3, f4);
              szTermID = tmp;
       }
       return 0;
}

Open in new window


if  for example  szTermSN=23D39449 szTermID=35832073
0
Help !!!,
I have written a C# WCF ASP.NET Service which runs in IIS and has been working fine for the past few years. I have returned to it after 3-4 months to do some additional work, However when I try to log into the service I cannot get beyond the login Page. I recompiled the service & client but with same result. When I try to debug I get a message that "The breakpoint will not currently be hit. No symbols have been loaded for this document. I am at a loss as to how to figure out what is wrong. When I look at the trace logs I see the following.  I have made no changes to the Login where it seems to be failing.



2019-01-29 21:38:21.240 +00:00 [Information] Trying to Log on as: "stryker" 
2019-01-29 21:38:22.300 +00:00 [Information] Error encountered: "[b]System.ServiceModel.ProtocolException[/b]: The content type text/html; charset=utf-8 of the response message does not match the content type of the binding (application/soap+xml; charset=utf-8). If using a custom encoder, be sure that the IsContentTypeSupported method is implemented properly. The first 1024 bytes of the response were: '<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\"> 
<html xmlns=\"http://www.w3.org/1999/xhtml\"> 
<head> 
[b]<title>IIS 8.5 Detailed Error - 500.19 - Internal Server Error</title> [/b]
<style type=\"text/css\"> 
<!-- 
body{margin:0;font-size:.7em;font-family:Verdana,Arial,Helvetica,sans-serif;} 

Open in new window

1
Hi,

I need to display placeholder text(hint) in the textbox using c# and asp.net. I can able to display on IE11 with enterprise mode OFF. When I turn on the Enterprise mode ON, Textbox not showing the placeholder text. So, I am using jquery code to display the placeholder text. Till then things are working.
Now I need to change the placeholder text on button click. Placeholder Text is not changing on button click. Please let me know what needs to be done.

<html>
<head><script type="text/javascript" >
      jQuery(function () {

            jQuery.support.placeholder = false;

            webkit_type = document.createElement('input');

            if ('placeholder' in webkit_type) jQuery.support.placeholder = true;

        });

        $(function () {

 

            if (!$.support.placeholder) {

 

                var active = document.activeElement;

 

                $(':text').focus(function () {

 

                    if (($(this).attr('placeholder')) && ($(this).attr('placeholder').length > 0) && ($(this).attr('placeholder') != '') && $(this).val() == $(this).attr('placeholder')) {

                        $(this).val('').removeClass('hasPlaceholder');

                    }

                }).blur(function () {

                    if (($(this).attr('placeholder')) && ($(this).attr('placeholder').length > 0) && ($(this).attr('placeholder') != '') && ($(this).val() == '' || $(this).val() == $(this).attr('placeholder'))) {

                       

Open in new window

0
below link is describes what i am doing :

https://www.c-sharpcorner.com/uploadfile/ulricht/how-to-create-a-simple-screen-sharing-application-in-C-Sharp/

but on some machines as soon as connection happens, the OnConnectionTerminated event gets called with return parameter  disconnect reason reason as 0 meaning "no info available" and extended info parameter as 3. what could be the reason for this? Please assist as same code is working on many other computers.
0
I know this is probably simple enough but I just can't see it.
I built an app a few years ago (which is working great) but we asked to add a few more choices to the dropdown list. When building it I used an ENUM but now I can't add to it. Is there a work around to this.
Thanks
0
I have many G-Code files and I want to create a gallery like c# application that shows the previews/thumbnails of the G Code files.
In short: I want a G-Code to Image converter.

Can someone give me some direction?
Or can someone give me a source code from where can I start?

Thanks advanced
0
How to show tooltip on hover of image icon who is next to checkboxlist in asp.net and c#?

I have 10-11 checkboxes with different values.
Ex. Chk CA
       Chk MN image icon
       Chk OH image icon
       Chk TN
       Chk NY  image icon

When we hover the image icon, help tooltip will appear? How can that be accomplished if we get the data from database. Or whats the bet approach
0
The more I read about commandbuilder the less I think I should be using it. I am using commandbuilder here to populate a datagridview. How would I restructure this code to not use commandbuilder to populate the datagridview?

        private void DisplayEditCHFLET()
        {
            try
            {
                EditCHFLETDataSet = new System.Data.DataSet(); /* Define the data set for the list of personnel */
                EditCHFLETDataSet.CaseSensitive = false;

                EditCHFLETDataCommand = new System.Data.SqlClient.SqlCommand();
                EditCHFLETDataCommand.Connection = EditCHFLETDataConnection;

                EditCHFLETDataCommand.CommandText = "SELECT [GRUPFLAG],[RANKNMBR],[FULLNAME],[ASGNMENT],[APPTDATE],[SHIFT],[SHLDNMBR],[RANK],[RANKDATE],[PINNUMBR],[ROW_ID] " +
                    "FROM [PERSASGN] WHERE [GRUPFLAG] = 'CHFLET' ORDER BY[FULLNAME]";

                EditCHFLETDataAdapter = new System.Data.SqlClient.SqlDataAdapter();
                EditCHFLETDataAdapter.SelectCommand = EditCHFLETDataCommand;
                _commandBuilder = new System.Data.SqlClient.SqlCommandBuilder(EditCHFLETDataAdapter);

                EditCHFLETDataAdapter.Fill(EditCHFLETDataSet);

                if (EditCHFLETDataSet == null || (EditCHFLETDataSet.Tables.Count == 0) || (EditCHFLETDataSet.Tables[0].Rows.Count == 0))
                {
                    MessageBox.Show("No records found in personnel database. Please start …
0
Hi.
I create now WriteableBitmap no problem with that. But all data values I have to convert to byte in order to use the construction of WriteableBitmap.
This is not what I need, because real data is 16 or 32 bit and I loose a lot of information by this conversion.
Is is any other way to draw images in WPF from row date in which is possible to use not only 8-bit data?
0
Best Practice for a Data Access Layer:

I am creating a class-injected data layer of the type: public List<T> GetData<T>(string cnn, string proc, string args)

where T is the class-definition of the data to be returned
cnn is the name of the database connection
proc is the name of the retrieval technique (stored proc)
args is a class-driven list for passing parameters


The goal here was to isolate the retrieval(obviously) from the middle tier and to use base-class definitions to describe the data.
Of course I may be creating a base-class runaway problem based on the number of dataset descriptions the team creates,


Does this sound like a good approach or is there a better way?

Thanks in advance
0
Hi Experts,

I have the following code. Before @Html.ValidationSummary() I want to put a check, if 'InvaliFileFormat' div is visible then make it invisible.

@using (Html.BeginFormAntiForgeryPost("/Contact", FormMethod.Post, new { @enctype = "multipart/form-data" }))
    {       
        @Html.ValidationSummary()
        if (Model.UploadIssueMessages != null)
        {
            <div class="validation-summary-errors" style="display:normal;margin-bottom: 0px;" id="InvaliFileFormat">
                <ul>
                    <li>@Model.UploadIssueMessages</li>
                </ul>
            </div>
        }}

Open in new window


Thanks in advance!
0
I'm getting an exception in my following line of code in my function.  My goal is to return the value of my resultsContainer if my switch statement is invoked.

            results = resultsContainer;  > Cannot implicit convert type System.Collections.Generic.List<XXX.Models.CustomReports.CreditHoldDetailsResults>
to xxx.Models.CustomsReport.CreditHoldResultsContainers.


    public static CreditHoldResultsContainer GetReportResultsObject(CreditHoldSearchCriteria searchCriteria
            , xxx.Models.Employee LoggedInUser
            , System.Globalization.CultureInfo systemCultureInfo
            )
        {
            var results = ServiceAssistantService.CustomReports.CreditHoldService.GetReportResults(searchCriteria, LoggedInUser.CultureInfo, LoggedInUser.ID.Trim().ToUpper());
            var resultsContainer = results.reportResults;
            var headerText = "";

            
         
            if (resultsContainer != null && resultsContainer.Any())
            {
                headerText = headerText + "  " + Sxxx.Tools.Language.Translate(Language.Keys.Sort_By, LoggedInUser.CultureInfo) + " : ";
                switch (searchCriteria.SortOrder)
                {
                    case 1:
                        resultsContainer = resultsContainer.OrderBy(x => x.CustomerNumber).ToList();
                        break;
                    case 2:
                        resultsContainer = resultsContainer.OrderByDescending(x => 

Open in new window

0
I have a dropdown in my cshtml file and and need to disable and enable it based upon a variable value

var canEdit = false or var canEdit = true

so basically if value is false disable the dropdown or if true enable the dropdown

<dropdown dropdown-menu-items="results" option-label="Not Reviewed" class="jq-checker-inspection-dropdown" data-poi-index="@inspectionItem.PointOfInspection"></dropdown>

I want it to work that something like this

 <input @(isEnabled ? "" : "disabled") @(noId == savedId ? "checked" : "") class="form-check-input" type="radio" name="checker-verify-radio-@componentId" id="checker-verify-radio-no-@noId" value="no">

the above working code is for a check box.if its true i have the checkbox checked and if false then checkbox is unchecked.

similiarly i want to have my dropdowd disabled if canEdit = false  and dropdown enabled if canEdit = true
0
Hi,

I am having .wsdl url. I am having these two information

1. SERVICEendPOINT: http://service.com/geocode2008?wsdl
2. WSDL location url: http://service.com/provider/geocode/2008/

How to use these in c# .net application. How c# client consumes this .wsdl? I have attached my .wsdl in the attachment.

If I enter Zipcode, How to call getGeocode? I am not sure what needs to be done.

Thanks
wsdl_xml.jpg
0
I have an MVC Web application. On the cshtml page, I have a data table that I am trying to format a date like M/dd/yyyy. My issue is that when the date is null, it displays "1/01/0001". I would like for it to just display blank if it is null. My code is below.

                            <td>@jobinfo.MLR_Submission_Date.ToLocalTime().ToString("M/dd/yyyy")</td>

Open in new window

0
Hello Experts,
I have file in a network shared folder. I can access it from file explorer(\\10.0.1.22\Users\mm\Test.txt). But when I am trying to access it from the C# program it says file does not exists. Any suggestions?

FileInfo myFile = new FileInfo(@"\\10.0.1.22\Users\mm\Test.txt");
bool exists = myFile.Exists;

Thanks in advance.
0
I have an MVC C# Application. On the cshtml page, i have a date input field. Sometimes the user leaves it blank and sometimes fills it in. I need to evaluate whether the field is blank or not in the controller. If it is blank, I would like to insert a default value of '01/02/1901'. I'm using html 5.

input code is below:
<input type="date" name="Date Worked" id="add_Date_Worked" class="form-control" required />

Open in new window

0
I have an MVC C# application that requires a user to select a client from a drop down list "add_Client_ID". After the user makes a selection, I need to refresh the "add_Product_ID" drop down list with the filtered information. What is the best method for this? Can someone help.

Drop Down Code -----------------------------------------
                <div class="row mg-t-20">
                    <label class="col-sm-5 form-control-label">Client:</label>
                    <div class="col-sm-6 mg-t-10 mg-sm-t-0">
                        <select name="Client_ID" id="add_Client_ID" class="form-control" required>
                            <option value="0">Select a Client</option>
                            @{
                                foreach (Client client in Model.Clients)
                                {
                                    <option value="@client.Client_ID">@client.Client_Name</option>
                                }
                            }
                        </select>
                    </div>
                    <label class="col-sm-1 form-control-label"><span class="tx-danger">*</span></label>
                </div>

                <div class="row mg-t-20">
                    <label class="col-sm-5 form-control-label">Product:</label>
                    <div class="col-sm-6 mg-t-10 mg-sm-t-0">
                        <select name="Product_ID" id="add_Product_ID" class="form-control" disabled required>
                   

Open in new window

0
How can I draw or plot an oil well trajectory in 3D using C #. Please check the image attached.

Regards,

Dallag
open_wells_3d_1.png
0
I need a function that takes datetime variable and tests if it is a valid datetime. If it is, then format it into (yyyy-MM-dd) to go into a sql datetime field. If the datetime is not valid, return (1901-01-01). Language is c#.
0
I have an MVC C# Web Application where the user is not required to input a value in a date input field. If the user does not enter a date, MVC throws an error as it expecting a value. Below is my input code, model & controller information. What is the best way to handle if user does not supply a date and still insert data successfully into Sql using a stored procedure. The stored procedure is expecting a datetime as a parameter.

Controller Code -----------------------------------------------------------------------
        [HttpPost]
        [ActionName("AddTimeInfo")]
        public ActionResult AddTimeInfoPost(TimeInfo timeinfo)
        {
            if (ModelState.IsValid)
            {
                timeinfo.Created_By = Request.Cookies.Get("User_ID").Value;
                timeinfo.Updated_By = Request.Cookies.Get("User_ID").Value;
                try
                {
                    timeinfoDao.InsertTimeInfo(timeinfo);
                    TempData["Success"] = "true";
                }
                catch (Exception e)
                {
                    TempData["Success"] = "false";
                }
            }
            else
            {
                var errors2 = ModelState
                    .Where(x => x.Value.Errors.Count > 0)
                    .Select(x => new { x.Key, x.Value.Errors })
                    .ToArray();
                TempData["Success"] = "false";
            }
            return RedirectToAction("TimeInfo", 

Open in new window

0

C#

94K

Solutions

25K

Contributors

C# is an object-oriented programming language created in conjunction with Microsoft’s .NET framework. Compilation is usually done into the Microsoft Intermediate Language (MSIL), which is then JIT-compiled to native code (and cached) during execution in the Common Language Runtime (CLR).