C#

91K

Solutions

32

Articles & Videos

24K

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

Hi Experts,

 Dim LockTime As String = "2:00 PM"

I want to subtract 2 hrs and want the value "12:00 PM"

Thanks in advance
0
Independent Software Vendors: We Want Your Opinion
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Hi Experts,

Just trying to view the data that comes with this tutorial:-

https://www.codeproject.com/Tips/869986/CRUD-operation-with-Entity-Framework-Code-First

when I can across the above error. Throughout the tutorial, there was no mention of connecting to my own server or database.

This is what I have on the webconfig:-
Data Source=(localdb)\Projects;Initial Catalog=OrganizationEmployeesCF;Integrated Security=True

I have replaced the datasource to mine but still no lock
Does anyone know a work around?

Cheers

Mike
0
Hi Experts,

I want to create a global variable and use it throughout the program.  I am using  "Public Action As String". But it does not work.
What should I do?

Thanks in advance.
0
Hi Experts,

This is my program. I am using some private variable to hold the values. Then I am using them through out the program. I want to know is it the right way to do or I should keep them in the session variable and use them. I am curious to know that when many people access the same web page are these variables going to create problem or change the values.  I am using ASP.net and VB.net.

Thanks in advance.


Partial Class EditCustomerOrder
    Inherits System.Web.UI.Page
    Private Shared Calling_Form As String
    Private Shared CustomerID As Integer
    Private Shared LocationID As Integer
    Private Shared MenuOrderDate As DateTime
   
    Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load
        If Not IsPostBack Then
            Calling_Form = Request.QueryString("Calling_Form")
       
            If Session("EditCustOrder_Calling_Form") Is Nothing = False Then
                Calling_Form = Session("EditCustOrder_Calling_Form")
            Else
                Calling_Form = Request.QueryString("Calling_Form")
            End If

            If Session("EditCustOrder_MenuOrderDate") Is Nothing = False Then
                MenuOrderDate = Session("EditCustOrder_MenuOrderDate")
            Else
                MenuOrderDate = Request.QueryString("MenuDate")
            End If
0
I would like to take this code and have it be reused for different stored procedures. This section of code would be called for each the the button on the form below. I have all the datatable, dbcommand, executenonquery, executescalar all in one c# class and call them when I need them I need to do this for the dataset code below

String connString = “”;

string sql = “select” – I would like to use a procedure so I can use the code in more than one place.

// create connection
Sqlconnection conn = new sqlconnection(connstring);

Try
{
Conn.open();

Sqldataadapter da = new sqldataapapter(sql, conn);

Dataset ds = new dataset();

Da.fill(ds, “”);
 
(would like to return ds.table
}
Catch
{
}
Finally
{
Conn.close();
0
Hi Experts,

How to create a public variable which can be used only in the form. Suppose I have form1.aspx. How can I define a public variable which can be used only in form1 .no other form should able to access it.
0
I have this code

public ActionResult GRIDPRINTS_Read(int woid, [DataSourceRequest]DataSourceRequest request)
        {
            IQueryable<GRIDPRINTS> gridprints = db.GRIDPRINTS;
            DataSourceResult result = gridprints.ToDataSourceResult(request, c => new GRIDPRINTS
            {
                WOID = c.WOID,
                GRIDPRTID = c.GRIDPRTID,
                GRIDID = c.GRIDID,
                MAPNAME = c.MAPNAME,
                SCALE = c.SCALE,
                PAGENUMBER = c.PAGENUMBER,
                ERRORS = c.ERRORS,
                STATUS = c.STATUS,
                NOTIFICATION = c.NOTIFICATION
            });

            return Json(result, JsonRequestBehavior.AllowGet);
        }

Open in new window


IT works fine Except I want to pass the woid to a where clause in the results.  So I added this line

.where(c.WOID==woid)    

public ActionResult GRIDPRINTS_Read(int woid, [DataSourceRequest]DataSourceRequest request)
        {
            IQueryable<GRIDPRINTS> gridprints = db.GRIDPRINTS;
            DataSourceResult result = gridprints.ToDataSourceResult(request, c => new GRIDPRINTS
            {
                WOID = c.WOID,
                GRIDPRTID = c.GRIDPRTID,
                GRIDID = c.GRIDID,
                MAPNAME = c.MAPNAME,
                SCALE = c.SCALE,
                PAGENUMBER = c.PAGENUMBER,
                ERRORS = c.ERRORS,
                STATUS = c.STATUS,
                NOTIFICATION = c.NOTIFICATION

             .where(c.WOID==woid)   

            });

            return Json(result, JsonRequestBehavior.AllowGet);
        }

Open in new window


It is failing with unknown method "where of string"  I am sure it is something simple stupid but after an hour of trying everything I am turning to the experts.
0
How can I convert

Example

32 to 0x20
 
A to 0x41

96 to 0x600x000x000x00

65736 to 0xC80x000x010x00

and back again.
0
After I added a sidebar and repositioned my items I had this error!

Codes from the source
            <tr>
                 <td>
                    <div class="col-sm-4">
                         <div class="thumbnail bg-grey text-center">
                             <h2>$14</h2>
                             <p>Basic License</p>
                             <a href="#" class="btn btn-success" role="button">Buy Now</a>
                         </div>
                     </div>  

              <div class="col-sm-8">
                  <asp:Panel  ID="Panel1" runat="server" cssClass="pnlEvents" ></asp:Panel>
             </div>
                 </td>                
             </tr>

My code behind error            

Line 52:
Line 53:                 //Add dynamic Panes to static Parent panel
Line 54:                 pnlEvents.Controls.Add(eventPanel);
Line 55:
Line 56:             }
0
Hi Experts,

I am testing my project in multiple computers and found a serious problem.

In Machine 1
I log in as an Admin. Then In the page I have to select Customer, location and Room. Then I click OK to go to a different page. (Sesson Admin='Y')

Then in Machine 2, I log in as a user.  select Customer, location and Room. Then I click OK to go to a different page (Sesson Admin='N')

When I come back machine 1 , where I logged in as Admin='Y' before, it changes it to Admin='N'  and all the selection (Customer, location and Room) has changed to that of machine 2.

What should I do. Please help.

Thanks in advance.
0
Technology Partners: We Want Your Opinion!
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

<asp:GridView ID="grdAdmin" runat="server" AutoGenerateColumns="false" GridLines="None"  CssClass="table table-condensed table-hover table-striped small" data-toggle="bootgrid">
                <Columns>
                    <asp:BoundField HeaderText="#" DataField="ID"  />
                    <asp:BoundField HeaderText="TableID" DataField="TableId" />
                    <asp:BoundField HeaderText="FieldName" DataField="FieldName" />
                    <asp:BoundField HeaderText="isKey" DataField="isKey" />
                    <asp:BoundField HeaderText="canEdit" DataField="canEdit" />
                    <asp:BoundField HeaderText="canFilter" DataField="canFilter" />
                    <asp:BoundField HeaderText="FilterTypeID" DataField="FilterTypeID" />
                    <asp:BoundField HeaderText="SortOrder" DataField="SortOrder" />
                    <asp:BoundField HeaderText="Active" DataField="Active" />
                    <asp:CommandField HeaderText="" />
                </Columns>
            </asp:GridView>


 private void grdAdmin_RowCreated(object sender, GridViewRowEventArgs e)
        {
           
            if (e.Row.RowType == DataControlRowType.Header)
            {
                e.Row.Cells[0].Attributes.Add("data-column-id", "ID");
                e.Row.Cells[0].Attributes.Add("data-identifier", "true");
                e.Row.Cells[0].Attributes.Add("data-type", "numeric");
                …
0
Hi,

I have a form form1 with a datagrid. But i call a second form form2 to made a query, to return only some records. I need to return a datatable to form1 and automatically fill a datagrid.
What is the best way to return a datatable from form2 to form1.

best regards
0
Hello Experts,
This customer of ours has a LAN with three mac OSX Yosemite,
procesor Intel 2.7 Ghz Core I5
8 Gb Ram 1600 Mhz DDR3

Inside each mac there is parallels with WIN 10 and our APP
Now our app works with MYSQL  and visual c# ,,,,
one of the MAC works as a server and the other two are stations consulting/updating the server,

All three macs are wireless and too slow
is it true.... if I switch to network cable instead of wifi,
 it may be faster at least something faster that we can notice ?

And what can I do to make these mac faster..
clearly they have not had any proper maintenance before...

but also is parallels also making it even much more slower??
not win 10 inside parallels shows a network speed of 1 GB is this reliable ?
Regards,
0
I have a Windows forms application. Part of what it does is copy 2 files. Is there a way I can include these files in the executable without having an installer?
0
I need to change the text on the Open button in OpenFileDialog.   How can I do that.  I googled around and it all seems to want to customize the whole dialog to add jpg's, etc.   I want it to stay the same, except different text on the open button.  I am using Winforms.  How?
thanks!
0
The below code is translated from C++ to C# but the row,  mask = -(crc & 1);  will not be compiled. Cannot implicitly convert type  'long' to 'uint'. If I change from uint to long I get the wrong result.  How can this be solved?

private uint crc32(byte[] message, int len)
{
      int i;
      int j;
      uint @byte;
      uint crc;
      uint mask;

            crc = 0xFFFFFFFF;
            for (i = 0; i < len; i++)
            {
                  @byte = message[i];
                  crc = crc ^ @byte;
                  for (j = 7; j >= 0; j--)
                  {
                        mask = -(crc & 1);
                        crc = (crc >> 1) ^ (0xEDB88320 & mask);
                  }
            }
            return ~crc;
}
0
Hi experts,

I've made a console app that basically does this:

1. Open .xlsx file
2. save the worksheet called "Load" as a xlCSV using Office.Interop.Excel. Code also attached.

// Get fully qualified path for xlsx file
            var spreadsheetLocation = Path.Combine(@"E:\SGGG\LBD", "LastBusinessDay.xlsx");

            var exApp = new Application();
            exApp.Visible = false;
            exApp.DisplayAlerts = false;
            var exWbk = exApp.Workbooks.Open(spreadsheetLocation);
            var exWks = (Microsoft.Office.Interop.Excel.Worksheet)exWbk.Sheets["Load"];

            exWks.SaveAs(@"E:\SGGG\LBD.csv", XlFileFormat.xlCSV);
            exWbk.Close();

The code all works fine if i just run the .exe file manually. However, I need to schedule this so that it runs once a day by Windows Task Scheduler and this is where it runs into problems.

I've told the task to run whether user is logged on or not and run with the highest privileges. Action is pointed to the .exe file of my console app. Again, if i run it outside of scheduler, it works as expected. When I run it in scheduler, it tells me successful but no csv is saved and Excel hangs in the background (i have to end task in task manager)...

Supremely weird. Please help
0
Hi Experts,

I have a date picker control.  I have three categories of dates.

1. Menu Available - If menu available for that date then change its color. Which I can do right now.

2. Customer Order available - If Customer order available then change its color to a different color(This web method has a CustID parameter).

3. If the date is a holiday, then disable it.

Thanks in advance.
0
On the click of a button, I want the program to wait and detect an inserted thumb drive, then return the drive letter. Does anyone have a WinForms C# example of something similar? I'm really only concerned with Windows platform, particularly Win7.
0
On Demand Webinar - Networking for the Cloud Era
LVL 9
On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Hi,
Is there one example to read each message, one by one, for one specific text string, within Sent folder of Outlook?
0
Why do I get this error at line24 ??

Line 23:             //fill pg w data
Line 24:             lblPrice.Text = "Price per unit: <br/>$ " + detail.eventPrice;
Line 25:             lblTitle.Text = detail.eventDetailName;
Line 26:             lblDescription.Text = detail.eventDesc;
0
Hi there, i have two data tables 1 that queries the informix database and 2nd one consist of daily customer file. so my task was to take the daily generated customer file compare it to the 1st datatable and if there are not matches consider it to be a new customer and then if there is a match i need to check to see if the other fields have been changed and add it to the file as changed customer.
DataTable tblSamebutotherchanges =  (from r in FirstDataTable.AsEnumerable()
                    join s in SecondDataTable.AsEnumerable()
                    on r.Field<string>("Customer") equals s.Field<string>("Customer")
                                     where r.Field<string>("Name") != s.Field<string>("Name") ||r.Field<string>("ADDRESS").ToUpper() != s.Field<string>("ADDRESS").ToUpper() || r.Field<string>("ADDRESS 2") != s.Field<string>("ADDRESS 2") || r.Field<string>("CITY").ToUpper() != s.Field<string>("CITY").ToUpper() || r.Field<string>("STATE") != s.Field<string>("STATE") || r.Field<string>("ZIP CODE").Substring(0,5) != s.Field<string>("ZIP CODE").Substring(0,5) || r.Field<string>("PARENT") != s.Field<string>("PARENT") || r.Field<string>("TELEPHONE") != s.Field<string>("TELEPHONE") || r.Field<string>("FAX") != s.Field<string>("FAX") || r.Field<string>("TERMS OF PAYMENT") != s.Field<string>("TERMS OF PAYMENT") || r.Field<string>("COUNTRY") != s.Field<string>("COUNTRY") || r.Field<string>("CURRENCY") != s.Field<string>("CURRENCY") || r.Field<string>("STATUS") != 

Open in new window

0
Hi Experts,

I have a textbox which accepts a date  for example "06/21/2017".
I use "prmDateClosed = New SqlParameter("@DateClosed", txtDateClosed.Text.Trim)" to save into the table. The data type of the field in the table is "Datetime". It saves in the table as "2017-06-26 00:00:00.000". When I retrieve it back in a gridview it displayes "6/21/2017 12:00:00 AM ". I just want to save in the table as "06/21/2017".  and retrieve as "06/21/2017".

Thanks in advance.
0
My Css is not applying . Here is the codes from code behind!!!

        //Get list of all products in DB
        EventDetail eventDetail = new EventDetail();
        List<EventDetail> details = eventDetail.getAllEventDetail();

        //Make sure events exist in database
        if (details != null)
        {
            //Create a new panel with an image button and 2 labels for each event
            foreach (EventDetail detail in details)
            {
                Panel eventPanel = new Panel();
                ImageButton imageButton = new ImageButton();
                Label lblName = new Label();
                Label lblPrice = new Label();

                //set childcontrols' properties
                imageButton.ImageUrl = "~/EventImages/Events/" + detail.eventImage;
                imageButton.CssClass = "eventImage";
       
                imageButton.PostBackUrl = "Detail.aspx?id=" + detail.EventDetail_ID;

                lblName.Text = detail.eventDetailName;
                lblName.CssClass = "eventName";

                lblPrice.Text = "$ " + detail.eventPrice;
                lblPrice.CssClass = "eventPrice";
               
                //Add child controls to panel
                eventPanel.Controls.Add(imageButton);
                eventPanel.Controls.Add(new Literal { Text = "<br />" });
                eventPanel.Controls.Add(lblName);
                eventPanel.Controls.Add(new Literal { Text = "<br …
0
When I use FileInfo to return the size of a file for me, it is returned in bytes. The code is simple enough.
FileInfo fi = new FileInfo(filePath);

Open in new window

The code then returns 16599774 bytes for the file in question.
size in bytesI then convert it to Megabyte by using the following code in an extension method.
return (bytes > 0) ? (bytes / 1024f) / 1024f : bytes;

Open in new window

I return the MB size as follows:
$"{Round(fileLength.ToMegabytes(),1).ToString()} MB";

Open in new window

I see that the size returned is 15,8 MB. When I look at the file properties however, I see this:
file propertiesWhen I view the file in Windows Explorer, I see a different size again
explorer sizeMy question is this:
1. Why the difference in file sizes between 15.8 MB and 16 599 774 bytes that I am seeing in code and in the file properties? Does it have to do with the data types? The bytes being long and the MB being double?
2. Why is the file size in Windows Explorer different again at 16 211 KB?
I understand why there is a difference between Size and Size on disk, but not between bytes and MB.
0

C#

91K

Solutions

32

Articles & Videos

24K

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).

Top Experts In
C#
<
Monthly
>