.NET Programming

132K

Solutions

77

Articles & Videos

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

Hi Experts,

I'm running a .NET application, where we are storing files on a separate drive (D:/) but when I try to link to the file, it's not downloading:
<a href="D:\dbProject\attachments\TestUpload_125368.txt">File</a>. What am I missing?

Thanks,
Steve
0
SharePoint Admin?
SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

Hello I am new to asp and and trying to learn how to code properly however, I have a deadline to get this code to work on a clients website. My hosting company moved us to a new server that does not support FrontPage extensions and so i need to update my skills and update my websites I support.

I copied this code from one of the asp.net  sources and tweaked it with my variables but am still getting 5 errors when i debug it.

Error      1      Cannot implicitly convert type 'string' to 'System.Web.UI.WebControls.TextBox'      c:\users\melinda\documents\visual studio 2013\Projects\WebApplication1\WebApplication1\Test_form.aspx.cs      27      30      WebApplication1
Error      2      Cannot implicitly convert type 'string' to 'System.Web.UI.WebControls.Label'      c:\users\melinda\documents\visual studio 2013\Projects\WebApplication1\WebApplication1\Test_form.aspx.cs      34      26      WebApplication1
Error      3      Cannot implicitly convert type 'string' to 'System.Web.UI.WebControls.Label'      c:\users\melinda\documents\visual studio 2013\Projects\WebApplication1\WebApplication1\Test_form.aspx.cs      40      26      WebApplication1
Error      4      Property or indexer 'System.Net.Mail.MailMessage.To' cannot be assigned to -- it is read only      c:\users\melinda\documents\visual studio 2013\Projects\WebApplication1\WebApplication1\Test_form.aspx.cs      49      9      WebApplication1
Error      5      Cannot implicitly convert type 'System.Net.Mail.MailAddress' to 'System.Net.Mail.MailAddressCollection'      c:\users\melinda\documents\visual studio …
0
Hello,
I am using vb.net desktop.
How to have excel like filtering in datagridview.

Thaks
0
Hey I am really struggling with this one. I can use a comma delimited file with no problem in my vb.net application I am building. But when I try to use a tab delimited file all I get is one column. The comma delimited worked. The rest did not. Can anyone tell me what I am doing wrong????

Dim Delimiter As String = ""
        If Me.cbDelimiter.Text = "," Then
            CSVConn.ConnectionString = ("Provider=Microsoft.Jet.OleDb.4.0; Data Source = " + Path.GetDirectoryName(FileName) + "; Extended Properties = ""Text;HDR=YES;FMT=Delimited""")
        End If
        If Me.cbDelimiter.Text = "|" Then
            CSVConn.ConnectionString = ("Provider=Microsoft.Jet.OleDb.4.0; Data Source = " + Path.GetDirectoryName(FileName) + "; Extended Properties=""text;HDR=YES;FMT=Delimited(|OrdersTAB.txtOrdersTAB.txt)""")
            ' Delimiter = "FMT=Delimited(|)"
        End If
        If Me.cbDelimiter.Text = "Tab" Then
            '= "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\MyDir;Extended Properties='text;HDR=YES;FMT=CSVDelimited;'; "
            'CSVConn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Path.GetDirectoryName(FileName) + ";Extended Properties='text;HDR=YES;FMT=Delimited;'; "
            'CSVConn.ConnectionString = ("Provider=Microsoft.Jet.OleDb.4.0; Data Source = " + Path.GetDirectoryName(FileName) + "; Extended Properties=""text;HDR=YES;FMT=TabDelimited""")
            '  Delimiter = "FMT=TabDelimited"
           …
0
Hello,
I am trying to merge word document  from vb.net
Please find the code :
                            oDoc.Content.Find.Execute(FindText:=StrRoomRouting,
                                                        ReplaceWith:=StrRoomRouting & " #" & StrRoomNo, Replace:=Microsoft.Office.Interop.Word.WdReplace.wdReplaceAll, MatchCase:=True)

Open in new window


I get an COM error:

String parameter too long
StrRoomRouting & " #" & StrRoomNo, this is  a long string more than 255

Thanks
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
Hi,

How do I modify the code below to convert dates to Day-Month-Year (i.e. 06 Dec 2016). I need to month to be in letters not numeric as the code below converts to.

result = DateTime.Parse(xnode.InnerText).ToUniversalTime().Date.ToString("dd/M/yyyy")

Thanks,

Victor
0
Please any code helpfull for a simply contact form in HTML that writes data on a sql db
regards!
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
I have a VB.NET application that connects with a SQL Server DB, and inserts a new record of data into a table that is an auto-increment ID column.  When the user enters the data, and decides that they do not want to save the information, the application is supposed to rollback the data and not insert it into the DB.  However, if the user does not save the data for ID number 150, for example, the code works as it should and removes the information from the DB, however upon the next entry of data into the DB, the ID number is now 151, and not 150 as that should be the next number in the sequence, since it was not utilized.

Can someone tell me code wise, how to ensure that SQL Server does not increment to the next number if the user does not save the record into the DB?  Below is the VB code that I am using for this functionality:


Private Sub frmWizard_FormClosing(sender As Object, e As FormClosingEventArgs) Handles Me.FormClosing
        If Not hasProfileBeenSaved Then
            If MsgBox("Save changes to the new profile?", MsgBoxStyle.YesNo) = MsgBoxResult.Yes Then
                e.Cancel = True  
            Else
                'delete profile
                DbUtil.Provider.DeleteRecord(profile.ID)
            End If
        End If
    End Sub

Open in new window



Thanks in advance for your feedback.

Regards,
aj85
0
How our DevOps Teams Maximize Uptime
How our DevOps Teams Maximize Uptime

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us. Read the use case whitepaper.

The user provides my vb.net code with a SQL query that would look like this  for example:

select DISTINCT *from employees a INNER JOIN orders b on b.[Employee ID] = a.ID

I want to find a way to populate the datatable I create in code with the query columns and information but not actually get data. Is there a way to do this? The code also accepts queries from MySQL, MS Access, CSV as well as SQL.
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
I have a Tuple List and need to do a search.

Dim strTaxCodeXREF_List As New List(Of Tuple(Of String, String, String))

This list is very rapidly loaded with 200,000 rows of data, from a text file.  Columns are (TaxCode, TaxDescription, TaxRate)

I need to do a search against TaxCode and retrieve the corresponding TaxDescription and TaxRate.
TaxCode is not unique. I realize that I could simply do a loop and check every row. However, I am seeking a more efficient solution.
I considered using a Dictionary Object but unless I am mistaken,  Dictionaries are limited to two columns. Moreover, Dictionaries require a unique key.

I am a novice to VB.Net and would greatly appreciate any suggestions on the best way to efficiently perform the search.

Thanks much...
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
Hello Experts,
My website is working fine until I add the following line.  The moment I try to run the website after the line has been added, I am getting the the error "Cannot open database "ASPState" requested by the login. The login failed.  Login failed for user 'userid'".  Any idea why it fails?  FYI, I am using c#.net in Visual Studio 2013.

Session["FirstName"] = "Krishna";

Thank you in advance.
0
Hello,
How to retrieve information from HTTP in vb.net desktop app.

Cheers
0
I am using c# console application.
i used like this but failed to get dymanic data
1.   string URL = "https://ecomexpress.in/tracking/?awb_field=852156111";
using (var client = new WebClient())
{
    client.Headers["Content-Type"] = "application/json; charset=UTF-8";
var json = client.UploadString(URL, JsonConvert.SerializeObject(new { awb_field = "852156111", Ubi = "", IrlVilationId = "", IsSecured = "" }));
}
2.
          WebClient client = new WebClient();
            client.Headers.Add("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; .NET CLR 1.0.3705;)");
            Stream data = client.OpenRead(url);
0
I have a table that has many checkboxes.  If one of them is selected, I want to fire an event that sets the value of a dropdown list.   I've tried with the below code bus cannot get it to work

    End Sub
    Protected Sub chkLearnerName_CheckedChanged1(sender As Object, e As EventArgs)

        Dim ischeked As Boolean = False
        Dim cntrl As Control
        For Each cntrl In chkboxestbl.Controls

            If TypeOf cntrl Is CheckBox Then
                If CType(cntrl, CheckBox).Checked = True Then
                    ischeked = True
                    ddlRevResult.SelectedValue = 1

                Else
                    ddlRevResult.SelectedValue = 2

                    Exit For

                End If
            End If
        Next
    End Sub

Open in new window

<table id="chkboxestbl" runat="server" style="width: 100%; font-size: xx-small;">
                                              <tr runat="server">
                                                  <td runat="server"></td>
                                                  <td runat="server" ></td>
                                              </tr>
                                              <tr runat="server">
                                                  <td runat="server">
                                                      <asp:CheckBox ID="chkLearnerName" OnCheckedChanged="chkLearnerName_CheckedChanged1" runat="server" Text="Learner Name" AutoPostBack="True" />
                      

Open in new window

0
Experts, please help! only left the folders in my aspx project, all the files are gone from their original location!
what happend!!
please any one
0
Why You Need a DevOps Toolchain
Why You Need a DevOps Toolchain

IT needs to deliver services with more agility and velocity. IT must roll out application features and innovations faster to keep up with customer demands, which is where a DevOps toolchain steps in. View the infographic to see why you need a DevOps toolchain.

Hi all.

I have the code below that is used to open a form "ContractHeaderEdit" based on the right click selection from another form "ContractMain". The records are in a datagridview control "DataGridMain" and when the end user right clicks and selects the Edit then it opens the "ContractHeaderEdit" form and populates the fields as seen below.

My code below works fine with the textboxes, but I'm having an issue with the comboboxes. The comboboxes have their items already added in the Properties window, I just want the selected item to be the one that is pulled from the sql query. Then the user can change it to whatever is already in the combobox (i.e. sql query pulls "Independent" but the end user can change it to another item in the combobox if they wish but the selected item is "Independent").

Any help would be appreciated. Thank you in advance.
Dim frm As New ContractHeaderEdit
            Dim con As New SqlConnection
            Dim cmd As New SqlCommand

            con.ConnectionString = "Data Source=myServer;Initial Catalog=myDB;Integrated Security=True"

            con.Open()

            cmd.Connection = con

            cmd.CommandText = "SELECT [PM_Contract_ID],[ContractName],[Contract_Category],[GPO_Contract_Type],[Begin_Date],[End_Date],[Contract_Product_Line],[Note] FROM [Contract Pricing].[dbo].[tblPM_Contracts-All Contracts] WHERE [PM_Contract_ID] = @ContractNumber"
            cmd.Parameters.AddWithValue("@ContractNumber", 

Open in new window

0
Hello Experts,

I have VS 2010 and 2015 community, and enterprise preview installed on a machine.  I want to uninstall all versions of 2015 and keep the VS 2010 version installed.  However for the past 2 days the uninstall for 2015 has been running and has yet to conclude a successful uninstall, which means there has to be an issue that MS has not resolved with this version of VS.  With that being said, does anyone know of a utlitity or tool that will completely and quickly uninstall 2015 and leave the VS 2010 version intact?  Please advise, as there has to be a better and more reliable way to uninstall 2015.  Thanks in advance.

aj85
VS_2015_Uninstall_2_Day_Status.JPG
0
I have an asp.net application in which i'm uploading file into the database. In Aspx i have a Updateprogress with Postbacktrigger in UpdatePanel. It is working fine when i remove my Localhost from the Compatibility View in IE11 but when i add localhost in compatibility view UpdateProgress does not appear.

i'm also using Following JavaScript Function to make Updateprogress appear:

<script type="text/javascript">
        window.onsubmit = function () {

            var updateProgress = $find("<%= UpdateProgress1.ClientID %>");
            window.setTimeout(function () {
                updateProgress.set_visible(true);
            }, 100);

        }
    </script>
0
Hi I have a background in writing perl both stand alone and back end web scripting,  I can also dabble in JavaScript/ jQuery, PHP with associated HTML & CSS as well as knowledge of Database

I've been asked to "get certificated" in .NET particular C# and ASP.net  

It's been suggested I look at courses like the-csharp-programming-language or programming-in-c-20483 both of these courses have pre-requisites

Can anyone recommend where to start with online coarses?  
There is a huge amount on Google I suspect some less useful than others
0
Hi,
Further to this
https://www.experts-exchange.com/questions/29029100/Problem-to-show-list.html?anchor=a42174635¬ificationFollowed=190745230#a42174635

and I have ImageHandler.cs like
using System;
using System.IO;
using System.IO.Compression;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Data;
using System.Configuration;
using System.Data.OleDb;
using System.Xml;
using System.Globalization;
using System.Collections.Generic;
using System.Drawing;
using System.Text; // This was needed to make ASCIIEncoding function
using System.Security.Cryptography; // This was needed to make everything related to MD5 function
using System.Web.Services;

namespace Own_rec
{
    public class ImageHandler : IHttpHandler
    {
        /// <summary>
        /// You will need to configure this handler in the Web.config file of your 
        /// web and register it with IIS before being able to use it. For more information
        /// see the following link: http://go.microsoft.com/?linkid=8101007
        /// </summary>
        public void ProcessRequest(HttpContext context)
        {
            //string userId = string.Empty;
            int userId = 0;
            //-- get the ID from query string you get from <img src tag
            if (null != 

Open in new window

0
Hi there,

I need some help write a powersheet so that when i run it on my IIS 7 or 7.5 it will check if each of this exisit. If exisit, it will throw a statement, "exisit, please have it removed"

http://localhost/iissamples
http://localhost/iisadmpwd
http://localhost/IISHelp
http://localhost/Printers

I want to ensure that  the default Virtual Directories and the files and folder they point to should be removed.
0

.NET Programming

132K

Solutions

77

Articles & Videos

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.