Improve company productivity with a Business Account.Sign Up

x

.NET Programming

133K

Solutions

38K

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

I am trying to convert VB.Net Process object arguments to C#. Please help me resolve the errors.

This VB code works:
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOK.Click

        Dim startInfo As New ProcessStartInfo
        startInfo.FileName = "C:\Program Files (x86)\Visual CUT 11\Visual CUT.exe"
        startInfo.Arguments = "-e ""C:\test_3\People_1.rpt"" ""Export_Format:Adobe Acrobat (pdf)"" ""Export_File:C:\test_3\People_1.pdf"""
        Process.Start(startInfo)
    End Sub

Open in new window

This C# code contains the errors:
      psi.Arguments = "-e ""C:\\test_3\\People_1.rpt " +
            "Export_Format:Adobe Acrobat (pdf) " +
            "Export_File:C:\\test_3\\People_1.pdf"";

Open in new window

Full sub code:
       private void btnOpenPDF_Click(object sender, EventArgs e)
        {
            Process p = new Process();
            ProcessStartInfo psi = new ProcessStartInfo();
            psi.UseShellExecute = true;
            psi.FileName = "C:\\Program Files (x86)\\Visual CUT 11\\Visual CUT.exe";
            psi.Arguments = "-e ""C:\\test_3\\People_1.rpt " +
            "Export_Format:Adobe Acrobat (pdf) " +
            "Export_File:C:\\test_3\\People_1.pdf"";
            p.StartInfo = psi;
            p.Start();
        }

Open in new window

The following screenshot shows the C# errors:
Code Errors
0
Free Tool: SSL Checker
LVL 12
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

1. I bought this template http://www.tattek.sk/minotaur-dash2/#/app/dashboard
and I'm customizing it.

2. On the link above, click on the "hamburger" on top. You see how the side menu shrinks and the main content expands
works
3. In my site, the side menu shrinks but the main content doesn't expand

You can see it here:

Site: http://147.75.0.117:88

Login with admin@admin.com / Password321$

doesn't work
4. I checked the Chrome Developer's tool and I see the CSS tag being added

css
5. I also put debug step in the demo site (I have the code locally from Themefoest).. There's a function setSmallNavigation() but  I commented it out and the demo still worked.

I'm not sure what I'm missing.
0
What are the steps to migrate an asp.net app using .net framework 4.0 to 4.5 using Visual Studio 2017?
0
Created a service using C# .NET.  How do I add the service to services.msc?
0
I want to show DropDown list of Availabe .resx files from Resources folder on viewpage inorder to display selected .resx contents. I displayed the contents but how can i show dropdown of the available .resx files ???
0
What steps can I take to determine what version  of.Net a Mac OS X computer is already running?
0
Is it possible to load .Net on a Mac?

If so what is the URL address to download the latest version of .Net for Mac OS X?
0
Hi EE,

I am upgrading a few windows servers that host a variety of bespoke applications is there any software or PowerShell commands I can use  to scan for .net Library Alternatives:

Alternatively is there anywhere I can check in the Windows Registry for a listing of installed .net libraries.

https://stackoverflow.com/questions/2943415/microsoft-enterprise-library-alternatives.

Thank you.
0
I'm working on a side project... it's forms with names, address, and other info. One of the fields is SSN.

I plan to encrypt the name and address fields. I can encrypt SSN as well but with all the cyber security issues going on... I'm thinking I shouldn't even store SSN or only store the last 4 digits.

The application will be hosted on a hosting server (ARMOR) eventually.

Any thoughts on if I should store SSN and encrypt or just leave out SSN? users can always search by name.
0
This code works. I've used LINQ to SQL on some projects but now wondering if there's a better way of coding this. I'm using stored procs and I want to see if I can use parameters for the stored proc. I don't want to use Entity Framework

1. I have a DBML
2. I have a stored proc
3. I have a model

4. I call the stored proc like this

 

  private LPDataContext _dbContext;
        public FormsRepository()
        {
            _dbContext = new LPDataContext();
        }

_dbContext.usp_InsertPersonali765Draft(model.ApplyReasonId, firstName, model.MiddleName,
                    familyName,
                    otherFirstName1, model.OtherMiddleName1, otherFamilyName1, otherFirstName2,
                    model.OtherMiddleName2,otherFamilyName2, otherFirstName3, model.OtherMiddleName3, otherFamilyName3,
                    streetAddress, model.AptNumber, city, model.StateId, model.ZipCode,
                   int.Parse(model.CountryOfNationality),
                    model.BirthCity, model.BirthState,int.Parse(model.CountryOfBirth), dateOfBirth, model.Gender,
                    model.MaritalStatusCode, model.UserName);

Open in new window


Is this code ok? should I leave it as is?  

How can I call the stored proc with parameters? This is an example of Linq to SQL insert but it doesn't use a stored proc Example

Another one here but it's not a stored proc Another example

EDIT: I'm concerened about SQL Injection but maybe how I have it is correct. See here Example 3 It says
Linq to SQL turns the curly braces into a parameterized query.
0
Upgrade your Question Security!
LVL 12
Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

I'll go step by step. I wonder why blank gets inserted instead of null

1. This is in the model
public string MiddleName { get; set; }

Open in new window


2. Database column is this
[MiddleName] [varchar](250) NULL,

Open in new window


3. I don't enter anything in  the middle name field
screen
4.  I have this line of code

 var middleName = string.IsNullOrEmpty(model.MiddleName) ? (object) DBNull.Value : model.MiddleName;

Open in new window


5. I see the value is null
null value
6. I see this after the line of code is executed
value of middle name
7. I call a stored proc and insert it like this. I out .ToString() because I was getting an error that Object can't be converted to string

 
  _dbContext.usp_InsertPersonali765Draft(model.ApplyReasonId, firstName, middleName.ToString(),
       ....

Open in new window


8.  This is part of the stored proc

ALTER procedure [dbo].[usp_InsertPersonali765Draft]


@ApplyReasonId int,
@FirstName varbinary(max),
@MiddleName varchar(50),
.....

Open in new window


9. I see blank . I want to save Null

db
0
Need to increase speed of code.  The below code works.  The problem is that I am receiving approximately 4,000 records from the Stored Procedure.  The below process is taking a long time to process.  I believe it is occurring at EnumValidation.FindFields.

Any idea how to speed up the process?
public List<T> SelectSPROC(string sprocName, List<Parameters> parameters) 
        {
            List<T> result = new List<T>();

            try
            {
                using (SQLConn = new SqlConnection(ConnectionStrings.GetConnectionString()))
                using (SQLCmd = new SqlCommand())
                {

                    SQLCmd.CommandText = sprocName;
                    SQLCmd.CommandType = CommandType.StoredProcedure;
                    SQLCmd.Connection = SQLConn;
                    SQLCmd.CommandTimeout = 0;

                    if (parameters.Count > 0)
                    {
                        for (int i = 0; i < parameters.Count; i++)
                        {
                            SQLCmd.Parameters.AddWithValue(parameters[i].parameterName, parameters[i].parameterValue);
                        }
                    }

                    SQLConn.Open();

                    SQLRdr = SQLCmd.ExecuteReader();

                    while (SQLRdr.Read())
                    {
                        T t = new T();  

                        for (int inc = 0; inc < SQLRdr.FieldCount; inc++)
                        {
                            

Open in new window

0
I am trying to use a variable in place of a command line argument, but the application (Visual Cut) will not run. There are no Visual Studio error messages. Please help me resolve the error.
Code that causes error:
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOK.Click

        Dim retval As String
        Dim ls_temp As String
        Dim Argu2 As String
        Argu2 = """Export_File:C:\test_3\People_1.pdf"""

        ls_temp = """C:\Program Files (x86)\Visual CUT 11\Visual CUT.exe"" " & _
"-e ""C:\test_3\People_1.rpt"" ""Export_Format:Adobe Acrobat (pdf)""" + Argu2
        retval = Shell(ls_temp)
    End Sub

Open in new window

There are no errors when this code runs:
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOK.Click

        Dim retval As String
        Dim ls_temp As String

        ls_temp = """C:\Program Files (x86)\Visual CUT 11\Visual CUT.exe"" " & _
"-e ""C:\test_3\People_1.rpt"" ""Export_Format:Adobe Acrobat (pdf)"" ""Export_File:C:\test_3\People_1.pdf"""
        retval = Shell(ls_temp)
    End Sub

Open in new window

0
I need to scan hundreds of QR codes as quickly as possible and save them to a .txt file that can be read by Excel.

I've read the reviews and the I-nigma QR code reader stands out, available at http://www.i-nigma.com/Downloadi-nigmaReader.html

More helpful information is at:  http://i-nigma.com/qr-barcode-reader-sdk.html

But I can't find a User's Guide.

In the past I've done this by:  a)  Scan the QR code, then b) paste the result into Notes on my phone.

If there is a better QR code reader that can more intuitively save the results to some kind of log file, I'd love to hear about it.

Thanks.
0
I'm using HtmlAgilityPack to traverse some html  
Given the code I've created a dotnetfiddle

How do I get the number from the current div selected ID?
I'm extracting text from Red and navy fonts is this the best way to do it? and how Do I know what the exception is

I've not got this far yet but given an image url and a file path what is the best way to save an image
0
I'm interested in getting information on obtaining an MSDN subscription such as eligibility, prices, licensing details, etc.

Where can I get this information from?
0
Hi

How do I replace '\"' with '"' globally in C#
Backslash  Double Quotes replace with Double Quotes
and remove Double Quotes from the end of a string

string MyString = "Lorem \"ipsum\" dolor sit amet \"consectetuer\" ultrices turpis Phasellus et odio. Urna."";
MyString.Replace('\\"', '"'); // Error CS1012  C# Too many characters in character literal
MyString.Replace("\\"", "\""); didn't work

Console.WriteLine(MyString);
// Expected output
Lorem "ipsum" dolor sit amet "consectetuer" ultrices turpis Phasellus et odio. Urna.

Open in new window

0
Working on a puzzle.

Given an array a that contains only numbers in the range from 1 to a.length, find the first duplicate number for which the second occurrence has the minimal index. In other words, if there are more than 1 duplicated numbers, return the number for which the second occurrence has a smaller index than the second occurrence of the other number does. If there are no such elements, return -1.

Below are some sample array's which are being tested.  So, in the code I have when this array  { 2, 4, 3, 5, 1 } reaches 5 I get an out of bound error which makes sense.  Any idea how to solve?
        private void Form1_Load(object sender, EventArgs e)
        {
            int[] a = new int[]{2, 3, 3, 1, 5, 2};
            a = new int[] { 2, 4, 3, 5, 1 };
            a = new int[] {1};

            //Console.Write("The first repeating elements is: ");

            Console.Write("Repeated Elements are :");
            //for (int i = 0; i < a.Length; i++)
            //{
            //    for (int j = i + 1; j < a.Length; j++)
            //    {
            //        if (a[i] == a[j])
            //            Console.Write(a[i] + " ");
            //    }
            //}

            for (int i = 0; i < a.Length; i++)
            {
                if (a[Math.Abs(a[i])] >= 0)
                {
                    a[Math.Abs(a[i])] = -a[Math.Abs(a[i])];
                    //Console.WriteLine("IF: " + a[Math.Abs(a[i])]);
                }
                else

Open in new window

0
I have created an array "pData" of length 5.  The array is to hold 5 pointers to arrays of doubles:

          double*[] pData;
          pData = new double*[5];

I have created an array "data" of length 10 to hold 10 doubles:
          double[] data;
          data = new double[10];

I populate "data" here:
          for (int i = 0; i < 10; i++)
                    data[i] = -1.0;

I get the error "Cannot implicitly convert type 'double[]' to 'double*[]'"

None of these work:
                              //None of these work:
                                    pData[0] = data;
                                    pData[0] = &(data[0]);
                                    pData[0] = (double*)data;

Thank you, in advance, for your help.
0
Free Tool: ZipGrep
LVL 12
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

I am using Dynamics 365 (patch 8.2.0.749).  On the out of the box Quote form, there is a editable grid, that throws the attached error when I attempt to add a part.

Can someone explain how to resolve this?  It is a pop-up dialog error with the following details:

ReferenceError: 'ORG_UNIQUE_NAME' is not defined
   at SetIframe (https://crm.wwm.net/Material/%7B636582967750000749%7D/WebResources/new_QuoteProduct?ver=-1606875395:18:1)
   at eval code (eval code:1:1)
   at RunHandlerInternal (https://crm.wwm.net/Material/form/ClientApiWrapper.aspx?ver=-1606875395:158:1)
   at RunHandlers (https://crm.wwm.net/Material/form/ClientApiWrapper.aspx?ver=-1606875395:117:1)
   at Anonymous function (https://crmtest.wwmh.net/WorldwideMaterialHandling/form/ClientApiWrapper.aspx?ver=-1606875395:101:63)
   at Anonymous function (https://crmtest.wwmh.net/_static/_common/scripts/MicrosoftAjax.js?ver=-1606875395:24:9)

Thanks
0
I'm working on a project at work that's Web Forms, C# and ASP.Net. The code is old.

Instead of using webconfig to hold connection strings and app settings, they have an XML file. In it, they have something like for the connection string

<add value="Server=DVSTL;Database=DVwhatever;Min Pool Size=2" key="Data.ConnectionString"/>

<add value="[enc]encrypted value here==" key="DataDB.CV.PWD"/>

<add value="[enc]encrypted value here=" key="DataDB.UID"/>

Open in new window


There's more in this XML file. There's an XML file for each environment.

Yesterday, we had a meeting about this and my manager said this was done for security because if we have the encrypted connection string in Web Config, someone can get that section...behind a firewall ... and decrypt the values/

I worked at another company last year where all the connection strings were in Web Config and the environemnt was big on security. We even had the dev environment's connection string encrypted.

I suggested removing the XML and just using the web config.

My question is... can web config's connection string... when encrypted.... be stolen and decrypted? with or wothout firewall.
0
I am trying to work with two radio buttons in a simple C# app that allows a user to select and open a PDF using the Process object. One PDF will be assigned to each radio button. The code is shown below. I get the following errors:  (1) "Type expected" and (2) "Cannot convert method group ‘OpenFile’ to non-delegate type ‘string’. Did you intend to invoke the method?" Please help me resolve the error.

The following line causes the error (line 24 in the second code box):
cmd = commands.OpenFile;

Open in new window


Full Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;

namespace CSh_Test1
{
    class commands
    {
        public void OpenFile(string fileName)
        {
            Process p = new Process();
            ProcessStartInfo psi = new ProcessStartInfo();
            psi.UseShellExecute = true;
            psi.FileName = fileName;
            p.StartInfo = psi;
            p.Start();
        }
    }

Open in new window

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

namespace CSh_Test1
{
    public partial class frmOpenPDF : Form
    {
        public frmOpenPDF()
        {
            InitializeComponent();
        }
      
        private void btnOpenPDF_Click(object sender, EventArgs e)
        {
            string fileName = "";
            string cmd;
            cmd = commands.OpenFile;
        }

        private void groupBox1_Enter(object sender, EventArgs e)
        {

        }

        private void frmOpenPDF_Load(object sender, EventArgs e)
        {

        }
        }
    }

}

Open in new window

The following code runs without any errors.

Open in new window

0
Hello,
I am trying to find rowindex of datarow( vb.net desktop). The code is as follows:
 Dim dtDgDiarySource As New DataTable
                                            dtDgtestSource = FrmMain.Dgtest.DataSource
                                            Dim rows As DataRow()
                                            rows = dtDgtestSource.Select("D_UID  = '" & row.Item("D_UID").ToString() & "'")

Open in new window


Cheers
0
I want ExtendedPrice to be calculated from values of two fields below.  I am getting below errors:

"A field initializer cannot reference the non-static field, method, or property 'MyApp.Models.ItemsModel.UnitPrice.get"
"A field initializer cannot reference the non-static field, method, or property 'MyApp.Models.ItemsModel.Total.get"

 public class ItemsModel
    {
        public string CustomerName { get; set; }
        public string PO { get; set; }
        public string DateOrder { get; set; }
        public string Total { get; set; }
        public string UnitPrice { get; set; }
        public string extendedPrice = Convert.ToDouble(UnitPrice) * Convert.ToDouble(Total);
    }

Open in new window


How do I return a calculated field in the model.
0
I am trying to work with two radio buttons in a simple VB.net app that allows a user to select and open a PDF using the Process object. One PDF will be assigned to each radio button. The code is shown below. I get the following error: "Argument not specified for parameter ‘AFileName’ of ‘Public Sub OpenFile(AFileName As String)’." Please help me resolve the error.

The following line causes the error (line 6 in Public Class Form1):
cmd.OpenFile()

Open in new window


Full Code:
Public Class Commands
    Public Sub OpenFile(ByVal AFileName As String)
        Dim psi As New ProcessStartInfo()
        psi.UseShellExecute = True
        psi.FileName = AFileName
        Process.Start(psi)
    End Sub
End Class

Open in new window


Public Class Form1
Private Sub btnOK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOK.Click
        If radPDF1.Checked = True Then
            Dim fileName As String
            Dim cmd As New Commands
            cmd.OpenFile()
            If radPDF1.Checked = True Then
                fileName = "c:\test_3\johnson.pdf"
            Else
                fileName = "c:\test_3\ross.pdf"
            End If
        End If
    End Sub
End Class

Open in new window


The following code runs without any errors.
Public Class Form1
    Public Sub OpenFile(ByVal AFileName As String)
        Dim psi As New ProcessStartInfo()
        psi.UseShellExecute = True
        psi.FileName = AFileName
        Process.Start(psi)
    End Sub

Open in new window


    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOK.Click

        Dim fileName As String
        If radPDF1.Checked = True Then
            fileName = "c:\test_3\johnson.pdf"
        Else
            fileName = "c:\test_3\ross.pdf"
        End If
        OpenFile(fileName)
    End Sub

Open in new window

0

.NET Programming

133K

Solutions

38K

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.