.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
Kaviya Balasubramanian
Sgraph Infotech
Imran Ghani
Post New Web Links

Delete spaces created by combining 2 fields

Posted By:      Posted Date: August 24, 2010    Points: 0   Category :ASP.Net
 

Howdy, this is kind of a continuation of an answer I got from this thread:  http://forums.asp.net/t/1592766.aspx

My users will enter a city/station where an incident occured, and the date.  The trigger below does work, but it will occasionally put spaces between the citystation and the date.  I think this happens when the citystaion name is not very long, but not sure.

(ex: city____08242010)

How can I make sure that if the incidentid is going to have spaces, that sql deletes those spaces?  I need the id to be space free.

Thanks!

===============================

ALTER

AS

TRIGGER [dbo].[tr_AddID1] ON [dbo].[tblIncidents] INSTEAD


View Complete Post


More Related Resource Links

delete a csv file created via StreamWriter?

  
I don't know if this is the correct forum.. but, is there a way I can automatically delete the following .csv file that was created via streamwriter (after it is viewed by an individual)?CODE (I would like to automatically delete the_filename.csv)://///////////////////////////////////////////////////////////////////////////////////////////////            string filename = "~/downloadfiles/data_complex987654321_filename.csv";             StreamWriter sw = new StreamWriter(HttpContext.Current.Server.MapPath(filename));             StringBuilder sb = new StringBuilder();            string filename = "~/the_filename.csv";            StreamWriter sw = new StreamWriter(HttpContext.Current.Server.MapPath(filename));            StringBuilder sb = new StringBuilder();

Can't get Distinct work, when combining fields from inner joined tables

  
Hi to all.I have a users table, each user has a session and each session has multiple parameters.I would like to retrieve all params for a specific user and get the paramID from the params table and the date submitted from the sessions table.This is the linq to SQL query so far:var items = (from param in db.Params join session in db.Sessions on param.SessionID equals session.ID where userID.Equals(session.UserID) //userID is the function argument orderby session.DateSubmitted descending select new { ParamID = param.ID, DateSubmitted = session.DateSubmitted }).Distinct(); I have noticed that when the DateSubmitted is fetched, i have multiple instances of a param in the result set, meaning that the Distinct does not work as expected. If i remove it like this:var items = (from param in db.Params join session in db.Sessions on param.SessionID equals session.ID where userID.Equals(session.UserID) //userID is the fu

delete workflow fields in a form

  
Hi I was testing a few workflows in a document library..after settling for the final workflow, I deleted the other workflows, however..the field still appears when I view the document library...How can i get rid of these fields, I know I can uncheck them from the view, but I want to delete this fields.

How to remove 'Delete Item' from context menu of a programmatically created list?

  
How to remove 'Delete Item' from context menu of a programmatically created list?
I have document library which is created programmatically but now I don't want to have 'Delete Item' in context menu of that document library. Are there any possibilites?

Default Calendar modification, unable to delete fields

  

Hello.  I'm new to Sharepoint Foundations 2010 (i've used Sharepoint Portal Server2007 and all the prior versions).  I would like to use the default calendar as a template but cannot delete the fields I do not want to use.  What are the steps to remove the fields (Something involving the Event Content Type) I do not wish to use?  I've tried deleting the content type but cannot (I get the following error: The last content type on a list cannot be deleted.Troubleshoot issues with Microsoft SharePoint Foundation. Correlation ID: bcb50019-5830-42f3-bde6-9b0353b803e1 Date and Time: 10/4/2010 2:24:05 PM ).  If I could create a new calendar with only the fields i need that has the current view in it that would be great.  I cannot seem to get a new view to mimic the current view from the calendar webpart.  any ideas could be greatly appreciated.

 

newbie


combining two fields with a group by

  
declare @jax table
(
cus nvarchar(50),
sum int,
sumly int,
rep nvarchar(50)
)

insert into @jax (rep,cus,sum)
SELECT     TOP 10 dbo.tblTerritory.fldSalesRep,dbo.ExecSales.CUSTOMER_NAME, 
                      SUM(dbo.ExecSales.JAN_SLS_AMNT + dbo.ExecSales.FEB_SLS_AMNT + dbo.ExecSales.MAR_SLS_AMNT + dbo.ExecSales.APR_SLS_AMNT + dbo.ExecSales.MAY_SLS_AMNT
                       + dbo.ExecSales.JUN_SLS_AMNT + dbo.ExecSales.JUL_SLS_AMNT + dbo.ExecSales.AUG_SLS_AMNT + dbo.ExecSales.SEP_SLS_AMNT + dbo.ExecSales.OCT_SLS_AMNT
                       + dbo.ExecSales.NOV_SLS_AMNT + dbo.ExecSales.DEC_SLS_AMNT) AS sum
FROM         dbo.tblTerritory INNER JOIN
                      dbo.ExecSales ON dbo.tblTerritory.fldBranch = dbo.ExecSales.BRANCHID
WHERE     (dbo.tblTerritory.fldSalesRep = N'mbradshaw') AND (dbo.ExecSales.load_year = 2010)
GROUP BY dbo.ExecSales.load_year, dbo.tblTerritory.fldSalesRep, dbo.ExecSales.BRANCHID, dbo.ExecSales.CUSTOMER_NAME
ORDER BY sum DESC


insert into @jax (rep,sumly)
SELECT     TOP 10  dbo.tblTerritory.fldSalesRep,SUM(dbo.ExecSales.JAN_SLS_AMNT + dbo.ExecSales.FEB_SLS_AMNT + dbo.ExecSales.MAR_SLS_AMNT + dbo.ExecSales.APR_SLS_AMNT + dbo.ExecSales.MAY_SLS_AMNT
                       + dbo.ExecSales.JUN_SLS_AMNT + dbo.ExecSales.JUL_SLS_AMNT + dbo.ExecSales.AUG_SLS_AMNT + dbo.ExecSales.SEP_SLS_AMNT + dbo.ExecSales.OCT_SLS_AM

Insert spaces to get fixed length fields for flat file export

  

Hi,

I have a query which extracts all the required data from a database and I need to load this data into a Text File. I am using a SSIS package to do this.

Now this file should have data in the format given below

437856785        A20101009This is construction         124728347

i.e the receiving file has no delimiters and each field is determined with a fixed length(fixed number of characters). The data I get out of my query for example for the first column returns just the value 437856785 and I need to append spaces to it to achieve the fixed length. I need to do to this kind of appending spaces to all the columns. Please suggest me ways to do this.

Thanks in advance..

 

 


Adding Dynamic Rows in ASP.NET GridView Control with TextBoxes and with Delete functionality

  
In my previous examples, I have demonstrated on how to add dynamic rows in GridView control with TextBoxes and how to save the values into the database. Now, seems that most of the developers are asking if how to add a delete functionality with it. So in this example, I'm going to show on how to delete a certain row in the dynamic GridView with TextBoxes.

SqlCommand.ExecuteNonQuery() returns -1 when doing Insert / Update / Delete

  
Sometimes you end up with a return value of -1 when using the SqlClient.SqlCommand.ExecuteNonQuery method.

Why is that?



Well, the ExecuteNonQuery method is there for statements for changing data, ie. DELETE / UPDATE /INSERT, and the returned value are the number of rows affected by that statement.

When checking the documentation we can see that there are some conditions that return -1.



For UPDATE, INSERT, and DELETE statements, the return value is the number of rows affected by the command.

When a trigger exists on a table being inserted or updated, the return value includes the number of rows affected by both the insert or update operation and the number of

rows affected by the trigger or triggers. For all other types of statements, the return value is -1. If a rollback occurs, the return value is also -1.

update/delete not working on server only

  

my aspx page works in VWD, and everything works on the server EXCEPT update and delete sql functions. any ideas?

thanks 


Create ID (uniqueid?) from two fields when data is entered

  

I need to create an ID from two fields when they are entered into the db for the first time.  I thought Uniqueidentifer would do this, but it looks like uniqueidentifier is random and i have no control of the process. 

My user will enter 4 letters into a column called INIT and 4 numbers into a column called NUMB.  What I would like to do is create an id by combining those fields.

How can I do this?

Thanks!

 


LINQ with GridView and edit fields

  

My project includes a grid view which displays information of inventory items (Assets), data is quried from AssetTable. The GridView has a command field to allow editing, below is a description of the tables and how data is displayed

Tables

BuildingTable: (BuildingID, BuildingName)

AssetTable: (BuildingID,..,....,....)

 

ItemTemplate: Using a LINQ query I join the two table and displays in a label control a string which includes BuildingID and BuildingName (5 North Building)

 EditItemTemplate: Using a LINQ query I populate a DropDownList with strings of BuildingID and BuildingName same as above.
 
Here  issue which I need to resolve:
1.  ItemTemplate display the correct information (BuildingID BuildingName) but when I switch to EditItemTemplate the pair that is 
displayed is the first one on the list, how do I make is scroll to the item which was displayed in the label ?
 
 
 
<asp:CommandField ShowEditButton="True" >
                    <ControlStyle Wi

How to use TOP in DELETE

  

Hi,

I have a large database in MSSQL 2005 (rows around 3,788,299 : size 4GB)

Two questions

1. SQL query ~ select top 100 * from [tablename], how do capture the next 100 record?

2. SQL query ~ delete top 100 from [tablename] --- MSSQL show me syntax error? How can I only delete the top 100 record?

 

thk.


delete record from excel sheet

  



Hello,

           I have write the code for deleting the data in excel sheet. but we have got the error" Deleting data in a linked table is not supported by this ISAM."

     below I paste some code snippest.

string strDelete = "Delete  from [" + strSheetName + "$]";

            cmdExcel.Connection = con;
            cmdExcel.CommandType = CommandType.Text;
            cmdExcel.CommandText = strDelete;

            cmdExcel.ExecuteNonQuery();


Please can anybody this answer.It is urgent


How to access a new database ( which i created ) in isqlplus ?

  

Hi.,

I created a new database with the help of Database Configuration Assistant !

I created with the scott account

Now i'm not able to connect to the database with the connect identifier with the scott account

The error i get is.,

ERROR - ORA-12154: TNS:could not resolve the connect identifier specified.

Plz help !



delete data in excel sheet

  

Hello,

           I have write the code for deleting the data in excel sheet. but we have got the error" Deleting data in a linked table is not supported by this ISAM."

     below I paste some code snippest.

string strDelete = "Delete  from [" + strSheetName + "$]";

            cmdExcel.Connection = con;
            cmdExcel.CommandType = CommandType.Text;
            cmdExcel.CommandText = strDelete;

            cmdExcel.ExecuteNonQuery();


Please can anybody this answer.It is urgent




I want Er Diagram for Fees System of small institution ,can u plz guide me what fields are necessary

  

I want Er Diagram for Fees System of small institution ,can u plz guide me what fields are necessary to store Fees information ...

 


Categories: 
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend