[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x

.NET Programming

133K

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

What's the appropriate way to re-use a sqlCommand and re-execute a datareader in which all I want to change is a parameter value?  See code below.  Note: Executing the Reader in the first iteration works fine, then it bombs on the second iteration of the loop.

        cn2 = New SqlConnection(GlobalVariables.strConn)
        cn2.Open()
        cmd2 = New SqlCommand(m_strNameLookupSQL, cn2)
        cmd2.Parameters.Add("@ItemId", SqlDbType.Int)

        Do While <some condition>
            cmd2.Parameters("@ItemId").Value = <some value that's different with each iteration of the loop>
            rdr2 = cmd2.ExecuteReader
            rdr2.Read()
       Loop
0
Exploring ASP.NET Core: Fundamentals
LVL 12
Exploring ASP.NET Core: Fundamentals

Learn to build web apps and services, IoT apps, and mobile backends by covering the fundamentals of ASP.NET Core and  exploring the core foundations for app libraries.

Hello,
I am  vb.net desktop developer and need to learn Asp.NET CORE (MVC)  , where do I start? Any suggestions on Books, Training (even paid is fine) will be appreciated.
Thanks
0
I want to show the text  as VIEW when  mouse over the image.
<img  src="images/<%# DataBinder.Eval(Container.DataItem, "idProduct") %>.jpg"  onmouseover= xxxxxx  onmouseout="this.src='<images/<%# DataBinder.Eval(Container.DataItem, "idProduct") %>.jpg'"> 

Open in new window


Please advise! Thank you!
1
I need an SSIS Example project (VS Shell 2013) That Uses a 2003 version of Excel file(s)

And 1 by 1 pulls in the file... sends the data to SQL
Then renames the file to another folder
0
On my PC this location contains a bunch of XML files

C:\SmartCompletion\Backend\IBS.Core\Resources

I'd like to limit my search to **just** the Resources folder.

There is a particular tag inside these XML files that I want to look at and verify that it does NOT contain a certain attribute:

 <Layout mode="Complex" UsePurgeRestore="true" UseCopy="true">   //////////// this would not show up in the search results

UsePurgeRestore="true" or UsePurgeRestore="false"  must NOT be an attribute in the <Layout> tag

So this would be a match for my search:

<Layout mode="Complex" UseCopy="true">

or this:

  <Layout UseAssignment="true" mode="Complex"  EditNewView="vAssetPacksLines">


Can Visual Studio do this using Regular Expressions?

I would need the RegEx.  I'm too slow at it and I need this as fast as I can.

reg ex search

NOTE:  I am open to freeware tools that can do this kind of exclusionary search of file contents.  I have AgentRansack, for example.  I also have Notepad++.   Do either of those support RegEx searches?

Thank you!
0
We're trying to build a datagrid connected to an SQL database in UWP as a proof of concept. We're running into an issue declaring the DataTemplate that it doesn't understand the DataType, and I can't get it to process it properly. This has to be defined as we're binding the textboxes to the SQL database. We were using this site for reference https://docs.microsoft.com/en-us/windows/uwp/data-access/sql-server-databases    (we've made changes to suite our needs)

Code segment throwing errors
<DataTemplate x:DataType="local:Product">

The.xaml page with the errors (line 48)
<Page
    x:Class="App3.Views.TicketsPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    Style="{StaticResource PageStyle}"
    mc:Ignorable="d">

    <Grid x:Name="ContentArea">
        <Pivot
            x:Name="Items">
            <PivotItem Header="Open">
                <Grid Background="{ThemeResource SystemControlPageBackgroundChromeLowBrush}">
                    <RelativePanel>
                        <ListView Name="WorklogList"
                            SelectionMode="Single"
                            ScrollViewer.VerticalScrollBarVisibility="Auto"
                            ScrollViewer.IsVerticalRailEnabled="True"
                            

Open in new window

0
We have a site and it has a global search feature which is very very slow. It looks up 4 tables and does a wildcard.

This is how it looks like
select ....
 from 
 [dbo].[Unit] AS u
	LEFT join [dbo].[Schedule] AS s
    ON u.[ScheduleID] = s.[ID]
    LEFT OUTER JOIN [dbo].[MasterLease] AS m
        ON s.[MasterLeaseID] = m.[ID]
		INNER JOIN dbo.Portfolio p ON p.ID = m.PortfolioID
 
WHERE 
u.[Deleted] <> 1
          AND (1 <> s.[Status])
   
          AND (m.[Deleted] <> 1)
          AND (m.[Active] = 1)
AND
      (
          (s.[Sched] LIKE @searchtext)
          OR (u.[SerialNo] LIKE @searchtext)
        
          OR (u.[CustomerRef] LIKE @searchtext )
          OR (u.[Model] LIKE @searchtext )
          OR (u.[Manufacturer] LIKE @searchtext)
          OR (u.[SiteAddress] LIKE @searchtext )
          OR (m.[CustomerName] LIKE @searchtext )
          OR (s.[LesseeName] LIKE @searchtext )
      );

Open in new window


1. My manager doesn't want to do a FullText Search
2. We have used indexes
3. The wildcard slows down the search, I think
4. If I join the 4 tables without the where clause, I get 2,827,623 rows. Should we dump this data in a table and just search this table? (update the table every night with fresh data)
5. Tried this as well... I broke down the joins by creating temp tables. First search Units, dumped in the temp table, #Units. Then Schedules in #Scheudles , then MasterLease in #ML.  Then did the join like I have above but what if there's nothing in #Units table...meaning...search didn't bring anything back from and #units is empty. I don't the join going to be correct.

I think #4 is a good option. How do others do a global search?
0
Hello Folks,

I'm expanding my knowledge in learning classes in powershell... I have written this basic  PS example

class Books {
    [string]$title 
    [string]$author
    [int]$pages   
}

$books1 = [books]::new()
$books1.title = "Harry Potter"
$books1.author = "JK Rowling"
$books1.pages = 309

$books2 = [books]::new()
$books2.title = "Scott Pilgrim vs. the World"
$books2.author = "Bryan Lee O'Malley"
$books2.pages = 168

$books2 | ? {$_.title -like "*scott*"}

Open in new window


this will display the book from book 2 titled like "scott"...
Does anybody have any idea on how can I tell the program to search within all the books and find any "X" Title... I was thinking "foreach" but i'm not sure I could squeeze it in...? or if you have a c# approach that would be great also :)

Thanks in advance!
0
I'm following this example https://docs.microsoft.com/en-us/aspnet/core/tutorials/first-web-api?view=aspnetcore-2.1
to learn .Net Core.

I know LINQ to SQL is not supported in .Net Core. Is LINQ to Entities (LINQ to Entities ) supported? is my only option is to use Entity Framework?

(I really liked LINQ to SQL. Too bad it's not supported)
0
Hello Experts,
I am trying to generate an output file using StreamWriter in C# which contains Credit Card (CC) numbers.  As long as the CC Number is 15 digits long, the StreamWriter works just fine.  But when the CC Number length is 16 digits long, the StreamWriter replaces the last digit with 0 (zero).  Any idea how to fix it?  Please try to help.

Thank you very much in advance!
0
Become a Certified Penetration Testing Engineer
LVL 12
Become a Certified Penetration Testing Engineer

This CPTE Certified Penetration Testing Engineer course covers everything you need to know about becoming a Certified Penetration Testing Engineer. Career Path: Professional roles include Ethical Hackers, Security Consultants, System Administrators, and Chief Security Officers.

I have legacy code in C#, Web Forms and LINQ to SQL.

I want to upgrade this code and I want to move the data layer to ASP.Net Web API. I found this link
https://docs.microsoft.com/en-us/aspnet/core/tutorials/first-web-api?view=aspnetcore-2.1

I wanted to keep LINQ to SQL code (DBML) to make the upgrade go faster. Looks like LINQ to SQL is not supported in .Net Core.L2S not supported lin

What should I do? I have DBML, stored procs. How can I do my upgrade?
0
These two lines of vb6 code I am trying to translate to C#:

mskFromDate.Text = Format(Date - TimeSerial((iNumDaysBefore * 24), 0, 0), "Short Date")
    mskToDate.Text = Format(Date + TimeSerial((iNumDaysAfter * 24), 0, 0), "Short Date")

I have this so far. I know it is not right.

var dt = string.Empty;
                dt = Convert.ToString(DateTime.Now.ToOADate() - (NumDaysBefore * 24));
                this.dtFromDate.Text = Convert.ToDateTime(dt).ToShortDateString();

Anybody have thoughts? I can't believe in vb6 they let folks subtract dates and numbers.
0
When I try to run a web application in Visual Studio I get the following error.  It's only occurring with one web application.  Why?  How do I fix???

Unable to connect to the configured development Web server.

Output from IIS Express:
Failed to register URL "http://localhost:1789/"
The process cannot access the file because it is being used by another process. (0x80070020)

Here's my Visual Studio configuration:
Microsoft Visual Studio Professional 2017 
Version 15.8.9
VisualStudio.15.Release/15.8.9+28010.2050
Microsoft .NET Framework
Version 4.7.03190

Installed Version: Professional

Visual C++ 2017   00370-10200-04031-AA118
Microsoft Visual C++ 2017

Application Insights Tools for Visual Studio Package   8.13.10627.1
Application Insights Tools for Visual Studio

ASP.NET and Web Tools 2017   15.8.05085.0
ASP.NET and Web Tools 2017

ASP.NET Core Razor Language Services   15.8.31590
Provides languages services for ASP.NET Core Razor.

ASP.NET Web Frameworks and Tools 2017   5.2.60618.0
For additional information, visit https://www.asp.net/

Azure App Service Tools v3.0.0   15.8.05023.0
Azure App Service Tools v3.0.0

C# Tools   2.9.0-beta8-63208-01
C# components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used.

Common Azure Tools   1.10
Provides common services for use by Azure Mobile Services and Microsoft Azure Tools.

ConvertToDevExtremeCommand Extension   1.0
ConvertToDevExtremeCommand Visual 

Open in new window

0
Hi Guys,
I am using asp.net mvc application with VB.net and I am trying to zip files and stream them back to the user to download.

Here is what I am doing
   Public Function DownloadFiles(attachmentsSelected As String) As ActionResult
        Dim obj As FileDownloads = New FileDownloads()
        ''get file list of files to download
        Dim filesCol = obj.GetFile(attachmentsSelected).ToList()

        Using memoryStream = New MemoryStream()
            Using ziparchive = New ZipArchive(memoryStream, ZipArchiveMode.Create, True)

                For i As Integer = 0 To filesCol.Count - 1
       //get the error here   ziparchive.CreateEntryFromFile(filesCol(i).FilePath + "\" + filesCol(i).FileName, filesCol(i).FileName, CompressionLevel.Optimal)
                Next
            End Using

            Return File(memoryStream.ToArray(), "application/zip", "Attachments.zip")
        End Using

    End Function

Open in new window


The issue with this code is when I am trying to download large file ...let's say 500mb I get an exception.

"Exception of type 'System.OutOfMemoryException' was thrown."

Any idea how can I fix this issue.

Thank you.
0
Hi,
I have a batch file as below:
call "C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\Tools\VsDevCmd.bat"
cd C:\AutomationTestSamples\AutomationTestSamples\bin\Debug
start cmd /k vstest.console.exe AutomationTestSamples.dll /Logger:trx;LogFileName=%1/UnitTest1.trx /testcasefilter:FullyQualifiedName~AutomationTestSamples.UnitTest1.trx

Open in new window


I want to read a batch file line by line and if the line contains "UnitTest1.trx",
I want to replace "/testcasefilter:FullyQualifiedName~AutomationTestSamples.UnitTest1" with "/test".

I tried the following code but when I opened the file nothing was replaced.  Any idea please?
string[] str = File.ReadAllLines(@"C:\Test\test.bat");
            for (int i = 0; i < str.Length; i++)
            {
                if (str[i].Contains(trxName))
                {
                    str[i].Replace(str[i].Substring(str[i].IndexOf("/testcasefilter")), "/test");                    
                }
                
            }

Open in new window

0
Question in regards to upgrading exchange 2013 CU17 to CU21
Has anyone heard of not being able to upgrade from exchange 2013 CU17 directly to CU 21?
Someone told me that you had to go from CU17 to CU20 because of a .net issue then go to CU21
Is this correct or is this not correct?
Basically has anyone gone from CU17 directly to CU21?
Thanks
0
Hi All,
I have a C# DLL which was written for me to interface with my VB6 program.  The DLL is COM-Visible and the Register for COM interop selected.  The DLL has 3 methods Initialization, Up and Dn.

I have a small VB6 test program which access the DLL.

I'm using VS 2017 (run as administrator) to build the DLL
I have Visual Studio (VB6) on the same machine - A Windows 10 PRO system.

In my VB program I have a reference to the DLL (actually the TLB).  Intellesense works fine - I can see all three methods.
My startup code is:
Public Sub Main()
    Dim AM as AudioManager
    Set AM = New AudioManager       ' <<<==== Error here
  
End Sub

Open in new window

When I run the program I get an error at the Set statement - Runtime 429 - "ActiveX component can't create object".
I've done quite a bit of research on the web about this, and most of the similar issues are when someone tries to move a project from a development environment.  In my case , I'm getting this on the development system.
I have tried:
Tlbexp AM.DLL /out:AM.tlb
Regasm /tlb:AM.tlb AM.DLL
Gacutil /i AM.DLL
So far nothing seems to work.  I have put the DLL and TLB into the System32, SYSWOW64 and my VB6 application folders (registering it in each after removing from the previous location) - doesn't help.
Anyone have any ideas?
Thanks in advance
0
Is there a way to reprogram a shortcut icon so users cannot pin it to the taskbar on Windows 7?  I found this link where you can disable pinning for a certain string, but I don't want to include that in the name of the shortcut.  Anyway of doing something in Powershell or VB?

https://docs.microsoft.com/en-us/windows/desktop/shell/appids

If any of the following strings, regardless of case, are included in the shortcut name, the program is not pinnable and is not displayed in the most frequently used list:

Documentation
Help
Install
More Info
Read me
Read First
Readme
Remove
Setup
Support
What's New
1
In the checkbox list below...

I need on ckecked  = true for Opened or Clicked

That it is assured that checkboxes No FIlter and Delivered are unchecked
And value =


<asp:CheckBoxList ID="rblMetrics" CssClass="icheck1" runat="server" AutoPostBack="False"
CellPadding="0" CellSpacing="0" Height="0px" RepeatColumns="2" RepeatDirection="Horizontal"
Width="200px">
    <asp:ListItem Class="icheck1" Selected="True" Value="0" Text="No Filter"></asp:ListItem>
    <asp:ListItem Class="icheck1" Selected="False" Value="1" Text="Delivered"></asp:ListItem>
    <asp:ListItem Class="icheck1" Selected="False" Value="2" Text="Opened"></asp:ListItem>
    <asp:ListItem Class="icheck1" Selected="False" Value="3" Text="Clicked"></asp:ListItem>
</asp:CheckBoxList>  

Open in new window

0
OWASP: Forgery and Phishing
LVL 12
OWASP: Forgery and Phishing

Learn the techniques to avoid forgery and phishing attacks and the types of attacks an application or network may face.

I am writing an app that will collect data from a number of excel spreadsheets and create one spreadsheet with specific data.  I've attached an example of the data.

I am using ExcelDataReader to get the data and then dumping into a datatable.

I need to get the manufacturer, supplier, and price.  As you can see by the image that they can be in any position in the spreadsheet and also not all have all the information.  I was using a
foreach (Datarow dr in dt.rows)
{
    dr[0] .....
}

Open in new window

Anyone have any suggestions to get the data in an easier manner than checking each column to then get all pertinent data in subsequent rows?

material example
0
I don't think ASP.Net app pool queues database calls but this is what my manager says:

We had a deadlock on a table. He said we don't get a deadlock on whatever section of the code because ASP.Net App Pool queues the select statements and that's why we don't get a deadlock in one section and we get it in another section.

Doesn't make sense to me. I think he was making it up :)
0
I HAVE A HAEMTALOGY ANALYZER WITH RJ45 PORT. I NEED TO RECEIVE DATA FROM THAT MACHINE TO MY VB.NET PROGRAM. KINDLY SHARE THE CODE FOR THE SAME SO THAT I CAN GET THE DATA AND RESTRUCTURE THE SAME AS PER MY REQUIREMENT.
0
We have EF 6 in our project. There was a lock on a table and my manager wants to put a no-lock on one of the tables. I've read about dirty reads.

I Googled and seems like EF doesn't have a no-lock command.

This link EF link  has
Entity Framework is never an introduced transaction Isolation Level on queries. Entity Framework uses SQL Server transaction Isolation Level by default.

Is this correct? I can't put a no-lock on a table?
0
I converted a vb6 function to .NET. My Boss says it "isn't very .NET". First is the vb6 function, then my conversion. Can anyone suggest ways to make it "more .NET?"

Public Function CalculateCheckDigit(sInString As String) As Integer
' Starter requires a check digit on the end of the Serial Ship Code
' for their Optional ASN label

' Algorithm is as follows:
' Strip out the spaces and punction from the incoming string
' (e.g. take only the stuff that is numeric)
' Add all of the odd positions together (OddSum)
' Add all of the even positions together (EvenSum)
' Multiply OddSum by 3 to get Result C
' Add Result C + EvenSum, divide by 10 and get the remainder
' 10 - Remainder = Final Check digit

    Dim sChar As String
    Dim sStrippedString As String
    Dim I As Integer
    Dim iOddSum As Integer
    Dim iEvenSum As Integer
    Dim iResultC As Integer
    Dim iRemainder As Integer

    On Error GoTo Error_H

    For I = 1 To Len(sInString)
        sChar = Mid$(sInString, I, 1)
        If IsNumeric(sChar) Then
            sStrippedString = sStrippedString & sChar
        End If
    Next I
   
    For I = 1 To Len(sStrippedString)
        sChar = Mid$(sStrippedString, I, 1)
        If I Mod 2 = 0 Then  ' Even position in the string
            iEvenSum = iEvenSum + Val(sChar)
        Else
            iOddSum = iOddSum + Val(sChar)
        End If
    Next I
    iResultC = iOddSum * 3
    iRemainder = (iResultC + iEvenSum) Mod 10
   …
0
Greetings:

I have a client who currently is able to upload graphic file(s) to his website for display. My client is a restaurant owner and, as I believe most clients would agree, does not want to be bogged down with graphic file size do to DPI or dimensions of the the graphic.

I use VB.NET and Visual Studio Pro 2017.

I would like to manipulate the DPI and graphic dimensions for him. What I need to adjust are:
  • DPI
  • width or length keeping the aspect ratio of the graphic

I am not savvy when it comes to graphic files. I do know how to gain addressability to the graphic file IO stream after upload.

I need mentoring on how to do these two things and save the graphic file as a smaller version of itself.

Any assistance is greatly appreciated.


Much thanks,
David Bach
0

.NET Programming

133K

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.