C#

92K

Solutions

25K

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

I'm trying to add databinder into the hyperlink and getting this error

     <asp:HyperLink ID="hlinkFile" runat="server" NavigateUrl= "~/StudentDB/" + '<%#DataBinder.Eval(Container.DataItem, "FILE_LOCATION")%>'>">Open/Save</asp:HyperLink>

Open in new window

0
Free Tool: IP Lookup
LVL 10
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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.

Using DirectoryServices.DirectoryEntry class I'm trying to remove a user entry from a group in active directory using C# .NET

I came across two ways of doing that,

First way:

DirectoryEntry directoryEntry = new DirectoryEntry(myGroupPath);
directoryEntry.Properties["member"].Remove(userDistinguishedName);
directoryEntry.CommitChanges();


Second way

DirectoryEntry directoryEntry = new DirectoryEntry(myGroupPath);
directoryEntry.Invoke("Remove", userDistinguishedName);



Acording to the msdn Invoke documentation, it says that Invoke Calls a method on the native Active Directory Domain Services object. How is it different than the first way?
0
I'm get this error when try to get data from DataGridView by using stored procedure.
The stored procedures:

create proc [dbo].[ADD_LAB_RESULTS]
@SAMPLE_ID int,
@ORDER_ID int,
@TESTID int,
@GROUPID int,
@SAMPLE_STATUS int
as
INSERT INTO LAB_RESULTS
           ([SAMPLE_ID]
           ,[ORDER_ID]
           ,[TESTID]
          ,[GROUPID]
           ,[SAMPLE_STATUS])
     VALUES
           (@SAMPLE_ID
           ,@ORDER_ID
           ,@TESTID
           ,@GROUPID
           ,@SAMPLE_STATUS)

create proc [dbo].[GET_GROUPID]
@TESTID int
as
select groupid from Groups
where Groups.groupid = ''+ @TESTID +''
My C# code when click save button BtnSave:
-------------------------------------------------------------------
this is the parameters void :

public void ADD_LAB_RESULTS(int sample_id, int order_id, int testid, int groupid,int SAMPLE_STATUS)
        {
            DAL.DataAccessLayer DAL = new DAL.DataAccessLayer();
            DAL.open();
            SqlParameter[] param = new SqlParameter[5];
            param[0] = new SqlParameter("@sample_id", SqlDbType.Int);
            param[0].Value = sample_id;

            param[1] = new SqlParameter("@order_id", SqlDbType.Int);
            param[1].Value = order_id;

            param[2] = new SqlParameter("@testid", SqlDbType.Int);
            param[2].Value = testid;

            param[3] = new SqlParameter("@groupid", SqlDbType.Int);
            param[3].Value = groupid;

            …
0
I want to do following:

1. Load Original.xml
2. convert to string look like result.xml
3. for loop and list
      Response.write attribute("id") + "  " + attribute("value")
   next

how can I do that in c#?


Original.xml
<?xml version="1.0" encoding="utf-8" ?>
<Surety QuoteID="123" CreatedDateTime="01/10/2017">
  <Line>
    <Commercial>
      <Bond Name="Notary" Form="Notary.pdf">
        <State name="CA">
          <Step name="Principal" StepNo="Step 1">
            <input type="text" class="" id="principalPhoneNo" placeholder="Custom field" value="310" />
             <input type="text" class="" id="principalPhoneNo2" placeholder="Custom field" value="210" />
            <input type="text" class="" id="principalPhoneNo3" placeholder="Custom field" value="110" />
          </Step>
          <Step name="P2" StepNo="Step 1">
            <input type="text" class="" id="principalPhoneNo4" placeholder="Custom field" value="310" />
             <input type="text" class="" id="principalPhoneNo5" placeholder="Custom field" value="210" />
            <input type="text" class="" id="principalPhoneNo6" placeholder="Custom field" value="110" />
          </Step>
        </State>
      </Bond>
    </Commercial>
  </Line>
</Surety>

Open in new window


Result.xml
<?xml version="1.0" encoding="utf-8" ?>
<Surety QuoteID="123" CreatedDateTime="01/10/2017">  
            <input type="text" class="" id="principalPhoneNo" placeholder="Custom field" value="310" />
            <input type="text" class="" id="principalPhoneNo2" placeholder="Custom field" value="210" />
            <input type="text" class="" id="principalPhoneNo3" placeholder="Custom field" value="110" />       
             <input type="text" class="" id="principalPhoneNo4" placeholder="Custom field" value="310" />
             <input type="text" class="" id="principalPhoneNo5" placeholder="Custom field" value="210" />
            <input type="text" class="" id="principalPhoneNo6" placeholder="Custom field" value="110" />  
</Surety>

Open in new window

0
I have xml file (c:\\data\abc.xml)

in c#, I want to search string "principalPhoneNo", if it is existed, then show find me the value, in this case it is 310,
in c#, I want to search string "principalPhoneNo2", if it is existed, then show find me the value, in this case it is 210,

how can i do that in c# that I do not have specific where the element tag is? meaning i want to find the value (no matter where it is located inside of XML file)

<?xml version="1.0" encoding="utf-8" ?>
<Surety QuoteID="123" CreatedDateTime="01/10/2017">
  <Line>
    <Commercial>
      <Bond Name="Notary" Form="Notary.pdf">
        <State name="CA">
          <Step name="Principal" StepNo="Step 1">
            <input type="text" class="" id="principalPhoneNo" placeholder="Custom field" value="310" />
             <input type="text" class="" id="principalPhoneNo2" placeholder="Custom field" value="210" />
            <input type="text" class="" id="principalPhoneNo3" placeholder="Custom field" value="110" />
          </Step>
        </State>
      </Bond>
    </Commercial>
  </Line>
</Surety>

Open in new window

0
Does anyone know how to use iframes with authorize.net. I have a website that has an iframe for payments. The problem is that when i press countinue it stays in the iframe. i want the iframe to close and but in the main web browser tab. i am using asp.net with c#
0
Hi-

I want to know how to remove temp files after Response.End

If I add File.Delete(prcss_docPath) in the finally the download does not complete.

        string srcTemplate = String.Empty;
        string prcss_docPath = String.Empty;
        string dnNo = String.Empty;
        try
        {
             srcTemplate    = "FileSrc.docx"
            prcss_docPath = "File.docx";
            bool processed = false;
            File.Copy(srcTemplate, prcss_docPath, false);
            ContractProcess cps = new ContractProcess();
            processed = cps.ParseWordTemplate(prcss_docPath, dnNo);

            if (processed)
            {
                Response.Clear();
                 FileInfo file = new FileInfo(prcss_docPath);
                Response.ContentType = "Application/msword";
                Response.AppendHeader("Content-Disposition", "inline; filename=" + file.Name);
                Response.AppendHeader("Content-Length", file.Length.ToString());
                Response.Flush();
                Response.TransmitFile(prcss_docPath);
                Response.End();
                Response.Close();
            }
        }
        finally //Delete the files.
        {

         }

Open in new window

0
we want to see anyone has been developing web form /c# with edmunds api. They do not have .net/c# sample.
Assume we have <asp:net dropdown> and I just need to bind their car maker, model, and year.

c#, asp.net
0
I'm working on consuming a third party web service. I know there are couple of ways to consume a web service. I tried following ways

1. I used visual studio to add a service reference - using this method, I have access to and declare a proxy/client object for the service, like below and set the credentials.

    ABCService proxy = new ABCServiceClient();

    proxy.ClientCredentials.UserName.UserName = "username";
    proxy.ClientCredentials.UserName.Password = "password";

2. I used WSDL.exe tool to generate a proxy class manually. After including the proxy class in my project, I have access to the object and properties in the proxy class, but I can't declare a client object like in step one and set the credentials.  
 
Questions -

1. how to set up UsernameToken element (WS-Security standard) in the soap header when generating a proxy class manually like in method 2 above.

2. what are key differences between method 1 and 2?

3. Also, is there any difference between using WSDL.exe vs SVCUTIL.exe?
0
I am working on a .Net application that is using nHibernate and I am passing through a structured datatype into a stored procedure.

I am using an extended method like this

    public static class StructuredExtensions
    {
        private static readonly Sql2008Structured structured = new Sql2008Structured();

        public static IQuery SetStructured(this IQuery query, string name, DataTable dt)
        {
            return query.SetParameter(name, dt, structured);
        }
    }

Open in new window


The full code of this is in the attached file,

The SQL User Defined Table Type is

CREATE TYPE [dbo].[CEQBM_CEQBN_TYP] AS TABLE(
	[PRNCPL_ACC_CD] [char](10) NOT NULL,
	[BRANCH_ACC_CD] [char](10) NOT NULL,
	[COPY_MISC_DLR_FG] [bit] NOT NULL DEFAULT ((0)),
	[COPY_LABR_HRS_FG] [bit] NOT NULL DEFAULT ((0)),
	[COPY_CSUM_COST_FG] [bit] NOT NULL DEFAULT ((0)),
	[COPY_PART_PRICE_FG] [bit] NOT NULL DEFAULT ((0)),
	[COPY_TRVL_RATE_FG] [bit] NOT NULL DEFAULT ((0)),
	[COPY_DISC_FG] [bit] NOT NULL DEFAULT ((0)),
	[COPY_TAX_RATE_FG] [bit] NOT NULL DEFAULT ((0)),
	[COPY_REJ_RESN_FG] [bit] NOT NULL DEFAULT ((0)),
	[COPY_CNTR_OBLG_FG] [bit] NOT NULL DEFAULT ((0)),
	[COPY_LABR_OVRS_FG] [bit] NOT NULL DEFAULT ((0)),
	[EDIT_MISC_DLR_FG] [bit] NOT NULL DEFAULT ((0)),
	[EDIT_LABR_HRS_FG] [bit] NOT NULL DEFAULT ((0)),
	[EDIT_CSUM_COST_FG] [bit] NOT NULL DEFAULT ((0)),
	[EDIT_PART_PRICE_FG] [bit] NOT NULL DEFAULT ((0)),
	[EDIT_TRVL_RATE_FG] [bit] NOT NULL DEFAULT ((0)),
	

Open in new window

0
On Demand Webinar: Networking for the Cloud Era
LVL 10
On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

i have a two serially (COM1->COM2) AND (COM2->COM1) connected USB device . i transmit the information into com1->to com2 same-way to second device .  but i want  to disable/enable  device when its running period .  i am trying to solve this problem but when   i am running the code exception will occurred (" data is invalid" ) . how to solve this problem?
formMain.cs
0
Hello Experts,
In a Windows Service program, I am trying to delete a file.  It works fine in my machine.  For example if the file is found, my program  deletes it and if the file not found, I get exception.  Same program when copied to production, neither the file gets deleted, not do I get any exception.  I am sure it goes to delete portion of the method.  Because I tested it with log4net.  FYI, in development I am using Windows 7 Pro and in Production Windows Server 2008 R2.  Any idea?  Below is my code.  Please help.

Thank you in advance.


public void DeletePMTFile()
        {
            string fullName = System.Configuration.ConfigurationManager.AppSettings["FULL_NAME"];
            string filePath = System.Configuration.ConfigurationManager.AppSettings["FILE_PATH"];
            var reader = new StreamReader(fullName);
            reader.Close();

            FileInfo fileName = new FileInfo(fullName);
            if (File.Exists(fullName))
            {
                try
                {
                    Array.ForEach(Directory.GetFiles(filePath), File.Delete);
                }
                catch (System.IO.IOException e)
                {
                    log.Error("DeletePMTFile: Error while deleting the file" + e.Message);
                    return;
                }
            }
            else
            {
                log.Warn("DeletePMTFile: " + filePath.Trim() + " not found");
            }
        }

Open in new window

0


 Im using datagridview in c#. when i add a new row in datagridview programmaticlly it shows error like "operation did not succeed successfully because program not commit or quite cell value change. but remember it shows error when i remove first item of datagridview and add new row again
here is code to add item in datagridview DataGridViewRow row = (DataGridViewRow)dgInvcProductList.Rows[0].Clone(); row.Cells[0].Value = productID; row.Cells[1].Value = name; row.Cells[2].Value = Detail; row.Cells[3].Value = Size; row.Cells[4].Value = Sale_Price; row.Cells[5].Value = Quantity; row.Cells[6].Value = totalPrice.ToString(); row.Cells[7].Value = Sale_Unit; dgInvcProductList.Rows.Add(row); First ImageAfter remove first rowWhen i add new row again error occure
0
I have written a big C# program, (like 84 pages long), and I want to use GNU grep to compile a list of all of the C# symbols, such as variable and class names into a .csv file for the purpose of creating a "data dictionary" that accompanies the program so that I can continue to maintain programming it effectively.

Somebody please tell me how to compose the pattern expression that does that. Or if there is a tool expressly for doing that, please tell me what the name of that tool is. (preferably a free tool).
0
Hi

I can successfully write to the MS message queue by doing this:
using (MessageQueue alertsQueue = new MessageQueue(Program.alertsQueuePath))
                {
                    BinaryMessageFormatter formatter = new BinaryMessageFormatter();
                    System.Messaging.Message message = new System.Messaging.Message(this, formatter);

                    alertsQueue.Send(message, "CommonObject");
                }

Open in new window


where "this" is a class called clsCommon.cs and is a populated object with values

Then on another console app, i need to read this message and i guess deserialise it
i.e.
   public void MqReceiveCompleted(object sender, ReceiveCompletedEventArgs e)
        {
            try
            {
                mq.EndReceive(e.AsyncResult);

                clsCommon objClsCommon = new clsCommon();
                string strObjClsCommon = e.Message.Body.ToString();

//here is need to convert the string I just got into objClsCommon

Open in new window


any ideas?
0
Hi All

I have the following applications

1. Web app (asp.net)
2. TCP importer windows forms app (imports data from gps devices in cars)
3. Translator console app - takes messages from MS Message Queue and puts in SQL DB
4. Alerts console app - takes messages from a different Message Queue and sends sms/emails

all have different teams, and with excepting of web app, all are having to store in memory little objects to speed up performance instead of doing DB lookups
We are processing 100 records a second (and it will keep growing), so we have to have stuff like a key value pair in memory (i.e. ImeiNumber, DB ID)

As each app has its own implementation of an in memory dictionary, and there are lots of them which all do different things, but ultimately storing the same data, I was thinking of a distributed memory cache, or some sort of API where it returns the data instead of doing a DB lookup
I think an API will be heavier, and currently apps 2,3and4 are on same windows 2016 server

I've been looking around and found memcache and memcacheD
However, it seems quite related to php etc, and not .net
I was wondering if there are are pure .net alternatives
We are using framework 4.5

What would you do in my position, and have you had an real experience with this
I'm currently a bit overwhelmed with all the data online, and would value so guidance and advice of what to use
0
I'm using Razor but i'm not knowing it well (inherited project).

Context

I'm using it to respond to a Twilio Conference Callback.  Twilio server send me a msg to tell me that a conference started/ended or participant joined/left, and no mather what i return in the <response></response>, it won't be executed.   But Twilio specifically request to return this empty response otherwise it trig a warning.

What i want to do

I would like to make one or more calls to external web pages to notify our services, and still return that empty response to make sure Twilio doesn't trig a warning.


Anyone can give me some help?

I've tried response.redirect in my callback, but of course, it doesn't return an empty response since and it's doesn't make Twilio Server happy.

Thanks for your help
0
I had this question after viewing Error 1053: The service did not respond to the start or control request in a timely fashion..

Hello,
I have exact the same issue as above.  I installed the Windows Service, when tried to Start the Service inside the Services window I received the error message below.  I looked at the above link, but it did not help me.  Any idea why I am getting this?  Please help.  Thank you in advance.

Error 1053: The service did not respond to the start or control request in a timely fashion.

Thank you!
0
I have a  asp.net site which contains a Create User Wizard.  Furthermore there is a Label on the outside of the Create  User Wizard.   I want the text  from the   asp:Label Id="txtCategory"    to  appear in the  asp:label "txtCategory1" in the Content Template of  Create User Wizard..  
Please help me with the best manner to have this happen at Page Load.

Thanks


    <asp:Label ID="txtCategory" runat="server"></asp:Label>
                       
<asp:CreateUserWizard ID="CreateUserWizard2" runat="server">
                                 <WizardSteps>
                                     <asp:CreateUserWizardStep ID="CreateUserWizardStep2" runat="server">
                                         <ContentTemplate>
                                             <table>
                                                 <tr>
                                                     <td align="center" colspan="2"> <asp:Label ID="txtCategory1" runat="server"></asp:Label></td>
                                                 </tr>
                                                 <tr>
                                                     <td align="right">
                                                         <asp:Label ID="UserNameLabel" runat="server" AssociatedControlID="UserName">User Name:</asp:Label>
                                                     </td>
                                                     <td>
                                     …
0
Concerto Cloud for Software Providers & ISVs
LVL 4
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

How would I write a query in MS SQL that lists all the fields in a table in the following format:

"camelCaseTableName"."FieldName"

Changing the first letter of the table name to lower case would be a big plus.  :)

Thanks!!!
0
NestingLayout.png
Here is my layout i need this in visual studio c# or c++ please help me to soft this problem. here i requested to give me idea to process layout like this,

thanks in advance
0
I have a program that needs to support the old ADODB objects (it's a long story). Anyway, apparently if the SQL command passed to the ADODB.Command object contains a cursor and is running against Microsoft SQL Server, ADO allows the code to continue execution even if the cursor isn't finished. In order to address this, we're trying to force the ADO command object to run asynchronously and then have the code halt execution until the ExecuteComplete event has fired. I'm not sure how to do this. Here's basically the (pseudo)code that I need.
private bool IsFinished = false;
public void RunADOCommand(string, sqlStatement, ADODB.Connection conn, ADODB.Command cmd)
{
    IsFinished = false;
    conn.ExecuteComplete += Conn_ExecuteComplete // attach event handler
    // ... do prep stuff here
    cmd.Execute(out recordsAffected, ref parameters, (int)ExecuteOptionEnum.adAsyncExecute);
    // !!!HERE IS WHERE I NEED TO WAIT for the ExecuteComplete event to fire
    return;
}
private void Conn_ExecuteComplete(int RecordsAffected, Error pError, ref EventStatusEnum adStatus, Command pCommand, Recordset pRecordset, Connection pConnection)
{
    IsFinished = true;
}

Open in new window

So far, everything I've tried like making the function async, using ManualResetEvent for signaling, etc... have just resulted in the main thread hanging.
0
Hi,
I have two tables, Table1 and table2, with the same structure, and same keys (D1, D2 ...). Is possible to sum and copy automatically values to a third table.
Attached image with exemple.

best regards
vb.net
Img9.png
0
good day,
i am developing with window form app
i want to click on a button which i put in another class to load a  rdlc report to be able to view the data immediately. because right now i must restart the app to be able to view the data in the report.
this is my code
there is the function to load the report in the class name Preview
 
        public void loadDetail(String client, String project, String batch, String sample)
        {
            using(sieve_db db = new sieve_db())
            {
                bindingSource1.DataSource = db.procedureForDetailSample(client, project, batch, sample);
                bindingSource2.DataSource = db.getPoints_sieve_tests(client, project, batch, sample);
                bindingSource3.DataSource = db.getAtterbergLimit(client, project, batch, sample);
                ReportDataSource rd1 = new ReportDataSource("Sieve", bindingSource2);
                ReportDataSource rd2 = new ReportDataSource("AtterbergLimit", bindingSource3);
                ReportDataSource rd3 = new ReportDataSource("Samples", bindingSource1);
                ReportParameter[] rpt = new ReportParameter[]
                {
                    new ReportParameter("client", client),
                    new ReportParameter("project", project),
                    new ReportParameter("batch", batch),
                    new ReportParameter("sample", sample)
                };
                reportViewer1_sieve.LocalReport.SetParameters(rpt);
            

Open in new window

0
i select the below data out of a database at lets say 1pm a csv file like below is outputt:

ID NAME      ADDRESS                        CITY              STATE    ZIPCODE
1   Nerd    123 something drive    SomeCity      MI          49546
2   BOSS    123 something drive    SomeCity      MI          49546
3   HEY      123 something drive    SomeCity      MI          49546
4   YOU     123 something drive    SomeCity      MI          49546
5   Love     123 something drive    SomeCity      MI          49546

this is my data in the database at 1.05 pm a csv file like below is generated a user probably went in and changed a few informations:

ID NAME      ADDRESS                        CITY              STATE    ZIPCODE
1   Nerd    123 something drives   SomeCity      MI          49546
2   BOSS    123 something drive   SomerCity     MI          49546
3   HEY      123 something drive    SomeCity      MI          49546
4   YOU     123 something drive    SomeCity      MI         49547

so now what i need help with:

each time a job runs i would like to keep a archive of the data appended to the existing text file in one place and compare that with the new data and only write any new customers or changed customers to the master file. how can i accomplish that?? so each time a file like below is created and and next time i send a file the below data should be missing and only new data,changed data and if there is not change then no data …
0

C#

92K

Solutions

25K

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