ASP.NET +Inserting Data From Xml In SQL Server Database Table From ASP.NET

May 31, 2007

hi

I want to read data from XML file and insert that data from XML file into the Database Table From ASP.NET page.
plz give me the code to do this using DataAdapter.Update(ds) 

View 1 Replies


ADVERTISEMENT

Lock On Table While Inserting Data In Database

Jul 10, 2014

I have question on lock on table in SQL Server while inserting data using multiple processes at a single time into same table.Here are my questions on this,

1) Is it default behavior of SQL server to lock table while doing insert?
2) if yes to Q1, then how we can implicitly mention while inserting data.
3) If I have 4 tables and one table is having foreign keys from rest of the 3 tables, on this scenario do I need to use the table lock explicitly or without that I can insert records into those tables?

View 1 Replies View Related

SQL Server 2008 :: Inserting Data From Staging Table To Main Table

Feb 23, 2015

I am trying to insert bulk data into main table from staging table in sql server 2012. If any error comes, this total activity is rollbacked. I don't want that to happen. I want to know the records where ever the problem persists, and the rest has to be inserted.

View 2 Replies View Related

Inserting Picture Into SQL Server Database Through Table

Jun 19, 2005

How to insert a picture into SQL Server 2000 table?
I want
1)Table structure.
2)Insert statement.
3)One example.

View 1 Replies View Related

Inserting Data From Access Table Into Sql Server With Vb.net

Jan 8, 2008

I am wanting to insert the data from a table in access into a table in an SQL database. I am using VB.Net 2005.

Any idea's, cheers, Darren.

View 5 Replies View Related

Inserting Blank Data In Sql Server Database - Why?!?!

Oct 23, 2006

Hi everyone!Hope that someone can help me solving this problem.I have a form where the user can register by putting his private data. Each time that he submits his data, if he is using Internet Explorer, it will insert blank data into sql server database. But if user is using Firefox, everything is working well, and all data is inserted.What seems to be the problem?Why in IE, data is inserted as blank?!Thanks for your possible help and attention to this issue.Hope that someone can help me.Best regards,Mesk

View 2 Replies View Related

Help With Inserting Data (and A Picture) Into My Sql Server 2005 Database

Feb 2, 2008

Hi,
I have a scenario where I want the current User to add details regarding their house in to my 'Property' table in my database and also store their uploaded picture in the same tabe when they press the 'Add Property' button.  I also want to store the current Users ID in the 'Property' table so the property being added is assigned to the current user.  Can anyone help me with the implementation of this?  Here is the code I have so far:
property.aspx page:
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<span style="font-size: 16pt; font-family: Bradley Hand ITC"><strong>Add Property</strong></span><table style="border-right: silver 3px outset; border-top: silver 3px outset; left: 337px;
border-left: silver 3px outset; border-bottom: silver 3px outset; position: relative;
top: 9px">
<tr>
<td colspan="2">
<strong><span style="font-size: 14pt; font-family: Bradley Hand ITC">
Address</span></strong></td>
</tr>
<tr>
<td style="width: 100px"><asp:Label ID="TownLabel" runat="server" Font-Bold="False" Height="23px" Style="vertical-align: middle;
text-align: right; font-family: 'Goudy Old Style';" Text="Town:" Width="97px"></asp:Label></td>
<td style="width: 100px">
<asp:TextBox ID="TownTextBox" runat="server"></asp:TextBox></td>
</tr>
<tr>
<td style="width: 100px"><asp:Label ID="CityLabel" runat="server" Height="23px" Style="vertical-align: middle;
text-align: right; font-family: 'Goudy Old Style';" Text="City:" Width="97px"></asp:Label></td>
<td style="width: 100px">
<asp:TextBox ID="CityTextBox" runat="server"></asp:TextBox></td>
</tr>
<tr>
<td style="width: 100px"><asp:Label ID="CountyLabel" runat="server" Height="23px" Style="vertical-align: middle;
text-align: right; font-family: 'Goudy Old Style';" Text="County:" Width="97px"></asp:Label></td>
<td style="width: 100px">
<asp:TextBox ID="CountyTextBox" runat="server"></asp:TextBox></td>
</tr>
<tr>
<td style="width: 100px"><asp:Label ID="CountryLabel" runat="server" Height="23px" Style="vertical-align: middle;
text-align: right; font-family: 'Goudy Old Style';" Text="Country:" Width="97px"></asp:Label></td>
<td style="width: 100px">
<asp:TextBox ID="CountryTextBox" runat="server"></asp:TextBox></td>
</tr>
<tr>
<td style="width: 100px"><asp:Label ID="PostcodeLabel" runat="server" Height="23px" Style="vertical-align: middle;
text-align: right; font-family: 'Goudy Old Style';" Text="Postcode:" Width="97px"></asp:Label></td>
<td style="width: 100px">
<asp:TextBox ID="PostcodeTextBox" runat="server"></asp:TextBox></td>
</tr>
</table>
<asp:Button ID="AddButton" runat="server" Text="Add Property" style="left: 378px; position: relative; top: 66px" /><tablestyle="border-right: silver 3px outset; border-top: silver 3px outset; left: 648px;
border-left: silver 3px outset; border-bottom: silver 3px outset; position: relative;
top: -190px">
<tr>
<td style="width: 186px">
<span style="font-size: 14pt; font-family: Bradley Hand ITC"><strong>Property Description</strong></span></td>
</tr>
<tr>
<td style="width: 186px">
<asp:TextBox ID="DescriptionTextBox" runat="server" Height="172px" Width="233px" TextMode="MultiLine"></asp:TextBox></td>
</tr>
</table><asp:FileUpload ID="PropertyPicture" runat="server" Style="left: 356px; position: relative;
top: -214px" />
<asp:SqlDataSource ID="AddProperty" runat="server" ConnectionString="<%$ ConnectionStrings:My Property PortfolioConnectionString %>"ProviderName="<%$ ConnectionStrings:My Property PortfolioConnectionString.ProviderName %>"
InsertCommand="INSERT INTO Property(User_ID, Property_type, Property_Name, Number_of_Rooms, Sleeps, Town, City, County, Country, Postcode, Description, Facility1, Facility2, Picture)
VALUES (@User_ID, @Property_type, @Property_Name, @Number_of_Rooms, @Sleeps, @Town, @City, @County, @Country, @Postcode, @Description, @Facility1, @Facility2, @Picture)">
<InsertParameters>
<asp:SessionParameter Name="User_ID" />
<asp:ControlParameter ControlID="TypeDropDownList" Name="Property_type" PropertyName="SelectedValue" />
<asp:ControlParameter ControlID="PropertyNameTextBox" Name="Property_Name" PropertyName="Text" />
<asp:ControlParameter ControlID="NoOfRoomsDropDownList" Name="Number_of_Rooms" PropertyName="SelectedValue" />
<asp:ControlParameter ControlID="SleepsDropDownList" Name="Sleeps" PropertyName="SelectedValue" />
<asp:ControlParameter ControlID="TownTextBox" Name="Town" PropertyName="Text" />
<asp:ControlParameter ControlID="CityTextBox" Name="City" PropertyName="Text" />
<asp:ControlParameter ControlID="CountyTextBox" Name="County" PropertyName="Text" />
<asp:ControlParameter ControlID="CountryTextBox" Name="Country" PropertyName="Text" />
<asp:ControlParameter ControlID="PostcodeTextBox" Name="Postcode" PropertyName="Text" />
<asp:ControlParameter ControlID="DescriptionTextBox" Name="Description" PropertyName="Text" />
<asp:ControlParameter ControlID="Facility1DropDownList" Name="Facility1" PropertyName="SelectedValue" />
<asp:ControlParameter ControlID="Facility2DropDownList" Name="Facility2" PropertyName="SelectedValue" />
<asp:Parameter Name="Picture" />
</InsertParameters>
</asp:SqlDataSource>
&nbsp;
<table style="left: 12px; position: relative; top: -411px; border-right: silver 3px outset; border-top: silver 3px outset; border-left: silver 3px outset; border-bottom: silver 3px outset;">
<tr>
<td colspan="2">
<strong><span style="font-size: 14pt; font-family: Bradley Hand ITC">
Property Details</span></strong></td>
</tr>
<tr>
<td style="width: 100px"><asp:Label ID="PropertyName" runat="server" Font-Bold="False" Height="23px" Style="vertical-align: middle;
text-align: right; font-family: 'Goudy Old Style';" Text="Property Name:" Width="101px"></asp:Label></td>
<td style="width: 100px">
<asp:TextBox ID="PropertyNameTextBox" runat="server"></asp:TextBox></td>
</tr>
<tr>
<td style="width: 100px"><asp:Label ID="NoOfRooms" runat="server" Height="23px" Style="vertical-align: middle;
text-align: right; font-family: 'Goudy Old Style';" Text="No of Rooms:" Width="97px"></asp:Label></td>
<td style="width: 100px">
<asp:DropDownList ID="NoOfRoomsDropDownList" runat="server">
<asp:ListItem>1</asp:ListItem>
<asp:ListItem>2</asp:ListItem>
<asp:ListItem>3</asp:ListItem>
<asp:ListItem>4</asp:ListItem>
<asp:ListItem>5</asp:ListItem>
<asp:ListItem>6</asp:ListItem>
<asp:ListItem>7</asp:ListItem>
</asp:DropDownList></td>
</tr>
<tr>
<td style="width: 100px"><asp:Label ID="Sleeps" runat="server" Height="23px" Style="vertical-align: middle;
text-align: right; font-family: 'Goudy Old Style';" Text="Sleeps:" Width="97px"></asp:Label></td>
<td style="width: 100px">
<asp:DropDownList ID="SleepsDropDownList" runat="server">
<asp:ListItem>1</asp:ListItem>
<asp:ListItem>2</asp:ListItem>
<asp:ListItem>3</asp:ListItem>
<asp:ListItem>4</asp:ListItem>
<asp:ListItem>5</asp:ListItem>
<asp:ListItem>6</asp:ListItem>
<asp:ListItem>7</asp:ListItem>
<asp:ListItem>8</asp:ListItem>
<asp:ListItem>9</asp:ListItem>
<asp:ListItem>10</asp:ListItem>
<asp:ListItem>11</asp:ListItem>
<asp:ListItem>12</asp:ListItem>
</asp:DropDownList></td>
</tr>
<tr>
<td style="width: 100px"><asp:Label ID="Type" runat="server" Height="23px" Style="vertical-align: middle;
text-align: right; font-family: 'Goudy Old Style';" Text="Type:" Width="97px"></asp:Label></td>
<td style="width: 100px">
<asp:DropDownList ID="TypeDropDownList" runat="server">
<asp:ListItem>Bungelow</asp:ListItem>
<asp:ListItem>Appartment</asp:ListItem>
<asp:ListItem>Flat</asp:ListItem>
<asp:ListItem>Studio</asp:ListItem>
<asp:ListItem>Cottage</asp:ListItem>
<asp:ListItem>House</asp:ListItem>
</asp:DropDownList>&nbsp;
</td>
</tr>
<tr>
<td style="width: 100px"><asp:Label ID="Facility1" runat="server" Height="23px" Style="vertical-align: middle;
text-align: right; font-family: 'Goudy Old Style';" Text="Facility 1:" Width="97px"></asp:Label></td>
<td style="width: 100px">
<asp:DropDownList ID="Facility2DropDownList" runat="server">
<asp:ListItem>Air conditioning</asp:ListItem>
<asp:ListItem>Dishwasher</asp:ListItem>
<asp:ListItem>En-suit</asp:ListItem>
<asp:ListItem>Garage</asp:ListItem>
<asp:ListItem>Garden</asp:ListItem>
<asp:ListItem>Internet</asp:ListItem>
<asp:ListItem>Pool</asp:ListItem>
</asp:DropDownList>&nbsp;
</td>
</tr>
<tr>
<td style="width: 100px"><asp:Label ID="Facility2Label" runat="server" Height="23px" Style="vertical-align: middle;
text-align: right; font-family: 'Goudy Old Style';" Text="Facility 2:" Width="97px"></asp:Label></td>
<td style="width: 100px">
<asp:DropDownList ID="Facility1DropDownList" runat="server">
<asp:ListItem>Pool</asp:ListItem>
<asp:ListItem>Air conditioning</asp:ListItem>
<asp:ListItem>Dishwasher</asp:ListItem>
<asp:ListItem>En-suit</asp:ListItem>
<asp:ListItem>Garage</asp:ListItem>
<asp:ListItem>Garden</asp:ListItem>
<asp:ListItem>Internet</asp:ListItem>
</asp:DropDownList></td>
</tr></table>
</asp:Content>
property.aspx.vb page:Partial Class Default2
Inherits System.Web.UI.PageProtected Sub AddButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles AddButton.Click
AddProperty.Insert()End Sub
End Class
Many Thanks

View 2 Replies View Related

Inserting Data Into Two Tables (Getting ID From Table 1 And Inserting Into Table 2)

Oct 10, 2007

I am trying to insert data into two different tables. I will insert into Table 2 based on an id I get from the Select Statement from Table1.
 Insert Table1(Title,Description,Link,Whatever)Values(@title,@description,@link,@Whatever)Select WhateverID from Table1 Where Description = @DescriptionInsert into Table2(CategoryID,WhateverID)Values(@CategoryID,@WhateverID)
 This statement is not working. What should I do? Should I use a stored procedure?? I am writing in C#. Can someone please help!!

View 3 Replies View Related

4 Layered Web Application For Inserting Data Into A Database Using Sql Server As The Back End And A Web Form As The Front End Using C#

Dec 10, 2005

4 Layered Web Application for Inserting data into a database using sql server as the back end and a web form as the front end using C# .
Can someone provide with code as I am new to this architecture and framework.
Better send email.
Thanks In Advance,
A New Bie

View 1 Replies View Related

Inserting Data To Text File From Database And Inserting Data Back To Database From Text File

Aug 7, 2007

Hello friends....
I am looking for 2 things(using c#.net or vb.net and sql svr 2000)
1.convert data from sql server 2000 database (say customers table from northwinds database) to a text file(separated by commas or just plain space)
2.Insert the data from text file back to database.
Can someone pls give me the detailed code to achieve this....really need this on urgent basis.......Thank You.

View 10 Replies View Related

Inserting Distinct Data From One Table In Another Table, How?!?Really Urgent And Needing Help!!!

May 24, 2007

 Hi, I have a table in which I will insert several redundant data. Don't ask why, is Integration services, it only reads data and inserts it in a SQL table. THis way, I have a SQL table with several lines repeating them selves. What I want to do is create a procedure that reads the distinct data and inserts it in another table, but my problem is that I am not able to select data line by line on the original table to save it in local variables and insert it on the another table, I just can select the last line. I've tried a while cycle but no succeed. Here is my code: create proc insertLocalizationASdeclare @idAp int, @macAp varchar(20), @floorAp varchar(2), @building varchar(30), @department varchar(30)select @idAp = idAp from OLTPLocalization where idAp not in (select idAp from dimLocalization)select @macAp=macAp,@floorAp=floorAp,@building=building,@department=department from OLTPLocalizationif (@idAp <> null)beginInsert into dimLocalization VALUES(@idAp,@macAp,@floorAp,@building,@department)endGO This only inserts the last line in the "oltpLocalization" table. O the other hand, like this:create proc aaaaasdeclare @idAp as int, @macAp as varchar(50), @floorAp as int, @building as varchar(50), @department as varchar(50)while exists (select distinct(idAp) from OLTPLocalization)begin    select @idAp =idAp from OLTPLocalization  where idAp not in (select idAp from dimLocalization)    select @macAp = macAp from OLTPLocalization where idAp = @idAp    select @building = building from OLTPLocalization where idAp = @idAp    select @department = department from OLTPLocalization where idAP = @idApif (@idAp <> null)begin    insert into dimLocalization values(@idAp,@macAp,@floorAp,@building,@department)endendgo this retrieves every distinct idAp in each increment on the while statement. The interess of the while is really selecting each different line in the OLTPLocalization table. I did not find any foreach or for each statement, is there any way to select distinct line by line in a sql table and save each column result in variables, to then insert them in another table? I've also thought about web service, that reads the distinct data from the oltpLocalization into a dataset, and then inserts this data into the dimLocalization table. Is there anything I can do?Any guess?Really needing a hand here!Thanks a lot!

View 1 Replies View Related

Transact SQL :: Table Structure - Inserting Data From Other Temp Table

Aug 14, 2015

Below is my table structure. And I am inserting data from other temp table.

CREATE TABLE #revf (
[Cusip] [VARCHAR](50) NULL, [sponfID] [VARCHAR](max) NULL, GroupSeries [VARCHAR](max) NULL, [tran] [VARCHAR](max) NULL, [AddDate] [VARCHAR](max) NULL, [SetDate] [VARCHAR](max) NULL, [PoolNumber] [VARCHAR](max) NULL, [Aggregate] [VARCHAR](max) NULL, [Price] [VARCHAR](max) NULL, [NetAmount] [VARCHAR](max) NULL,

[Code] ....

Now in a next step I am deleting the records from #revf table. Please see the delete code below

DELETE
FROM #revf
WHERE fi_gnmaid IN (
SELECT DISTINCT r2.fi_gnmaid
FROM #revf r1, #revf r2

[Code] ...

I don't want to create this #rev table so that i can avoid the delete statement. But data should not affect. Can i rewrite the above as below:

SELECT [Cusip], [sponfID], GroupSeries, [tran], [AddDate], [SetDate], [PoolNumber], [Aggregate], [Price], [NetAmount], [Interest],
[Coupon], [TradeDate], [ReversalDate], [Description], [ImportDate], MAX([fi_gnmaid]) AS Fi_GNMAID, accounttype, [IgnoreFlag], [IgnoreReason], IncludeReversals, DatasetID, [DeloitteTaxComments], [ReconciliationID],

[Code] ....

If my above statement is wrong . Where i can improve here? And actually i am getting 4 rows difference.

View 5 Replies View Related

Inserting Data From One Table To Another

Aug 5, 2007

Hi, I have two tables in a data base and i'm inserting the data from one into the other...no probs. What i was wondering is, in table1 i have an column of ID numbers. In the table2 i have a matching set of ID numbers. There are 5 PersonID numbers in table one and 10 in table two, the same 5 numbers as in table1 but each ID has a duplicate with different data in the two rows.

SAMPLE:

INSERT
INTO Table1 (PersonID, level1, Level2, Level3, Level4)
SELECT PersonID,level1, Level2, Level3, Level4
FROM Table2

When i insert the data into table1 it leaves the first 5 rows of data as null and then populates the table with all the data from table two. Is there anyway of preventing these first 5 columns from remaining empty....

I hope that makes sense

View 3 Replies View Related

Inserting Data Into Another Table

Jan 22, 2008



Hi, I'm fairly new to SQL Server 2005.
i have a table that creates customer id's along with other data (let's call it Customer)
I would like to take the same customer_id data and import it into a different table (HQ_Customer) the new table also has different column names.

Is there a script that can be used for this problem?

View 5 Replies View Related

Inserting Data From One Table To Another

May 15, 2006

Well, I think this should be an easy question, but here goes:
I'm taking data from one table and inserting it into another. According to the SQL Server Mobile Book Online, the syntax goes like this:
INSERT INTO Table1 (col1, col2) SELECT (col1, col2) from Table2

So while I can do this with my tables:
INSERT INTO sensor_stream (sensor_stream_id) SELECT (sensor_stream_id) FROM sensor_stream_temp

If I add any more columns, I get an error. Like this:
INSERT INTO sensor_stream (sensor_stream_id, sensor_stream_type_id) SELECT (sensor_stream_id, sensor_stream_type_id) FROM sensor_stream_temp
The error is "There was an error parsing th equery. [ Token line number =1, Token line offset = 98, Token in error = ',' ]"

Anyone have any ideas about why I cannot do more than one column at a time?
TIA,
-Dana

View 4 Replies View Related

How To Create Table A By Inserting All Data From Table B?

Jan 16, 2005

Hi,

Anyone can help me?

How to create Table A by inserting all the data from Table B?

Cheers,
Daniel.

View 1 Replies View Related

Inserting Data Into A Table Referencing PK From Another Table

May 12, 2008

How do i insert data into multiple tables. Lets say i have 2 tables: Schedules and Event

Schedules data is entered into the Schedules Table first

then now i need to insert Event table's data by refrencing the (PK ID) from the schedules table.

How do i insert data into Event table referencing the (PK ID) from Schedules Table ?


Fields inside each of the tables can be found below:




Event Table
(PK,FK) ScheduleID
EventTitle
AccountManager
Presenter
EventStatus
Comment

Schedule Table
(PK) ID


AletrnateID
name
UserID
UserName
StartTime
EndTime
ReserveSource
Status
StatusRetry
NextStatusDateTime
StatusRemarks

View 2 Replies View Related

Regarding Inserting Data From GUI To Database

Feb 28, 2008

Hi iam working with the form which has fields like AuditName,Industry Name,Company Name,Plant Name,Group Name,AuditStartedOn,Auditperiod upto,CreatedOn,createdby
I have dropdownlists for Industry Name,Company Name,Plant Name,Group Name.Data will be filled into Industry Name,Group Name when pageloads from the database and later depending on industryname company name and depending on company name plant name ddl's wiil be filled.
Later to insert this into the Audit table i had given the Stored procedure as :
create procedure CreateAudit
(
@AuditName nvarchar(50),
@IndustryName nvarchar(50),
@IndustryID int output,
@CompanyName nvarchar(50),
@CompanyID int output,
@PlantName nvarchar(50),
@PlantID int output,
@GroupName nvarchar(50),
@GroupID int output,
@AuditStartedOn datetime,
@AuditScheduledto datetime,
@CreatedOn datetime,
@CreatedBy int
)
as
begin
//Here iam getting the Id of the industryname selected in the ddl from industry table into an output parameter  @IndustryID
select @IndustryID=Ind_Id_PK from Industry where Industry_Name=@IndustryName
//Here iam getting the Id of the companyname selected in the ddl from company table into an output parameter  @CompanyID
select @CompanyID=Cmp_ID_PK from Company where Company_Name=@CompanyName
//Here iam getting the Id of the plantname selected in the ddl from plant table into an output parameter  @PlantID
select @PlantID=Pl_ID_PK from Plant where Plant_Name=@PlantName
//Here iam getting the Id of the Groupname selected in the ddl from Group table into an output parameter  @GroupID
select @GroupID=G_ID_PK from Groups where Groups_Name=@GroupName
Insert into Audits(Audit_Name,Audit_Industry,Audit_Company,Audit_Plant,Audit_Group,Audit_Started_On,Audit_Scheduledto,Audit_Created_On,Audit_Created_By)values(@AuditName,@IndustryID,@CompanyID,@PlantID,@GroupID,@AuditStartedOn,@AuditScheduledto,@CreatedOn,@CreatedBy)
end
Later called these parameters into class file:
 
namespace xyz{
public class clsCreateAudit
{SqlConnection con = new SqlConnection(ConfigurationSettings.AppSettings["constr"]);
SqlCommand cmd = new SqlCommand();SqlDataAdapter da = new SqlDataAdapter();public clsCreateAudit()
{
con.Open();
}public void CreateAudit(string Audit_Name, int Audit_Industry, int Audit_Company, int Audit_Plant, int Audit_Group, DateTime Audit_Started_On, DateTime Audit_Scheduledto, DateTime Audit_Created_On, string Audit_Created_By)
{
cmd.Connection = con;cmd.CommandType = CommandType.StoredProcedure;
cmd.CommandText = "CreateAudit";
SqlParameter AuditName = new SqlParameter();AuditName.ParameterName = "@AuditName";AuditName.DbType = DbType.String;
AuditName.Value = Audit_Name;AuditName.Direction = ParameterDirection.Input;
cmd.Parameters.Add(AuditName);
SqlParameter AuditIndustry = new SqlParameter();AuditIndustry.ParameterName = "@IndustryName";AuditIndustry.Direction = ParameterDirection.Input;
AuditIndustry.Value = Audit_Industry;AuditIndustry.DbType = DbType.String;
cmd.Parameters.Add(AuditIndustry);
SqlParameter IndustryID = new SqlParameter();IndustryID.ParameterName = "@IndustryID";
IndustryID.Direction = ParameterDirection.Output;IndustryID.DbType = DbType.Int32;
//IndustryID.Size = 100;
cmd.Parameters.Add(IndustryID);SqlParameter AuditCompany = new SqlParameter();
AuditCompany.ParameterName = "@CompanyName";AuditCompany.Direction = ParameterDirection.Input;
AuditCompany.Value = Audit_Company;AuditCompany.DbType = DbType.String;
cmd.Parameters.Add(AuditCompany);SqlParameter CompanyID = new SqlParameter();
CompanyID.ParameterName = "@CompanyID";CompanyID.Direction = ParameterDirection.Output;
CompanyID.DbType = DbType.Int32;
//IndustryID.Size = 100;
cmd.Parameters.Add(CompanyID);
 SqlParameter AuditPlant = new SqlParameter();
AuditPlant.ParameterName = "@PlantName";AuditPlant.Direction = ParameterDirection.Input;
AuditPlant.Value = Audit_Plant;AuditPlant.DbType = DbType.String;
cmd.Parameters.Add(AuditPlant);SqlParameter PlantID = new SqlParameter();
PlantID.ParameterName = "@PlantID";PlantID.Direction = ParameterDirection.Output;
PlantID.DbType = DbType.Int32;
//IndustryID.Size = 100;
cmd.Parameters.Add(PlantID);SqlParameter AuditGroup = new SqlParameter();
AuditGroup.ParameterName = "@GroupName";AuditGroup.Direction = ParameterDirection.Input;
AuditGroup.Value = Audit_Group;AuditGroup.DbType = DbType.String;
cmd.Parameters.Add(AuditGroup);SqlParameter GroupID = new SqlParameter();
GroupID.ParameterName = "@GroupID";GroupID.Direction = ParameterDirection.Output;
GroupID.DbType = DbType.Int32;
//IndustryID.Size = 100;
cmd.Parameters.Add(GroupID);SqlParameter AuditStartedOn = new SqlParameter();
AuditStartedOn.ParameterName = "@AuditStartedOn";AuditStartedOn.Direction = ParameterDirection.Input;
AuditStartedOn.Value = Audit_Started_On;AuditStartedOn.DbType = DbType.String;
cmd.Parameters.Add(AuditStartedOn);SqlParameter AuditScheduledto = new SqlParameter();
AuditScheduledto.ParameterName = "@AuditScheduledto";AuditScheduledto.Direction = ParameterDirection.Input;
AuditScheduledto.Value = Audit_Scheduledto;AuditScheduledto.DbType = DbType.String;
cmd.Parameters.Add(AuditScheduledto);SqlParameter CreatedOn = new SqlParameter();
CreatedOn.ParameterName = "@CreatedOn";CreatedOn.Direction = ParameterDirection.Input;
CreatedOn.Value = Audit_Created_On;CreatedOn.DbType = DbType.String;
cmd.Parameters.Add(CreatedOn);SqlParameter CreatedBy = new SqlParameter();
CreatedBy.ParameterName = "@CreatedBy";CreatedBy.Direction = ParameterDirection.Input;
CreatedBy.Value = Audit_Created_By;CreatedBy.DbType = DbType.Int32;
cmd.Parameters.Add(CreatedBy);
cmd.ExecuteNonQuery();
con.Close();
}
}
}
Then i called these function into .aspx.cs file:
 
using xyz;protected void btn_CreateAudit_Click(object sender, EventArgs e)
{SqlConnection con = new SqlConnection(ConfigurationSettings.AppSettings["constr"]);
PCRA.clsCreateAudit obj = new PCRA.clsCreateAudit();
SqlCommand cmd = new SqlCommand();
//Iam getting the Session(UID) from my login page.obj.CreateAudit(txt_AuditName.Text, Convert.ToInt32(ddl_Industry.SelectedItem.Value), Convert.ToInt32(ddl_Company.SelectedItem.Value), Convert.ToInt32(ddl_Plant.SelectedItem.Value), Convert.ToInt32(ddl_Group.SelectedItem.Value), Convert.ToDateTime(txt_StartingOn.Text.ToString()), Convert.ToDateTime(txt_AuditPeriod.Text.ToString()), System.DateTime.Now, Session["UID"].ToString());lbl_Mesg.Text = "Your Audit Details are added succesfully";
}
 
But iam getting an error here near obj.CreateAudit as:
Input string was not in a correct format.
I even want to know if my storedprocedure reaches the requirement which i specified.
please help me with this.Its very urgent.
 

View 1 Replies View Related

INSERTING DATA INTO SQL DATABASE

Apr 9, 2008

I have table in my SQL db

I am inserting value using insert statement

Following are statement which I am using when inserting data into database

INSERT INTO EMPLOYEE (NAME, TELEPHONE, PINNUM,CELLNUM)
SELECT NAME,TELEPHONE,PINNUM FROM EMPLOYEE WHERE EMPLOYEEID=1

Noticed that I dont have CELLNUM In my select statment, but I want to insert that number from textbox which I have on my webform.
can some one tell me how do i do this query so i can insert data into database.

HELP ME
thank u
maxs

View 6 Replies View Related

Having Difficulty Inserting Into The Database Table

Feb 7, 2005

I created a web form where the user fills in some data and when he submits the form, I do an insert into he database table. The problem is, how can I get the data from the form into the insert statement?. here is the code:
Dim Message As String
Dim connStr As String
Dim myConnection As SqlConnection
Dim mySqlCommand As SqlCommand
connStr = "server=SIMIVSdotNET;Trusted_Connection=yes;database=AeroSea"
myConnection = New SqlConnection(connStr)
mySqlCommand = New SqlCommand("INSERT INTO TravelRequestEntry (CustomerID,Name) Values (1,name.text)", myConnection)

If I execute the above code, then nothing gets updated. When I change the insert staement into the following,
mySqlCommand = New SqlCommand("INSERT INTO TravelRequestEntry (CustomerID,Name) Values (1,'myname')", myConnection) then,
value 1 for customerID field and myname in the namefield is added.
I know I am doing something stupid, but can't figure it out.
I am confused. please help me.

View 2 Replies View Related

Inserting Data From A Constructed Table

Mar 10, 2007

I can do this in an old (~2003) way, but I'm trying to figure out a new (2005) way.  What I've got is an e-commerce project in which users select various products from a catalog and add them to a shopping cart.  Then they go to a checkout page which displays the current contents of the shopping cart, which are contained in a manually-constructed data table (system.data.datatable). 
On the checkout page a GridView displays the contents of the data table.  At that point they can check out via button click, which launches the following (somewhat simplified) ADO.NET code:1 Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs)
2 'Some variables
3 Dim intCounter As Integer 'Used to count the loop
4 Dim prmQuantity As New System.Data.SqlClient.SqlParameter() 'A parameter
5 Dim prmProduct As New System.Data.SqlClient.SqlParameter() 'A parameter
6 Dim prmPrice As New System.Data.SqlClient.SqlParameter() 'A parameter
7 Dim InsertCommand As New System.Data.SqlClient.SqlCommand 'The SQL insert command
8 Dim dbConnection As New System.Data.SqlClient.SqlConnection 'The connection to the DB
9
10 'Set the parameters for the SQL statement
11 prmQuantity.ParameterName = "@Quantity"
12 prmQuantity.SqlDbType = Data.SqlDbType.Int
13 prmQuantity.Size = 18
14 prmQuantity.Direction = Data.ParameterDirection.Input
15
16 prmProduct.ParameterName = "@Product"
17 prmProduct.SqlDbType = Data.SqlDbType.VarChar
18 prmProduct.Size = 50
19 prmProduct.Direction = Data.ParameterDirection.Input
20
21 prmPrice.ParameterName = "@Price"
22 prmPrice.SqlDbType = Data.SqlDbType.Int
23 prmPrice.Size = 18
24 prmPrice.Direction = Data.ParameterDirection.Input
25
26 'Create the connection to the database using web.config
27 dbConnection.ConnectionString = ConfigurationManager.ConnectionStrings("MyDB").ConnectionString
28
29 'Various command settings
30 InsertCommand.CommandText = "INSERT INTO [Orders] ([Quantity], [Product], [OrderDate], [ItemPrice]) VALUES (@Quantity, @Product, {fn NOW()}, @Price)"
31 InsertCommand.CommandType = Data.CommandType.Text
32 InsertCommand.Connection = dbConnection
33
34 'Add the rows to the database
35 For intCounter = 0 To objDT.Rows.Count - 1
36
37 'Re-inserts the data rows from objDT
38 objDR = objDT.Rows(intCounter)
39
40 'Set param values
41 prmQuantity.Value = objDR("Quantity")
42 prmProduct.Value = objDR("Product")
43 prmPrice.Value = objDR("Price")
44
45 'Add params to insert command
46 InsertCommand.Parameters.Add(prmQuantity)
47 InsertCommand.Parameters.Add(prmProduct)
48 InsertCommand.Parameters.Add(prmPrice)
49
50 'Open connection
51 InsertCommand.Connection.Open()
52
53 'Execute the insert command
54 InsertCommand.ExecuteNonQuery()
55
56 'Close connection and clear parameters for the next loop
57 InsertCommand.Connection.Close()
58 InsertCommand.Parameters.Clear()
59
60 Next
61
62 Response.Redirect("done.aspx")
63
64 End Sub
65
What I'd like to do is see if I can instead use a simplified approach based on 2.0 controls. Specifically, I was hoping that I could use an SqlDataSource and simply tap into its built-in Insert capabilities. So I tried this alternate procedure:Protected Sub Button2_Click(ByVal sender As Object, ByVal e As System.EventArgs)Dim intCounter As Integer 'Used to count the loopFor intCounter = 0 To objDT.Rows.Count - 1DSOrdersNew.InsertParameters("Product") = objDR("Product")DSOrdersNew.InsertParameters("Quantity") = objDR("Quantity")DSOrdersNew.Insert()NextEnd SubWhen I run this I get an error message saying: "Unable to cast object of type 'System.String' to type 'System.Web.UI.WebControls.Parameter'."Am I just way out in left field here? I guess I don't mind doing it the old-fashioned way, but it seems like there ought to be a way to do this. Any suggestions would be appreciated. Thanks! 

View 2 Replies View Related

Inserting Data To Table From Textbox

Jun 17, 2008

Hello all....
I am trying to submit data from a form(textbox) to a sql table. but I am getting an error message "NullReferenceException was unhandled by user code" Can any help me with this? This is my code inProtected Sub btnSubmit_ServerClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSubmit.Click
Dim cnstr As String = ConfigurationManager.ConnectionStrings("ConnectionString").ToString()Dim pa1 As Data.SqlClient.SqlParameter = New Data.SqlClient.SqlParameter("Keyword", Data.SqlDbType.VarChar, 50, Data.ParameterDirection.Input)
pa1.Value = Keyword.Text
SqlHelper.ExecuteNonQuery(cnstr, Data.CommandType.StoredProcedure, "spNewRec", pa1)
 
Thanks in advance...

View 4 Replies View Related

Inserting Varchar Data To Table...

Jan 3, 2001

It appears that when I insert data into a varchar(8000) field, SQL Server truncates everything after the 256th byte. When I change the field to text, this problem is eliminated. Can someone give me an explanation of why? And can I actually to the insert with the field being a varchar(8000) instead of a text data type. This will do wonders for the size and indexing.

View 1 Replies View Related

Table Order When Inserting Data

Jul 23, 2005

I have to import data into a empty database, that has many tables.some tables have to be inserted first than others due to the foreignkeys.How do I find out the order of the tables that I have to insert datainto?Thanks in advance!Sam

View 6 Replies View Related

Error While Inserting Data In DataBase ?

Oct 15, 2006

my requirment is insert TableName and JourneyDate and FlightNumber alongwith otherdata at RunTime but i get error, I tried it several times. Table Structure is:  Create Table HA142
(
JourneyDate DateTime primary key,
FlightNo char(5)not null FOREIGN kEY REFERENCES FLIGHTS(FlightNo),
FirstClassSeatAvalable int,
BusinessClassSeatAvalable int,
EconomyClassSeatAvalable int,
FsWaitingAvalable int,
BsWaitingAvalable int,
EcWaitingAvalable int
)  string flightno = drpFlightNo.SelectedItem.Text;
string JourneyDate = Session["JourneyDate"].ToString();
string newStrign = ",18,42,280,3,7,35)";
SqlConnection myConn = new SqlConnection("workstation id=JASIM;packet size=4096;user id=ASPNET;data source=JASIM;persist security info=False;initial catalog=Test");
SqlCommand populateFlightTable = new SqlCommand("INSERT INTO "+flightno+" VALUES("+JourneyDate+","+flightno+newStrign,myConn);
myConn.Open();
populateFlightTable.ExecuteNonQuery();
myConn.Close(); whenever compiler reached to populateFlightTable.ExecuteNonQuery(); I received error. i tried it to rectify several times but no result.plz hemp me...

View 3 Replies View Related

Problems On Inserting Data Into Database

Sep 11, 2007

Hi all, I want to insert some data that from a table into a database, and I got the error message-- "The variable name '@IssueID' has already been declared. Variable names must be unique within a query batch or stored procedure."  Is it anything wrong with my code? Thanks a lot.

            Dim row As Data.DataRow
            For Each row In table.Rows
                DataSource.InsertParameters.Add("IssueID", row(0))                DataSource.InsertParameters.Add("UserName", Session("loginName"))                DataSource.InsertParameters.Add("IssueCost", row(1))                DataSource.InsertParameters.Add("IssueDesc", row(2)) 
                DataSource.Insert()
            Next row 

View 4 Replies View Related

Inserting Test Data In To The Database

Jan 3, 2001

How can i insert test Data in to the Database,I want to insert one million records in to the table,This is to test Database Performance.
Can anyone help me in this regard,Do we have any scripts for this purpose???
thanks
Mar

View 4 Replies View Related

Inserting Data Into A Database Alphabetically

Jul 20, 2005

Hello, is it possible to insert new data into a datbasealphabetically? For example when a user enters a new row of data, Iwant the row inserted in the correct order. I do not think this ispossible.Thank you for the help!

View 1 Replies View Related

Inserting Ascii Data Into SQL Database

Aug 22, 2006



Hi everyone,



I need to save the ascii data in my sql express 2005 database in one table and in 2 coloums in this table using VB express...

Can I do it by datareader or with bulk insert t-sql command?

I tried it this way but it gives error like "connection property is not initialised" it is on executenonquery row in the code...

Dim cmd = New SqlCommand("BULK INSERT RFID.dbo.stock(material_number,total) FROM 'C:can1.txt' " & _

"WITH FIELDTERMINATOR = ',', ROWTERMINATOR = '' ")

connection.Open()

cmd.executenonquery()

connection.Close()



I hope some can help with this problem....

View 6 Replies View Related

Problem In Inserting An Integer Into A Database Table

Mar 4, 2007

i am using visual web developer 2005 and SQL Express 2005 with VB as the code behindi want to insert an integer into my database table and this is my code        i = i + 1        productionstatus.UpdateCommand = "UPDATE productionprogressbar SET completedprocess = i                                                                                                                          WHERE order_id = 10"        productionstatus.Update() "i" is declared at the top of the page like this                Partial Class production_processlist                        Inherits System.Web.UI.Page                        Dim i As Integer = 0 when i run the program i get the error   input string is not in the correct formatwhat is wrong in my code ?please help me

View 1 Replies View Related

Can Anybody Tell Me Why The Following Stored Procedure Is Not Inserting Into My Database Table?....

Sep 7, 2007

ALTER PROCEDURE AddListAndReturnNewIDValue (
@EditorId int,@CategoryID int,
@ListTitle nvarchar(50),@Blurb nvarchar(250),
@FileName nvarchar(50),@ByLine nvarchar(50),
@HTMLCopy nvarchar(MAX),@MainStory bit,
@MainStoryImageFile nvarchar(50),@Publish bit,
@PublishDate smalldatetime,
@ListId int OUTPUT
)
AS
-- Insert the record into the database
INSERT INTO shortlist (EditorId,CategoryID,ListTitle,Blurb,FileName,ByLine,HTMLCopy,MainStory,MainStoryImageFile,Publish,PublishDate)
VALUES (@EditorID,@CategoryID,@ListTitle,@Blurb, @FileName, @ByLine, @HTMLCopy, @MainStory, @MainStoryImageFile,@Publish,@PublishDate)
-- Read the just-inserted ProductID into @NewProductID
SET @ListId = SCOPE_IDENTITY()
 
here is the sqlDataSource
<asp:SqlDataSource
id="srcShortList"
ConnectionString="<%$ ConnectionStrings:ShortList %>"
SelectCommand="SELECT Id,EditorId,CategoryID,ListTitle,Blurb,FileName, ByLine, HTMLCopy, MainStory, MainStoryImageFile, Publish,PublishDate,Date,Deleted FROM shortlist"
InsertCommand="AddProductAndReturnNewProductIDValue"SelectCommandType="StoredProcedure"
UpdateCommand="UPDATE shortlist SET CategoryID=@CategoryID,ListTitle=@ListTitle,Blurb=@Blurb,ByLine=@ByLine,HTMLCopy=@HTMLCopy,MainStory=@MainStory,Publish=@Publish,PublishDate=@PublishDate WHERE Id=@Id"
Runat="server" >
<SelectParameters>
<asp:QueryStringParameter
Name="Id"
QueryStringField="Id" />
</SelectParameters>
 
</asp:SqlDataSource>

View 2 Replies View Related

Inserting Data In Batch Mode In A SQL Table Using .NET

Jun 22, 2004

Hi,

I have an ASP.NET Web Service that accepts a DataSet object passed to it. This DataSet will contain a large number of records in it's table. What I want to do (if possible) is insert all records in a SQL table in a batch mode (one go). Is this doable?

Thanks,

View 1 Replies View Related

Inserting Data Into Table - Column Does Not Allow Nulls

Sep 26, 2013

I'm inserting data from a c# webservice into a table via a stored procedure, but I get a Column does not allow nulls on the @alert_id column/field. It is set as int and allow nulls is not ticked.

Here's the sql:

USE [aren]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [aren1002].[ArenAlertInsert]

[Code] ....

View 7 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved