.NET Programming

134K

Solutions

39K

Contributors

The .NET Framework is not specific to any one programming language; rather, it includes a library of functions that allows developers to rapidly build applications. Several supported languages include C#, VB.NET, C++ or ASP.NET.

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

Sign up to Post

Hi

I'm using npgsql for first time with postgres 11 db

My code is as follows

    cmd = new NpgsqlCommand("INSERT INTO \"tracking_dataa\"(imei_number, gps_datetime, event_id, speed, latitude, longitude, heading, raw_data)	" +
                                                                          "VALUES(@ImeiNumber, @GPSDateTime, @EventId, @Speed, @Latitude, @Longitude, @Heading, @RawData);", con, transactSql)
                                {
                                    CommandType = CommandType.Text
                                };
                                cmd.Parameters.AddWithValue("@ImeiNumber", item.ImeiNumber);
                                cmd.Parameters.AddWithValue("@GPSDateTime", item.GPSDateTime);
                                cmd.Parameters.AddWithValue("@EventId", item.EventId);
                                cmd.Parameters.AddWithValue("@Speed", item.Speed);
                                cmd.Parameters.AddWithValue("@Latitude", item.Latitude);
                                cmd.Parameters.AddWithValue("@Longitude", item.Longitude);
                                cmd.Parameters.AddWithValue("@Heading", item.Heading);
                                cmd.Parameters.AddWithValue("@RawData", item.RawData);
                            
                                cmd.ExecuteNonQuery();

Open in new window


However, I get the error
{"42P01: relation \"tracking_dataa\" does not exist"}

Open in new window


i've tried the following

INSERT INTO \"tracking_dataa\"(imei_number, gps_datetime, event_id, speed, latitude, longitude, heading, raw_data

INSERT INTO tracking_dataa (imei_number, gps_datetime, event_id, speed, latitude, longitude, heading, raw_data

INSERT INTO \"public\".\"tracking_dataa\"(imei_number, gps_datetime, event_id, speed, latitude, longitude, heading, raw_data

INSERT INTO public.tracking_dataa (imei_number, gps_datetime, event_id, speed, latitude, longitude, heading, raw_data

Open in new window


Nothing seems to work, the same error exists

When I browse my DB in Navicat, the table is under the public schema and I can connect fine

What am i doing wrong?
0
Hi,

I'm looking at ways to convert MGRS coordinates to Decimal  Latitude, Longitude  I've come across CoordinateSharp  the Developer Guide makes use of tryParse but dosn't seem say how to trap the errors nor dose the dotnetfiddle example

I also note the output is Degree minute seconds not digital

The Developer Guide Suggests "c.FormatOptions.CoordinateFormatType = CoordinateFormatType.Degree_Decimal_Minutes;"


However this Errors

		string mgrs = "16R CV 05774 44722";
		Coordinate c;
		if(Coordinate.TryParse("16R CV 05774 44722", out c))
		{
			c.FormatOptions.CoordinateFormatType = CoordinateFormatType.Degree_Decimal_Minutes;

			Console.WriteLine(c);
		}

Open in new window


So how do I rewrite the above trapping errors and output to  Decimal  Latitude, Longitude variables?
0
Is it possible for the following task to be "inlined" and run on the current thread when the t.Wait(); is encountered?
Task t = Task.Run(() => MyMethod());
t.Wait();

Open in new window

If so, can you provide some example code that does this?

(I've tried setting ThreadPool.SetMaxThreads(8, 8); (This succeeds. My computer has 8 CPUs.) and then launching a dozen tasks via Task.Run() to try and fill up the ThreadPool so my Task t = Task.Run() gets queued but not run. However, I have not been able to get t.Wait(); to "inline to inline the task. So far it just always waits I assume for a free ThreadPool thread to become available.)
0
I'll go step by step with my question at the end. This is Windows Forms, C#

1.  Code populates a Datatable from the database. You see the ImageData column is blank. This is correct.
e1.png
2. When the "ImageData" is null in the database, code replaces the column with an image "Add Image". Looks like this.
 if (e.Row.Cells["ImageData"].Value == System.DBNull.Value)
                {
                    e.Row.Cells["ImageData"].Value = iFramework.Images.Images.ImageToByte(Properties.Resources.AddImage);
                   
                }

Open in new window


e2.png
3. I click on the first column "Detailed Description". Change the text. I don't change the "Image" column; I don't upload a new image.

4. I click Save

5. I look at the Datatable and the ImageData column is changed to "Add Image" byte ...even tho I didn't make a change. This happens because the code (step #2) adds the image and this changes the Datatable
e3.png
My questions:

1. After I click "Save", I check the "ImageData" column. I want to see if it's changed (meaning user has uploaded a new image). "Add Image" is NOT considered as user uploading a new image but Datatable shows it as changed. It's like "fake" change!  It should be "blank" (step #1)

Anyway I can check --> ImageData column is "Add Image".

2. The "Add Image" gets saved like this. Can I check the "System.Byte[]" in the DataTable to this? Could this tell me it's "Add Image"?

Open in new window

0
Hello Experts -

Is anyone familiar with SAP BI4? I'm new to this, and I'm trying to do a simple count by category. So say the object is "color", and each record has a "color" field. I added the "color" object to the report, and now I just want to count the number of reds, blues, oranges, etc., so I want a group of red rows with a count or those, then a group of blues and a count of those.

Any ideas? Do I use "break" or "group"? Thanks. When I highlight the color column and just do a "count", it counts the unique values only. I need to know how many reds, how many blues etc.

Thanks,
Marcos
0
Hi experts,
I have wrote the C# API programe to get data from different location.
All used to work fine.Suddenly it's generating error becuase the records not available
in the API records.(requesting records)There is no way to find Candidate avaiable or not.

see below link how the API request send.

https://test/v3/company/18f62e940d1d01/position/771b0f2aff3c01/candidate/05ea659e456a01/stream

Error:

 500 Internal Server Error
{
    "error": {
        "type": "getStreamError",
        "message": "there was an unknown error getting candidate stream."
    }
}

 string urlCandatestream = "/company/" + CompanyID + "/position/" + positionID + "/candidate/" + candidateID + "/stream";
                var request = new RestRequest(urlCandatestream, Method.GET);


                request.AddHeader("Content-Type", "application/json");
                request.AddHeader("cache-control", "no-cache");
                request.AddHeader("authorization", connectAPI.getAccessToken());
                // rqst.Proxy = GlobalProxySelection.GetEmptyWebProxy();

                IRestResponse response;
                varRequest = request.ToString();
                try
                {
                    response = await _restClent.ExecuteTaskAsync(request);
                    VarRequestResults = response.Content;
                }
                catch (Exception ex)
                {
                    throw new Exception("Error executing  request to " + 

Open in new window

0
Visual Studio vb.net  2019 project.  One of the dlls give the error message "The type initializer for <module. threw an exception".   This program has been running w/o any problems for several years using previous versions of visual studio.  The problem started with visual studio upgrade to 2019.  
The error occurs when loading two of the forms in the dll.  I use Devexpress controls and have used their tool to make sure that all required references are present.   Errors occur during load as I am unable to call any sub from the Load event.  I can't attach this to a simple project to look for errors as this dll has references to 4 other dlls.  
No errors on my machine,  but problem occurs on customers machines.
0
I was having a heck of a time trying to create a report in Visual Studio 2017.  I removed references to version 9 and installed 150.1400 from nuget and added the references back.  I was never able to get a report viewer onto a form.  It always ended up at the bottom as a component like the timer or backgroundworker.  I uninstalled 2017 and installed 2019 after hours of unsuccessful google fu trying to fix it.  2019 allows me to drop a report viewer onto a form but I am missing the add new item - report option.  So now I can drop a report viewer onto a form but I can't add an RDLC to my winforms project.  I may go back to VS 2010 where things just worked...This is crazy frustrating.

Any ideas on getting the report creation option into the menu?

Thanks
screen shot references
0
Hello All,

I tried to create an ASP.NET MVC CORE web project using Visual Studio 2019 Community. But when I am right-clicking on Model Folder >> Add A New Item>>
I am seeing “ADO.NET Entity Data Model” under [Data] tab. Can someone explain what I need to do so that I can see “ADO.NET Entity Data Model” under [Data]  ?

Thank you
ADO-NET-Entity-Data-Model.docx
0
This is Windows Forms, C#.

I have a Dataset with 3 datatables.  For datatable ST_MER_POS_Product_Online_List_AA, I want to only keep the rows that have been changed.

1. This is is how I check if the datatable has rows changed:
                  var ttest = IsDataSetChanged(Onlineds); //**** check to see if row is changed
                //var p = Onlineds.ST_MER_POS_Product_Online_List;

               ws.UpdateOnlineProducts_AA(Authorize.MAC_IDs, Onlineds); //call to update 
                this.Onlineds.AcceptChanges();

Open in new window


2. Check to see if row has changed or not
 public bool IsDataSetChanged(DataSet m_DSet)
        {
            if (m_DSet == null)
                return (false);

            foreach (DataTable dt in m_DSet.Tables)
            {
                foreach (DataRow dr in dt.Rows)
                {
                    if (dr.RowState != DataRowState.Unchanged)
                        return (true);
                    
                }
            }
            return (false);
        }

Open in new window


3. I  tried dr.Delete(); but I think it deleted all the rows

 public DataSet IsDataSetChangedOnlineProduct(DataSet m_DSet)
        {
            if (m_DSet != null)
            {
                foreach (DataTable dt in m_DSet.Tables)
                {
                    //var p = dt.Rows.Count;

                  //  var p = dt.GetChanges();

                    foreach (DataRow dr in dt.Rows)
                    {
                       if (dr.RowState == DataRowState.Unchanged) 
                       {
                          dr.Delete();

                       }



                    }
                }

                m_DSet.AcceptChanges();

                return m_DSet;
            }


            return m_DSet;
        }

Open in new window


How can I do this?
0
Why do some of my .aspx pages add this to the URL? (ex. www.url.com/filename.aspx?_ga=2.176514797.910954863.1579199334-2140930447.1563381308

I don't know why it adds ?_ga=2.176514797.910954863.1579199334-2140930447.1563381308 to the end of the URL when I bring the file up in the browser. Is that something that I'm doing wrong?
0
I understand that this is not easy to debug and help with but I'm posting some screenshots...hopefully someone can give me an idea where to look and how to do this...

(My first day of working with Crystal Reports and I'm not a CR developer )

1. The report looks like this. You see the tab "Main Report"? I want to add another tab but I don't know how this tab is built. I did a search in the code for "Main Report" and I don't find it. Did a search in stored procs and I don't see "Main Report". Did a search in our Web Services code and I don't see the word "Main Report"
EE-CR.png
2. The report itself looks like this and I see the file

EE-CR-2.png
3. This is the Windows Forms that's the container. Maybe I need to check all the User Controls but still....where is that tab coming from?

EE-CR-3.png
It's ok if no one can help.  I know it's hard to debug it without the code. I can ask my manager if it's ok to give the code and someone here could tell us how this all comes together.
0
Hi, I have an question about what language or technology I can use to do following.
Let say I have an image normally shows as  rectangle with height and width.
I need to transform this image into circle . The same bitmap but not rectangular form but circle form.
Can you suggest what I can use to do this. I program in C#, C++, vb using Visual Studio 2019. If I
need to use another language it is no problem.
0
I encountered some C# WPF code (written by other people) and I think the problem they were trying to solve was displaying a message window from a background thread, and getting the error "The calling thread must be STA, because many UI components require this."

So it looks like they decided to fix this by creating their background thread and setting the ApartmentState to STA before running it.

I'm skeptical if this is a valid solution.

I'd like to know if I can prove this can lead to problems, or is there some official documentation somewhere that says "Don't do this."

(Because I eventually need to make a decent argument that will be convincing to others.)

(I'm used to instead using Dispatch to run code on the UI thread.)

(I do admit there is a need to somehow deal with "the background thread encountered a problem and we need to tell someone about it". I suspect setting the background thread to STA is not the proper solution.)
0
Working on my first Crystal Report code. It was done by another developer and now I have to make changes to it.

The datasource is a stored proc. I added a new column.

How can I bind the column from the stored proc to the field? The other fields are already there. It's the Phone field I need to add.

EE-CR.png
0
Can you please tell me why its not starting the apache server?  Thanks.
screenshot.JPG
0
I'm having to support an ancient VB6 application. Currently, I'm writing a COM object class for it. Everything works except for assigning a value to a property. This particular property needs to behave like a VB6 variant data type when used in VB6 code.

I have the simplest little class in C#
    [ComVisible(true)]
    [Guid("1EB35E9B-60EE-4A26-BAEB-6A2D7AC32FF0")]
    [ClassInterface(ClassInterfaceType.AutoDual)]
    public class FooThingy
    {
        private object _value;

        public object Value
        {
            get
            {
                return _value;
            }
            set
            {
                _value = value;
            }
        }

        public FooThingy()
        {

        }
    }

Open in new window

And I call it via the simplest VB6 code. I have added line numbers for easy reference.
Public Sub Main()
    
1    Dim foo As FooThingy
2    Set foo = New FooThingy
3    If (foo.value <> "hello") Then
4        foo.value = "Testing"
5    End If

End Sub

Open in new window

At line 4 it fails with a runtime error 424 "Object required" yet line 3 evaluates with no problem. I know VB6 has this weird distinction between Property Let and Property Set and I'm guessing that is somehow related. What I need to figure out is how do I get my C# class to work with the VB6 code above. Perhaps there's some kind of marshaling declaration that will do the trick? I'm really hoping there's an answer to this because my alternative is to go through this very old VB6 program that was very badly written and find all the places where assignment is being done and replace it with a SetValue() method call which DOES work.
0
Hello Experts,

I have a textbox(input) when user enter accept only numbers(digits only) and it should be 10. Once entered we need for format like (123)456-7890. I tried below but not working as expected.
CSHTML
 <input type="text" id="PhoneNumber" name="PhoneNumber" value="" class="form-control" autofocus="autofocus" maxlength="11">
                                <span class="bar" id="ErrMsg" ></span>
                                <label for="PhoneNumber">Phone</label>

Open in new window


JS
$("#PhoneNumber").keypress(function (e) {
    //if the letter is not digit then display error and don't type anything
    if (e.which != 8 && e.which != 0 && (e.which < 48 || e.which > 57)) {
        //display error message
        $("#ErrMsg").html("Digits Only").show();
        return false;
    }
});

$("#PhoneNumber").blur(function (e) {
    phone = $(this).val();
    if (phone.length != 10) {
        $("#ErrMsg").html("Phone number must be 10 digits.").show().fadeOut("slow");
        return false;
    }
    else
        $(this).val($(this).val().replace(/^(\d{3})(\d{3})(\d)+$/, "($1)$2-$3"));
});

Open in new window


I have couple of issues with the above code, first I did Maxlength 11 then only it's accepting 10 digits and also I get format like this (123)456-0 (since my maxlenght was 11). After changing Maxlength to 14, I still get same issue. Please suggest how can I solve this.

Thanks,
ASPDEV
0
Coding in ASP.NET and C#

Hello Experts,
I am trying to run a Windows Service job only once everyday at a time specified in App.Config file.  How can I use make use of Timer class?  As soon as the job is done, the job will go to sleep mode and again wake up next day.  Is there a simple way?

Here is the requirement.

 1. Process Schedule Task
    Add code to Process the task here
    .
    .

 2. Once the job is executed, reset next run to every 24 hours

Thank you very much in advance!
0
I have installed the visual studio 2019 community but after some days it showing that my license has expired and I cant use it. Weird because it’s a community edition so shouldn’t it be free? I have done a ton of things – restarted my pc, reinstalled but still the same issue. Can someone guide here…what’s going on?
Thanks
VS-weird-issue.png
0
I am working on a desktop application using C#, WPF, and .net core 3.1. I was reading on Microsoft's website that DataGrid was being deprecated and should be replaced with DataGridView in .net core 3.1 applications. The issue I am having is that it doesn't seem to actually be supported or at least according to Visual Studio 2019. First, the DataGrid tool still exists in the toolbox while DataGridView does not. In addition, even if I manually type the DataGridView code in VS2019, the code is shown as invalid code. I was looking online and have been having issues finding any info on this so I am guessing I am doing something wrong.

My question is what should I be using, DataGrid of DataGridView? Being it is a new application I would have preferred to use the most up to data version (DataGridView) so my code doesn't break in a year, but if I have to still use DataGrid, I will.
0
Hello Experts,
I am trying to create a Windows Service project, which uploads data from an API.  In one class, I am trying to access an external class name ManageData, with in the same project.  But, getting the below error message.  Please see the attached picture.  Please let me know how to fix it.  Thank you in advance.

Error      CS0246:      The type or namespace name 'ManageData' could not be found (are you missing a using directive or an assembly reference?)

Thank you!
Service.png
0
Hello Experts!
I have gotten an issue dumped in my lap. I am a SysAdmin by trade and enjoy my craft, not developing and here is just why:

We offload our SSL to a HA pair of Load Balancer. That works fine. Traffic comes in HTTPS, gets converted to HTTP and ships it along to the server (Server 2012 R2).
So here is where things get messy:
This application is built with .NET Core 3.1. On the server, going HTTPS to the site everything runs without issue (it requires a login). Going HTTP to the site it just boots you back out to the login screen, no error no warning, just login over and over. The Dev claims it to be a security feature to ensure traffic is secure (which I understand) and per the Dev cannot be turned off (core doesn't allow it to be off, which I don't understand).
Going through the Load Balancer yields the same result as HTTP on the server (makes sense as it is being delivered there as HTTP).

Here where the assistance is needed.
In the Load Balancer we header tag the following:
HTTP_FRONT_END_HTTPS               On
HTTP_X_FORWARDED_PROTO       https
HTTP_X_FORWARDED_FOR       (client IP)

The headers get modified, I requested that a full header site be placed there for viewing, and they are being tagged.
Not sure why Forwarded_For needs to be there but here we are.

This should allow .NET Core 3.1 to see the load as HTTP, but alas it does not. I think it is an app problem, but here we are with it now being my issue.

Thank you as always for any assistance that …
0
Hello Experts

I recently had a question open about web hosting. One of my replies to an expert that commented included my current employment situation.  I am at a crossroads with my IT career.   I have 20yrs of experience in IT.  Unfortunately most of the yrs are of very narrow/specific experiences.  I most recently went to a Full Stack Developer boot camp with hopes of it aiding in my job search. I have not found a match yet. So, I am in "survival" mode.  I created a LLC and am doing my own landscaping and courier work just to pay the bills.

David Favor suggested I open a new question and ask for help.  I have attached my resume.  Can you take a look at it and offer feedback/suggestions on where to go with my career?  Perhaps there is a hole that needs filled with online coursework or self-paced learning.  I am open to branching out of the development arena into a different area of IT.

Thank you,
jimbo99999
EdDobiasResume.doc
0
I'm working on a Windows Forms application/desktop written in 2002. Yes, you read that right.... Windows Forms that uses Crystal Reports.

We can't upgrade the code to web at this time. Too many clients on it and the owner doesn't want to invest in a web application.

We want to replace the Crystal Reports section of this application.

These are some of the options we've been talking about:

1. SSRS (a developer here said SSRS is being replaced)
2 . Power BI - how would this work with an old code like the one we have?
3. A developer here said we can write the stored procs and have one of the web developers design and code the pages. Custom web pages that act like reports. Don't think we can do this because clients are not setup for web. They all use our desktop application.

A developer here is pushing for Power BI. I don't know how it would work with Windows Forms/desk top.

Any ideas?
0

.NET Programming

134K

Solutions

39K

Contributors

The .NET Framework is not specific to any one programming language; rather, it includes a library of functions that allows developers to rapidly build applications. Several supported languages include C#, VB.NET, C++ or ASP.NET.