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


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

Not inserting in table correctly :\

Posted By:      Posted Date: October 13, 2010    Points: 0   Category :ASP.Net
 
select territory,load_year,'Forecast SPECTRUM - Month Sales' as Title,
case when (load_year = @load_year and load_month = 1) then M1_Color else null end as ColorJan,
case when (load_year = @load_year and load_month = 1) then M1_Value else null end as ValueJan,
case when (load_year = @load_year and load_month = 2) then M1_Color else null end as ColorFeb,
case when (load_year = @load_year and load_month = 2) then M1_Value else null end as ValueFeb,
case when (load_year = @load_year and load_month = 3) then M1_Color else null end as ColorMar,
case when (load_year = @load_year and load_month = 3) then M1_Value else null end as ValueMar,
case when (load_year = @load_year and load_month = 4) then M1_Color else null end as ColorApr,
case when (load_year = @load_year and load_month = 4) then M1_Value else null end as ValueApr,
case when (load_year = @load_year and load_month = 5) then M1_Color else null end as ColorMay,
case when (load_year = @load_year and load_month = 5) then M1_Value else null end as ValueMay,
case when (load_year = @load_year and load_month = 6) then M1_Color else null end as ColorJun,
case when (load_year = @load_year and load_month = 6) then M1_Value else null end as ValueJun,
case when (load_year = @load_year and load_month = 7) then M1_Color else null end as ColorJul,
case when (load_year = @load_year and load_month = 7) the


View Complete Post


More Related Resource Links

Fetch Identity column just after inserting a row in table

  
Hi, Please help me with this question. I have a table and I insert a row into it. How can i select the latest inserted row? Can the 'inserted table' keyword be used outside trigger? ( I mean can we use it in above scenario?? If yes how)   Thanks in advance Tiya

My repeating table did not open/load correctly

  
In my browser-enabled form I am using a webservice to get data from one look up table in my database. The table consists of two columns (ProdId and ProdDescription). In order to allow the user to select more than one products, I bind  this data to a repeating table where the productId column converted from a check box to a checkbox instead. So every row of this repeating table have a checkbox in the first column so the user can make selection and a textbox in the second column to list the Product Description. When the user open/load the existing form where multiple selection was made to the repeating table none of the checkboxs were checked. I have no idea how to go about to fix this issue and i can use some help. So far i have not use any codes for my form so i would like to stay codeless and using rules instead. Thank you in advance.

inserting an array of data into a database table

  
im looking to insert an array of information into a database tableessentially what id like to do is something like this:            objCmd = New OleDb.OleDbCommand("INSERT INTO pluINFO VALUES *", objConn)            For j = 0 To 265                objCmd.Parameters.Add( info(j) )            Next this code gives me a syntax error for the insert statement is there anyway i can set the insert statement that would allow me to add each element of the array(looping through rather than hardcoding several hundred entries) into the table?any input appreciatedThanks

Get inserted ids when inserting from User Defined Table Type

  
Imagine this procedure:   CREATE PROCEDURE [dbo].[insertActive] ( -- Add the parameters for the stored procedure here @p_data dbo.activeUpdate readonly) AS BEGIN -- SET NOCOUNT ON added to prevent extra result sets from -- interfering with SELECT statements. insert into dbo.active (name,stateid) select name,stateid from @p_data END How can I get the ids of the rows that have been inserted?  I tried searching the net and the forums but could not find anything. Thanks for any and all help, Gareth.

Problem Facing While Inserting records into table which os dynamicaly created

  
Hi,I have created table into database dynamicaly,while inserting records into that dynamic table i faced problem.The name "STD000001" is not permitted in this context. Valid expressions are constants, constant expressions, and (in some contexts) variables. Column names are not permitted. this error occured.I created dynamic table by ,declare @STUDENT_Table varchar(50)set @STUDENT_Table = [dbo].[GetStudentTable](@SchoolID)declare @cmd varchar(5000)Set @cmd = 'Create Table  ' + @STUDENT_Table + '(   [student_id] [varchar](10)NOT NULL,    [school_id] [varchar](50)NULL,    [class1] [varchar](50)NULL,    [division1] [varchar](50)NULL,    [educalis_id] [varchar](16)NULL,    [roll_no] [varchar](10)NULL,    [first_name] [varchar](50)NULL,    [middle_name] [varchar](50)NULL,    [last_name] [varchar](50)NULL,    [gender] [varchar](6)NULL,    [father_name] [varchar](50)NULL,    [mother_name] [varchar](50)NULL,    [father_office_address] [varchar](200)NULL,    [mother_office_address] [varchar](200)NULL,    [home_address] [varchar](200)NULL,    [father_mobile_no] [varchar](10)NULL,    [mother_mobile_no] [varchar](10)NU

pushing 2columns of one table to another table after filtering(eliminating nulls & inserting only ip

  
hi thankz in advance,i have 2 tables t1 and t2in t1 i have 4 columns from that i want to insert only 2 columns to another table t2 i only want to send data which is in the form of ip adress like(123.123.123.123)after eliminating nulls and other data.plz suggest me is it possible to write a query or i need to do it programetically.thankz a lot..

inserting one table data to another after filtering nulls and duplicates

  
hi i have tbl_ip i want to filter nulls and duplicate to my tbl_ipfilter can u suggest me a stored procedure for this. data of tbl_ip is like below . ip 27.24.83.105 NULL NULL NULL 92.20.83.203 92.20.83.203 67.21.83.315

Problem when Inserting xml data into a table using OpenXml

  
Hi, i stuck with a problemam trying to insert data from xml file to sql server.i made query like thisSET NOCOUNT ON DECLARE @hDoc INT EXEC sp_xml_preparedocument @hDoc OUTPUT, '<NewDataSet>  <xs:schema id=''NewDataSet'' xmlns='''' xmlns:xs=''http://www.w3.org/2001/XMLSchema'' xmlns:msdata=''urn:schemas-microsoft-com:xml-msdata''>  <xs:element name=''Job''>     <xs:complexType>      <xs:sequence>        <xs:element name=''BillToNo'' type=''xs:string'' minOccurs=''0'' /> <xs:element name=''Colors'' type=''xs:string'' minOccurs=''0'' /> <xs:element name=''CompanyNo'' type=''xs:string'' minOccurs=''0'' /> <xs:element name=''CsrCode'' type=''xs:string'' minOccurs=''0'' /> <xs:element name=''CsrName'' type=''xs:string'' minOccurs=''0'' /> <xs:element name=''CustomerPoNo'' type=''xs:string'' minOccurs=''0'' /> <xs:element name=''DivisionOriginal'' type=''xs:string'' minOccurs=''0'' /> <xs:element name=''EstimateNo'' type=''xs:string'' minOccurs=''0'' /> <xs:element name=''FinalDeliveryDate'' type=''xs:string'' minOccurs=''0'' /> <xs:element name

inserting data to Users Table in ASPNETDB from Create User Wizard

  

When a user starts a membership using the Create User wizard supplied by the aspnetdb profile service, I need to add a field to a table in aspnetdb and upon clicking the ContinueButtonClick insert some data.  The field I'll add is "SubscId".  My first question is what table is best for this - Users or Membership?

Secondly, what is the best way to insert new data for this scenario?  code behind?  markup?  Can someone provide basic syntax of insert code in code behind for this scenario?


Save Changes not working correctly when SQL table has a trigger

  

Hi all,

My WCF isn't working currently when a SQL table has a trigger on it that updates a column.

My table:

(SalesID int, SalesNumber nvarchar(10), OrderType nvarchar(3), OrderDate datetime) the trigger creates a new formatted string value for SalesNumber based on the OrderType and the SalesID, e.g GRN00001

The trigger is applied when the WCF service adds a new record. But the return values for SalesNumber is still NULL. I'm not sure why it will not update. If I restart the programme it retrieves the correct data...

public tblSales tblSales_Save(tblSales dsUpdated)
{
  db.tblSales.ApplyCurrentValues(dsUpdated);
  db.SaveChanges();
  return dsUpdated;
}

public tblSales tblSales_Save(tblSales dsUpdated)
{
  db.tblSales.ApplyCurrentValues(dsUpdated);
  db.SaveChanges();

  tblSales dsNew = tblSales_FindID(dsUpdated.SaleOrderID);
  return dsNew;
}


Neither way works...

 

 

 


Save Changes not working correctly when SQL table has a trigger

  

Hi all,

My WCF isn't working currently when a SQL table has a trigger on it that updates a column.

My table:

(SalesID int, SalesNumber nvarchar(10), OrderType nvarchar(3), OrderDate datetime) the trigger creates a new formatted string value for SalesNumber based on the OrderType and the SalesID, e.g GRN00001

The trigger is applied when the WCF service adds a new record. But the return values for SalesNumber is still NULL. I'm not sure why it will not update. If I restart the programme it retrieves the correct data...

public tblSales tblSales_Save(tblSales dsUpdated)
{
  db.tblSales.ApplyCurrentValues(dsUpdated);
  db.SaveChanges();
  return dsUpdated;
}

public tblSales tblSales_Save(tblSales dsUpdated)
{
  db.tblSales.ApplyCurrentValues(dsUpdated);
  db.SaveChanges();

  tblSales dsNew = tblSales_FindID(dsUpdated.SaleOrderID);
  return dsNew;
}


Neither way works...

 

 

 


Inserting and querying data on the same table

  

I need to implement a logic where in I insert or update a table in a loop.If the record is inserted then I need to update the table.To check this I have given IF NOT EXISTS statement with a query. But IF NOT EXISTS always returns true, so many records are getting inserted and update always fails

How do I resove this problem


getting error while inserting values into table in sql server 2005

  
i have connected to sql server n my connection string is

conn.ConnectionString =

"data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\subi.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True"

But i am not able to insert values into the table..

am getting sqlexception error.... and msg as invalid object name "staff" as staff is my table name.. before this i had some problem with connection then i cleared that problem then after that this problem occured.. plz guide me on this ... i need to complete my project as soon as possible


Inserting 15 minute Interval Data in a table

  

What is the most efficient way of creating a 15 minute increment table. This table needs to continue to increment with time so its not a static table. While loop? how will that affect the performance, if I have to add dates starting 2005 till today and then basically after that with every hour a value needs to be added.. How can I go about doing that?

I am using SQL 2008

 Thanks -Sarah


Inserting XML into SQL Server 2008 table

  

Hi,

I'm generating an XML file from front end, I'm using 4 Data Transfer Object classes comprising of full details of a Customer like CustomerPersonalInfoDTO.cs, CustomerLoginInfoDTO.cs, CustomerPreviousAddressDTO.cs, CustomerAddressInfoDTO.cs.

Everything is fine and XML is also generated, But the problem is with SQL Server Stored Procedure. I've created a table Customer with 20 columns.

CustomerPersonalInfoDTO.cs holds 10 customer fields and CustomerLoginInfoDTO.cs holds another 10 customer fields (total =20)..

I now need to insert at a time these 20 FIELDS into SQL server Customer Table. My XML Data will look like the below:


<?xml version="1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" ?> 
- <CustomerDTO>

- <CustomerPersonalInfo>
  <CustomerId>29291ac4-68a3-46c2-a0ed-52d01a97036b</StudentId> 
  <CustomerTitle>Mr.</StudentTitle> 
  <CustomerfirstName>XX</StudentfirstName> 
  <CustomerlastName>XX</StudentlastName> 
  <CustomerSurname>XX</StudentSurname> 
  <CustomerReligionId>d573ac51-818b-462c-a6b7-59baa07084a4</ReligionId> 
  <CustomerCategoryId>413aa4e0-a4c0-460c-aa3f-3c302f426bd0</CategoryId> 
  <

Inserting value of a textbox into a table

  

I have a detailsview, and I was wondering how I can insert value from a textbox instead of a boundfield value. I am able assign value to textbox in code behind. Could I please know of a simple way to do this. Thanks

<div>
    <asp:DetailsView ID="DetailsView4" DataSourceID="AccessDataSource6" 
             runat="server" Height="250px" Width="625px" AutoGenerateInsertButton="True" 
             AutoGenerateEditButton="True" AutoGenerateDeleteButton="True" 
             AutoGenerateRows="False" DefaultMode="Insert">
        <Fields>                 
                
                    <asp:BoundField DataField="PartNumber" HeaderText="PartNumber"
                  SortExpression="PartNumber" HeaderStyle-Width="100" /> 
                  <asp:BoundField DataField="QtyOrdered" HeaderText="QtyOrdered"
                  SortExpression="QtyOrdered" /> 
                  <asp:BoundField DataField="Units" HeaderText="Units"
                  SortExpression="Units" /> 
                   <asp:BoundField DataField="QtyReceived" HeaderText="QtyReceived"
                  SortExpression="

Inserting null value into foreign key table with allow null enabled

  

Hey guys, 

I have 2 table Table A, Table B.

Table A - Parent Table

ID - Uniqueidentifier not null(PK)

Table B -Child Table              

ID - uniqueidentifier null(FK, TableA)


I have a stored procedure to insert data into Table B, but when I tried to insert a null value into column ID of table B, this error came up:

The INSERT statement conflicted with the FOREIGN KEY constraint "FK_tableB_tableA". The conflict occurred in database "database name", table "table A", column 'ID'.

The statement has been terminated.

The insert statement in asp.net is like so:

sqlcommand.parameter.add(New Sqlparameter("ID", Nothing))


I am guessing adding nothing to the null value column is the problem, but i don't know how to fix it... can any1 help me?


Zeph

The INSERT statement conflicted with the FOREIGN KEY constraint "FK_tableB_tableA". The co

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