Tag: asp.net

Unrequired file created when breaking from an if else statement in Excel Impot

I am using C# VS2005 and SQL Server 2005. I have an Excel import function for my web application. The import works perfectly if the file chosen by user is correct, and I have made an if-else statement to check for the file content type, and return; if the file type is incorrect. However, whenever […]

SqlCommand parameters aren't working properly

Consider the following code: SqlConnection conn = new SqlConnection(@”connection string”); SqlCommand ourCommand = new SqlCommand(String.Format( @”SELECT Field1,Field2,Field3 FROM Tbl WHERE Field1 LIKE ‘@FL1′”), conn); ourCommand.CommandTimeout = 6000; ourCommand.Parameters.AddWithValue(“@FL1”, TextBox1.Text); SqlDataAdapter adapter = new SqlDataAdapter(ourCommand); DataTable dt = new DataTable(); conn.Open(); adapter.Fill(dt); GridView1.DataSource = dt; GridView1.DataBind(); The problem is that datatable is empty – which means […]

How can I sum the last 15 rows in my database table?

I have a Sales table, with the following columns: employeeID amount date Now I want to SUM up the last 15 rows, so I am currently doing: SELECT TOP 15 SUM(amount) FROM Sales ORDER BY [Date] DESC But I get 15 rows obviously, is there a way I can sum it up and not have […]

How to generate a column with id which increments on every insert

This is my table where i want my PNRNo to be generated as ‘PNRRES001’ for the first entry, and consecutive entries with ‘PNRRES002′,’PNRRES002’ so on. So while creating table only i called that column to function which will generate the PNR no, User just has to enter the CustomerNo from the front end, and data […]

Using if exists

I’m having an issue with duplicates being inserted on refresh. Our team here decided using ‘if exists’ in sql is the best way to stop duplicate inserts. However, what if a parameter is set to null? string cmdText = ” if (not exists(select * from table where field1 = @field1 and field2 = @field2 and […]

ASP.NET Membership on .NET 4.0 Multi-Tenant app. Default or Custom?

This is my first attempt, trying to integrate Membership on an existing shop already in production. I’m not quite sure, based on my scenario, if I should use the build-in aspnet-providers or custom implementations of them in order to integrate membership. Here’s a few details: I have a multi-tenant, single database, single schema web app […]

Empty database tables after Visual Studio Web Deploy

EF6, Identity 2, MVC5, C# using Visual Studio 2013.2 Express for Web. SQL Express on local PC. Am trying to publish using Web Deploy to MS SQL 2012. In the Web Deploy configurations my databases appear and I have configured the Connection Strings in both Web.config as well as the Web Deploy configuration dialog. Test […]

Simple SELECT in C# throws “Incorrect syntax near '='”

I am trying to get data from my database using the SqlDataReader But I am getting a syntax error “System.Data.SqlClient.SqlException: Incorrect syntax near ‘=’” and I don’t know what its about. Here is my code cmd = new SqlCommand(“Select Submission_Attachment as Path from Tasks where Submission_FileName =” + FileName, con); reader = cmd.ExecuteReader(); while (reader.Read()) […]

Cron job asp.net

I have a clockIn & clockOut module that records start time & end time for workers from an Asp.NET app. I want to ask how to do cron job for asp.net application to see if a worker has not entered their time on that date or week and send an email notification to remind them […]

asp.net quiz application

i want to create asp.net webforms, contain single multiple choice question on a form using formview que. and ans. from sql server table(sqldatasource). please give me a basic idea thanks

MS SQL Server is a Microsoft SQL Database product, include sql server standard, sql server management studio, sql server express and so on.