Insert To Recordset Gives Different Date Format To Table Insert ????????

Jun 28, 2007

Help please!



I have an asp page with some simple vbscript to add a record to a table, the record has a datefield (dob).

the insert results in a US formated date if I add a record to a dynamic recordset but a UK formated date if I insert direct to the table ?????

i.e.

if request("dob") is "01/11/2007" (1st november 2007)





set conn = server.createobject("adodb.connection")

set rs = server.createobject("adodb.recordset")

rs.open "tez", mc, 2, 2 rs.addnew

rs("dob") = request("dob")

rs.update



11 jan 2007 stored in table



while



set trs = Server.CreateObject("ADODB.RecordSet")

qfn= "insert tez values('"+request("dob")+"')"

trs.Open qfn,mc



results in

1 november 2007 is written to the table.

Both of these methods are used in the same asp page.



This is on a windows2003 server, sql2005,iisv6, asp.netv2



I have tried every setting I can find in iis,asp,sql server to no avail.

I need the recordset method to work correctly.



Terry



View 8 Replies


ADVERTISEMENT

How To Insert/format A Date In My DB Table?

Apr 4, 2007

Hi. I am sitting here as a newbie programming my first web application.I have in my tables a column ‘Birthday’ declared as a  smalldatetime (I only want to store year, month and day).Where Year, Month ans Days are dropdownlist. 
Inserting the data I use this code:
Dim Birthday As New DateTime(Int32.Parse(Year.SelectedValue), Int32.Parse(Month.SelectedValue), Int32.Parse(Days.SelectedValue))-and then I use Birthday in my stored procedures.
 Whan I look into my tabel is ses the value is stored like this: 12.01.1996 00:00:00
This is also the result if I change the column declaration from smalldatetime to DateTime.Is 12.01.1996 00:00:00 (mm.dd.yyyy) the correct value in my DB. I whould have expecetd dd.mm.yyyy or yyyy.mm.dd ?
 
Please avise.

View 4 Replies View Related

How Can You Insert A Dummy Row At The Top Of Every Related Recordset In A Table?

Jan 22, 2008

I have the following:

TicketID_1 AuditRec1
TicketID_1 AuditRec2
TicketID_1 AuditRec3
TicketID_1 AuditRec4
TicketID_1 AuditRec5
TicketID_2 AuditRec1
TicketID_2 AuditRec2
TicketID_2 AuditRec3
TicketID_2 AuditRec4
TicketID_2 AuditRec5

I need to insert a dummy row as the first row in this AuditRecord table for every occurrance of a given TicketID so that I get the following:

Dummy_Tick1 Dummy_AuditRec
TicketID_1 AuditRec1
TicketID_1 AuditRec2
TicketID_1 AuditRec3
TicketID_1 AuditRec4
TicketID_1 AuditRec5
Dummy_Tick2 Dummy_AuditRec
TicketID_2 AuditRec1
TicketID_2 AuditRec2
TicketID_2 AuditRec3
TicketID_2 AuditRec4
TicketID_2 AuditRec5

The AuditRec table is huge. How can I accomplish this using SQL?

View 1 Replies View Related

Insert Date As Dd/mm/yy Format

Dec 7, 2004

Hi all,

I have an application that receive date input from user in the dd/mm/yyyy format. When I tried to insert the record into the SQL Server with an INSERT statement, I received an error message indicating the date index is out of range. I guess, the SQL Server is expecting the date format to be mm/dd/yyyy. Is there any way that I can input the date into SQL Server in dd/mm/yyyy format.

Thank You
hawwa

View 6 Replies View Related

How To Insert Date Format Mm/dd/yyyy In MySQL Database

Mar 25, 2008

Hello every one,                  I have a problem while inserting the date format like  mm/dd/yyyy in mySQL. It is showing the date format error.and my requirement is to enter like this format from front-end(asp.net,C#) and i am using mySQL as database.                  any help would be greatly appriaciated. 

View 4 Replies View Related

How To Insert Data Into Sql Table In Desired Format

Jan 25, 2008

 Hello,I have a problem the scenario is :I have data in an excel file and now I am reading data from that file and insert that data into sql database. this is well.but the problem is that I have few fields with date time data in excel sheet. In my database I have varchar type data type for these data columns.I want to read these data columns from the excel sheet and insert only time into the data base.how can I do this I am using the following line of code for selelcting only time from the excel file. string qry = "Select CONVERT(CHAR(5),datetime,114) from [" + objStr[0] + "];";this gives me error message.help me to read the data from excel file and insert it  into the sql table in desired format. Thanks in advance, junior 

View 1 Replies View Related

BULK INSERT From A Saved Recordset?

Jan 22, 2004

Is there any way to copy data from a previous saved recordset using "BULK INSERT" or bcp ? (the recordset is supposed to be saved using adPersistADTG or adPersistXML)

View 2 Replies View Related

Insert Now's Date + Time Into A Table

Sep 10, 2006

HiLets say I have a user registration table and I want to know since when the member joined the club.How do I make the insert clause to include the date or date+time ?TIAGuy  

View 24 Replies View Related

Help-insert One Table To Another From Tow Date Fields- Single Row For Each Day

Apr 20, 2008

need help on update from one table to another like this
this is my first table

tb_all_holiday





id

fname

Start_Date

End_Date

val_holiday

111
aaaa

15/03/2008
21/03/2008

1

222
bbbb

02/05/2008
09/05/2008

3

333
cccc

03/04/2008
15/05/2008

4

333
cccc

29/04/2008
07/07/2008

1

444
dddd

01/05/2008
02/05/2008

1

444
dddd

09/05/2008
19/08/2008

1

555
EEE

09/07/2008
09/08/2008

4

666
fff
10/09/2008
12/09/2008

1
this is my second table to insert into !

i need to insert to another table like this
single row for each day from start_date TO END_DATE
check each employee add row for each day
insert all employee one after one


ID fname new_date val_holiday
----------------------------------------------------

111 aaaa 15/03/2008 1
111 aaaa 16/03/2008 1
111 aaaa 18/03/2008 1
111 aaaa 19/03/2008 1
111 aaaa 20/03/2008 1
111 aaaa 21/03/2008 1

222 bbb 02/05/2008 3
222 bbb 03/05/2008 3
222 bbb 04/05/2008 3
222 bbb 05/05/2008 3
222 bbb 06/05/2008 3
222 bbb 07/05/2008 3
222 bbb 08/05/2008 3
222 bbb 09/05/2008 3

333 ccc 03/04/2008 4
333 ccc 04/04/2008 4

......................................................add row for each day
...............................
333 ccc 15/05/2008 4


TNX for help

View 6 Replies View Related

How Can I Insert, Retrieve Date From ASPX Page In Table ??

Mar 2, 2006

hello all
pls tell me
how can i insert, retrieve  date from ASPX(vs2003)  page in table in sql server 2000??
i m in trouble
pls help me
 
 
 

View 1 Replies View Related

Strange Problem: SQL Insert Statement Does Not Insert All The Fields Into Table From Asp.net C# Webpage

Apr 21, 2008

An insert statement was not inserting all the data into a table. Found it very strange as the other fields in the row were inserted. I ran SQL profiler and found that sql statement had all the fields in the insert statement but some of the fields were not inserted. Below is the sql statement which is created dyanmically by a asp.net C# class. The columns which are not inserted are 'totaltax' and 'totalamount' ...while the 'shipto_name' etc...were inserted.there were not errors thrown. The sql from the code cannot be shown here as it is dynamically built referencing C# class files.It works fine on another test database which uses the same dlls. The only difference i found was the difference in date formats..@totalamount=1625.62,@totaltax=125.62are not inserted into the database.Below is the statement copied from SQL profiler.exec sp_executesql N'INSERT INTO salesorder(billto_city, billto_country, billto_line1, billto_line2, billto_name,billto_postalcode, billto_stateorprovince, billto_telephone, contactid, CreatedOn, customerid, customeridtype,DeletionStateCode, discountamount, discountpercentage, ModifiedOn, name, ordernumber,pricelevelid, salesorderId, shipto_city, shipto_country,shipto_line1, shipto_line2, shipto_name, shipto_postalcode, shipto_stateorprovince,shipto_telephone, StateCode, submitdate, totalamount,totallineitemamount, totaltax ) VALUES(@billto_city, @billto_country, @billto_line1, @billto_line2,@billto_name, @billto_postalcode, @billto_stateorprovince, @billto_telephone, @contactid, @CreatedOn, @customerid,@customeridtype, @DeletionStateCode, @discountamount,@discountpercentage, @ModifiedOn, @name, @ordernumber, @pricelevelid, @salesorderId,@shipto_city, @shipto_country, @shipto_line1, @shipto_line2,@shipto_name, @shipto_postalcode, @shipto_stateorprovince, @shipto_telephone,@StateCode, @submitdate, @totalamount, @totallineitemamount, @totaltax)',N'@billto_city nvarchar(8),@billto_country nvarchar(13),@billto_line1 nvarchar(3),@billto_line2 nvarchar(4),@billto_name nvarchar(15),@billto_postalcode nvarchar(5),@billto_stateorprovince nvarchar(8),@billto_telephone nvarchar(3),@contactid uniqueidentifier,@CreatedOn datetime,@customerid uniqueidentifier,@customeridtype int,@DeletionStateCode int,@discountamount decimal(1,0),@discountpercentage decimal(1,0),@ModifiedOn datetime,@name nvarchar(33),@ordernumber nvarchar(18),@pricelevelid uniqueidentifier,@salesorderId uniqueidentifier,@shipto_city nvarchar(8),@shipto_country nvarchar(13),@shipto_line1 nvarchar(3),@shipto_line2 nvarchar(4),@shipto_name nvarchar(15),@shipto_postalcode nvarchar(5),@shipto_stateorprovince nvarchar(8),@shipto_telephone nvarchar(3),@StateCode int,@submitdate datetime,@totalamount decimal(6,2),@totallineitemamount decimal(6,2),@totaltax decimal(5,2)',@billto_city=N'New York',@billto_country=N'United States',@billto_line1=N'454',@billto_line2=N'Road',@billto_name=N'Hillary Clinton',@billto_postalcode=N'10001',@billto_stateorprovince=N'New York',@billto_telephone=N'124',@contactid='8DAFE298-3A25-42EE-B208-0B79DE653B61',@CreatedOn=''2008-04-18 13:37:12:013'',@customerid='8DAFE298-3A25-42EE-B208-0B79DE653B61',@customeridtype=2,@DeletionStateCode=0,@discountamount=0,@discountpercentage=0,@ModifiedOn=''2008-04-18 13:37:12:013'',@name=N'E-Commerce Order (Before billing)',@ordernumber=N'BRKV-CC-OKRW5764YS',@pricelevelid='B74DB28B-AA8F-DC11-B289-000423B63B71',@salesorderId='9CD0E11A-5A6D-4584-BC3E-4292EBA6ED24',@shipto_city=N'New York',@shipto_country=N'United States',@shipto_line1=N'454',@shipto_line2=N'Road',@shipto_name=N'Hillary Clinton',@shipto_postalcode=N'10001',@shipto_stateorprovince=N'New York',@shipto_telephone=N'124',@StateCode=0,@submitdate=''2008-04-18 14:37:10:140'',@totalamount=1625.62,@totallineitemamount=1500.00,@totaltax=125.62
 
thanks

View 7 Replies View Related

How Can I Insert Date In SQL Server 2000 Database (table )from ASP.NET 1.1. Program??

Feb 1, 2006

hi ALL !!!
How can I insert Date in SQL Server 2000 database(table ) from ASP.NET 1.1. Program??
pls send me code if u can
pls help me ..

View 2 Replies View Related

OPENROWSET (INSERT) Insert Error: Column Name Or Number Of Supplied Values Does Not Match Table Definition.

Mar 24, 2008

Is there a way to avoid entering column names in the excel template for me to create an excel file froma  dynamic excel using openrowset.
I have teh following code but it works fien when column names are given ahead of time.
If I remove the column names from the template and just to Select * from the table and Select * from sheet1 then it tells me that column names donot match.
 Server: Msg 213, Level 16, State 5, Line 1Insert Error: Column name or number of supplied values does not match table definition.
here is my code...
SET @sql1='select * from table1'SET @sql2='select * from table2'  
IF @File_Name = ''      Select @fn = 'C:Test1.xls'     ELSE      Select @fn = 'C:' + @File_Name + '.xls'        -- FileCopy command string formation     SELECT @Cmd = 'Copy C:TestTemplate1.xls ' + @fn     
-- FielCopy command execution through Shell Command     EXEC MASTER..XP_CMDSHELL @cmd, NO_OUTPUT        -- Mentioning the OLEDB Rpovider and excel destination filename     set @provider = 'Microsoft.Jet.OLEDB.4.0'     set @ExcelString = 'Excel 8.0;HDR=yes;Database=' + @fn   
exec('insert into OPENrowset(''' + @provider + ''',''' + @ExcelString + ''',''SELECT *     FROM [Sheet1$]'')      '+ @sql1 + '')         exec('insert into OPENrowset(''' + @provider + ''',''' + @ExcelString + ''',''SELECT *     FROM [Sheet2$]'')      '+ @sql2 + ' ')   
 
 

View 4 Replies View Related

Insert Command Fails When I Want To Insert Records In Data Table

Apr 20, 2008

On my site users can register using ASP Membership Create user Wizard control.
I am also using the wizard control to design a simple question and answer  form that logged in users have access to.
it has 2 questions including a text box for Q1 and  dropdown list for Q2.
I have a table in my database called "Players" which has 3 Columns
UserId Primary Key of type Unique Identifyer
PlayerName Type String
PlayerGenre Type Sting
 
On completing the wizard and clicking the finish button, I want the data to be inserted into the SQl express Players table.
I am having problems getting this to work and keep getting exceptions.
 Be very helpful if somebody could check the code and advise where the problem is??
 
 
<asp:Wizard ID="Wizard1" runat="server" BackColor="#F7F6F3"
BorderColor="#CCCCCC" BorderStyle="Solid" BorderWidth="1px"
DisplaySideBar="False" Font-Names="Verdana" Font-Size="0.8em" Height="354px"
onfinishbuttonclick="Wizard1_FinishButtonClick" Width="631px">
<SideBarTemplate>
<asp:DataList ID="SideBarList" runat="server">
<ItemTemplate>
<asp:LinkButton ID="SideBarButton" runat="server" BorderWidth="0px"
Font-Names="Verdana" ForeColor="White"></asp:LinkButton>
</ItemTemplate>
<SelectedItemStyle Font-Bold="True" />
</asp:DataList>
</SideBarTemplate>
<StepStyle BackColor="#669999" BorderWidth="0px" ForeColor="#5D7B9D" />
<NavigationStyle VerticalAlign="Top" />
<WizardSteps>
<asp:WizardStep runat="server">
<table class="style1">
<tr>
<td class="style4">
A<span class="style6">Player Name</span></td>
<td class="style3">
<asp:TextBox ID="PlayerName" runat="server"></asp:TextBox>
</td>
<td>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server"
ControlToValidate="PlayerName" ErrorMessage="RequiredFieldValidator"></asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td class="style5">
 
<td class="style3">
<asp:DropDownList ID="PlayerGenre" runat="server" Width="128px">
<asp:ListItem Value="-1">Select Genre</asp:ListItem>
<asp:ListItem>Male</asp:ListItem>
<asp:ListItem>Female</asp:ListItem>
</asp:DropDownList>
</td>
<asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server"
ControlToValidate="PlayerGenre" ErrorMessage="RequiredFieldValidator"></asp:RequiredFieldValidator>
</td>
 
</tr>
</table>
  Sql Data Source
<asp:SqlDataSource ID="InsertArtist1" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>" InsertCommand="INSERT INTO [Playerst] ([UserId], [PlayerName], [PlayerGenre]) VALUES (@UserId, @PlayerName, @PlayerGenre)"
 
ProviderName="<%$ ConnectionStrings:ConnectionString.ProviderName %>">
<InsertParameters>
<asp:Parameter Name="UserId" Type="Object" />
<asp:Parameter Name="PlayerName" Type="String" />
<asp:Parameter Name="PlayerGenre" Type="String" />
</InsertParameters>
 
 
</asp:SqlDataSource>
</asp:WizardStep>
 
 Event Handler
 
To match the answers to the user I get the UserId and insert this into the database to.protected void Wizard1_FinishButtonClick(object sender, WizardNavigationEventArgs e)
{
 SqlDataSource DataSource = (SqlDataSource)Wizard1.FindControl("InsertArtist1");
MembershipUser myUser = Membership.GetUser(this.User.Identity.Name);
Guid UserId = (Guid)myUser.ProviderUserKey;String Gender = ((DropDownList)Wizard1.FindControl("PlayerGenre")).SelectedValue;
DataSource.InsertParameters.Add("UserId", UserId.ToString());DataSource.InsertParameters.Add("PlayerGenre", Gender.ToString());
DataSource.Insert();
 
}
 

View 1 Replies View Related

How To Insert Data From A File Into Table Having Two Columns-BULK INSERT

Oct 12, 2007



Hi,
i have a file which consists data as below,

3
123||
456||
789||

Iam reading file using bulk insert and iam inserting these phone numbers into table having one column as below.


BULK INSERT TABLE_NAME FROM 'FILE_PATH'
WITH (KEEPNULLS,FIRSTROW=2,ROWTERMINATOR = '||')

but i want to insert the data into table having two columns. if iam trying to insert the data into table having two columns its not inserting.

can anyone help me how to do this?

Thanks,
-Badri

View 5 Replies View Related

Enter Todays Date - Edit Record In A Table Instead Of Using Insert Statement

Apr 9, 2015

Sometimes I want to quickly to edit a record in a table instead of using an insert statement.

Sometimes there are auditing columns like DateCreated, and CreatedBy,

I know it can be made as default. for DateCreated to be sysdatetime, and createdby to be system user.

But I just curious to know if there is a way to manually enter today's date and the user in the cell?

View 9 Replies View Related

Wants To Insert Into Multiple Table By A Single Insert Query

Apr 11, 2008

Hi,ALL
I wants to insert data into multiple table within a single insert query
Thanks

View 3 Replies View Related

Multiple Insert Call For A Table Having Insert Trigger

Mar 1, 2004

Hi

I am trying to use multiple insert for a table T1 to add multiple rows.

Ti has trigger for insert to add or update multiple rows in Table T2.

When I provide multiple insert SQL then only first insert works while rest insert statements does not work

Anybody have any idea about why only one insert works for T1

Thanks

View 10 Replies View Related

T-SQL (SS2K8) :: Stored Procedure To Truncate And Insert Values In Table 1 And Update And Insert Values In Table 2

Apr 30, 2015

table2 is intially populated (basically this will serve as historical table for view); temptable and table2 will are similar except that table2 has two extra columns which are insertdt and updatedt

process:
1. get data from an existing view and insert in temptable
2. truncate/delete contents of table1
3. insert data in table1 by comparing temptable vs table2 (values that exists in temptable but not in table2 will be inserted)
4. insert data in table2 which are not yet present (comparing ID in t2 and temptable)
5. UPDATE table2 whose field/column VALUE is not equal with temptable. (meaning UNMATCHED VALUE)

* for #5 if a value from table2 (historical table) has changed compared to temptable (new result of view) this must be updated as well as the updateddt field value.

View 2 Replies View Related

SQL Server 2012 :: Format Value Of A Column And Insert It Into Another Column Of The Same Table?

Sep 18, 2014

A column of a table has values in the format - 35106;#Grandbouche-Cropp, Amy.

I need to format the column data in such a way that only the text after # (Grandbouche-Cropp, Amy) remain in the column.

The text before ;# (35106) should be inserted in to another column of the same table.

Below is the table structure:

create table [HR_DEV_DM].[CFQ_TEST].sp_CFQ_Commercial_Referrals
(
ID int identity,
PromotionalCode nvarchar(4000),
QuoteNumber nvarchar(100),
CreatedBy nvarchar(100),
Created datetime,
ModifiedBy nvarchar(100),
Modified datetime,
CreatedBy_SalesRepSharePointID int,
ModifiedBy_ModBySharePointID int
)

View 2 Replies View Related

SQL Server 2008 :: Insert Data Into Table Variable But Need To Insert 1 Or 2 Rows Depending On Data

Feb 26, 2015

I am writing a query to return some production data. Basically i need to insert either 1 or 2 rows into a Table variable based on a decision as to does the production part make 1 or 2 items ( The Raw data does not allow for this it comes from a look up in my database)

I can retrieve all the source data i need easily but when i come to insert it into the table variable i need to insert 1 record if its a single part or 2 records if its a twin part. I know could use a cursor but im sure there has to be an easier way !

Below is the code i have at the moment

declare @startdate as datetime
declare @enddate as datetime
declare @Line as Integer
DECLARE @count INT

set @startdate = '2015-01-01'
set @enddate = '2015-01-31'

[Code] .....

View 1 Replies View Related

Datetime Format (insert From Vb6)

Apr 12, 2000

I'm still having a problem inserting date fields into sql server.

I don't understand how it accepts datetime.

I have all of my date columns defined with datetime format and all of the dates are coming out as the default of: 01/01/1900.

I tried to insert the data as string and sql server doesn't understand that format.
Here's some of the code:

We're going from flat VSAM files to an sql server database.
This is one huge sql insert statement with about 75 fields being loaded into a table so I'll only post one the date fields.
Here's where I call the String functions from:

First, I have to uncomp the field from binary to String:

ls_sdate = Right$(CompToStr(bufMast.Name_Chg_Date), 8)

And then I send this string to my Convert_Date function:

lsDet1 = Trim$(lsDet1) & Convert_Date(ls_sdate) & ","

(lsDet1 is a concatenated String of the SQL Values to be inserted)

And Here are the two functions:
The date field is coming in like: 1991112 where if the first character is a 1, the year is 1900 and if the first character is a 0, the year is 2000.
I get correct fields in my message box like 1996/12/31 but then I don't know what sql server does to it in datetime format.
When I check the database table it looks like: 01/12/1900

Maybe there is something wrong with my Convert_Date function;

__________________________________________________ ____________

Public Function CompToStr(aCompdata() As Byte) As String
'This is one way in which you can unpack a comp field. As I mentioned,
'you might be better off designing a flexible class to do the
'conversions. At minimum, this function should be expanded to
'accept a data picture as a param (decimal placement and so on).

Dim lsRtnStr As String
Dim lsHoldStr As String
Dim llCount As Long

For llCount = 1 To (UBound(aCompdata) + 1) Step 1 'loop thru the passed array.
lsHoldStr = Hex(aCompdata(llCount - 1)) 'Convert the byte to a Hex string.
If Len(Trim$(lsHoldStr)) = 1 Then 'if the highorder nibble was 0
lsHoldStr = "0" & Trim$(lsHoldStr) 'pad it with a leading zero.
End If
lsRtnStr = lsRtnStr & lsHoldStr 'Concat it to the return string.
lsHoldStr = "" 'clear the var for the next pass.
Next
lsRtnStr = Replace$(lsRtnStr, "C", " ") 'Positive sign replacement.
lsRtnStr = Replace$(lsRtnStr, "D", "-") 'Negative sign replacement.
lsRtnStr = Replace$(lsRtnStr, "F", " ") 'Unsigned - implicit positive.
lsRtnStr = Trim$(lsRtnStr)

llCount = 0
llCount = InStr(1, lsRtnStr, "-")

If llCount > 0 Then
lsRtnStr = Right$(lsRtnStr, 1) & Left$(lsRtnStr, (Len(lsRtnStr) - 1))
End If
CompToStr = lsRtnStr 'Return the hex string.
End Function
__________________________________________________ ___________________

Public Function Convert_Date(ByRef ls_sdate As String) As String

'incoming date
Dim ls_scent
, ls_smonth, ls_sday, ls_syear As String

ls_scent = Left(ls_sdate, 1)
ls_syear = Mid(ls_sdate, 2, 2)
ls_smonth = Mid(ls_sdate, 4, 2)
ls_sday = Right(ls_sdate, 2)

If (ls_sday = "00") Then
ls_sdate = "0000"
ElseIf (ls_scent = 0) Then
'ls_sdate = ls_smonth & "/" & ls_sday & "/" & "19" & ls_syear
ls_sdate = "19" & ls_syear & "/" & ls_smonth & "/" & ls_sday
ElseIf (ls_scent = 1) Then
'ls_sdate = ls_smonth & "/" & ls_sday & "/" & "20" & ls_syear
ls_sdate = "20" & ls_syear & "/" & ls_smonth & "/" & ls_sday
End If

Convert_Date = ls_sdate

End Function
__________________________________________________ ____________

View 1 Replies View Related

Insert :) I Have Different Insert Code Lines (2 Insert Codelines) Which One Best ?

Jun 4, 2008

hello friends
my one insert code lines is below :) what does int32 mean ? AND WHAT IS DIFFERENT BETWEEN ONE CODE LINES AND SECOND CODE LINES :)Dim conn As New SqlConnection(ConfigurationManager.ConnectionStrings("ConnectionString").ConnectionString)
Dim cmd As New SqlCommand("Insert into table1 (UserId) VALUES (@UserId)", conn)
'you should use sproc instead
cmd.Parameters.AddWithValue("@UserId", textbox1.text)
'your value
Try
conn.Open()Dim rows As Int32 = cmd.ExecuteNonQuery()
conn.Close()Trace.Write(String.Format("You have {0} rows inserted successfully!", rows.ToString()))
Catch sex As SqlExceptionThrow sex
Finally
If conn.State <> Data.ConnectionState.Closed Then
conn.Close()
End If
End Try
MY SECOND INSERT CODE LINES IS BELOWDim SglDataSource2, yeni As New SqlDataSource()
SglDataSource2.ConnectionString = ConfigurationManager.ConnectionStrings("ConnectionString").ToString
SglDataSource2.InsertCommandType = SqlDataSourceCommandType.Text
SglDataSource2.InsertCommand = "INSERT INTO urunlistesi2 (kategori1) VALUES (@kategori1)"
SglDataSource2.InsertParameters.Add("kategori1", kategoril1.Text)Dim rowsaffected As Integer = 0
Try
rowsaffected = SglDataSource2.Insert()Catch ex As Exception
Server.Transfer("yardim.aspx")
Finally
SglDataSource2 = Nothing
End Try
If rowsaffected <> 1 ThenServer.Transfer("yardim.aspx")
ElseServer.Transfer("urunsat.aspx")
End If
 
 
cheers

View 2 Replies View Related

Bulk Insert Using Format File.......

Apr 8, 2001

I want to use the bulk insert statement to insert data from a text file that contains more columns than the target sql table does. I am using SQL 7.0.

I am using a format file, but I can't work out how to achieve the above. SQL books online (and the msdn website) do not describe how to do this, but it is intimated that it can be done.

Any suggestions ?

Regards,

Stuart.

View 1 Replies View Related

Format Files For Use With Bulk Insert

Aug 9, 2006

I used bcp to produce the apended format file.How can it be modified to recognize the quotes that surround the textfields and not insert the quotes along with the text? Invariably, thefirst four columns have text surrounded by quotes and are terminated bytabs. If the first column has "abc", only abc ought to be insertedinto that field in the table.ThanksTed==================format file========================<?xml version="1.0" ?>- <BCPFORMATxmlns="http://schemas.microsoft.com/sqlserver/2004/bulkload/format"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">- <RECORD><FIELD ID="1" xsi:type="CharPrefix" PREFIX_LENGTH="2" MAX_LENGTH="6"COLLATION="Latin1_General_CI_AI" /><FIELD ID="2" xsi:type="CharPrefix" PREFIX_LENGTH="2" MAX_LENGTH="7"COLLATION="Latin1_General_CI_AI" /><FIELD ID="3" xsi:type="CharPrefix" PREFIX_LENGTH="2" MAX_LENGTH="48"COLLATION="Latin1_General_CI_AI" /><FIELD ID="4" xsi:type="NativeFixed" LENGTH="4" /><FIELD ID="5" xsi:type="CharPrefix" PREFIX_LENGTH="2" MAX_LENGTH="8"COLLATION="Latin1_General_CI_AI" /><FIELD ID="6" xsi:type="NativePrefix" PREFIX_LENGTH="1" /></RECORD>- <ROW><COLUMN SOURCE="1" NAME="f_supplier_code" xsi:type="SQLVARYCHAR" /><COLUMN SOURCE="2" NAME="f_product_code" xsi:type="SQLVARYCHAR" /><COLUMN SOURCE="3" NAME="f_product_name" xsi:type="SQLVARYCHAR" /><COLUMN SOURCE="4" NAME="f_asset_classes_id" xsi:type="SQLINT" /><COLUMN SOURCE="5" NAME="f_size" xsi:type="SQLVARYCHAR" /><COLUMN SOURCE="6" NAME="f_dist_unit" xsi:type="SQLFLT8" /></ROW></BCPFORMAT>

View 6 Replies View Related

Bulk Insert From Csv Using XML Format File

Apr 4, 2008



Hello, I am doing a bulk insert using a XML Format file from a csv file. Most everything works just fine, but my delimiter is a , the problem is one of the column sets sometimes contains a , within "" like this:

value1,"value,2",value3

So when I do my insert it is distorting the column values because unlike excel it is not ignoring the comma within the quotes. Is there any way to set an attribute within the format file to prevent this from happening?

View 2 Replies View Related

BULKI INSERT And Format File

Mar 28, 2008



Hi All,

I have to import data into my database. The data comes in csv files. They really are CSV: comma separated.

Because there are now two type of import files, I have to make two format files for BULK insert command. (In previous versions of my application there was only one import file, so the BULK INSERT Worked without fomrat file.)

The trouble is that it does not work . The files come in Unicode encoding (starting with FF FE).

I always get different errors as I change anything. The most annoying one:


Bulk load data conversion error (truncation) for row 1, column 2 (b).

It's annoying, because I don't have a clue what it means.

Some other are:
Unexpected EOF, Codepage not installed (when I specify CODEPAGE='1201'), Column too long, etc...

Can anyone help me, please? This is driving me crazy.

My test table:


CREATE TABLE [dbo].[aaa](

[ a] [nvarchar](1000) NULL,

[ b] [nvarchar](1000) NULL,

[ c] [nvarchar](1000) NULL

) ON [PRIMARY]

My BULK INSERT STATEMENT:


BULK INSERT [aaa]

FROM 'c:123.csv'

WITH(FORMATFILE = 'c:123.xml',)

My format file (123.xml):



<?xml version="1.0"?>

<BCPFORMAT xmlns="http://schemas.microsoft.com/sqlserver/2004/bulkload/format" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

<RECORD>

<FIELD ID="1" xsi:type="NCharTerm" TERMINATOR=","/>

<FIELD ID="2" xsi:type="NCharTerm" TERMINATOR="," />

<FIELD ID="3" xsi:type="NCharTerm" TERMINATOR="" />

</RECORD>

<ROW>

<COLUMN SOURCE="1" NAME="a" xsi:type="SQLNVARCHAR" />

<COLUMN SOURCE="2" NAME="b" xsi:type="SQLNVARCHAR" />

<COLUMN SOURCE="3" NAME="c" xsi:type="SQLNVARCHAR"/>

</ROW>

</BCPFORMAT>

View 1 Replies View Related

BUlk Insert Using Format File

Jan 17, 2008

I Have a fixed width file where the format look like below:
f1 - 16
f2 - 64
f3 - 64..
....etc


and the format file that i created looks like:
8.0
20
1 SQLCHAR 0 16 "" 0 ExtraField
2 SQLCHAR 0 64 "" 0 ExtraField
3 SQLCHAR 0 64 "" 0 ExtraField
4 SQLCHAR 0 16 "" 1 DatabaseName
5 SQLCHAR 0 128 "" 0 ExtraField
6 SQLCHAR 0 24 "" 2 DelivaryDay
7 SQLCHAR 0 4 "" 0 ExtraField
8 SQLCHAR 0 3 "" 0 ExtraField
9 SQLCHAR 0 24 "" 0 ExtraField
10 SQLCHAR 0 3 "" 0 ExtraField
11 SQLCHAR 0 24 "" 0 ExtraField
12 SQLCHAR 0 64 "" 0 ExtraField
13 SQLCHAR 0 24 "" 0 ExtraField
14 SQLCHAR 0 24 "" 0 ExtraField
15 SQLCHAR 0 24 "" 3 CompleteDate
16 SQLCHAR 0 24 "" 0 ExtraField
17 SQLCHAR 0 24 "" 0 ExtraField
18 SQLCHAR 0 24 "" 0 ExtraField
19 SQLCHAR 0 24 "" 0 ExtraField
20 SQLCHAR 0 256 "" 0 ExtraField


I need to take only three coulmns from the file and the text file won't contain any delimeters between the fields.
I tried to execute this using Bulk..Insert and i am getting the error:

Cannot bulk load. Invalid column number in the format file "C:sampleXXXX.fmt"

Any one can help me what is the problem here?
I am using SQL Server 2000.

View 1 Replies View Related

Bulk Insert Format File

Aug 24, 2007

Hi ,
I was wondering if there was a way in a format file to load a host file data field to more than one column in a table?

Thanks

View 1 Replies View Related

Using A Format File With BULK INSERT

May 21, 2008

Hi,

im attempting the following bulk insert statement:
BULK INSERT gtaRatesTemp FROM 'D: estData.CSV' WITH (FIRSTROW = 3, FORMATFILE = 'D: estFormat.Fmt'

testData.CSV example:




"Country","Country Code","City","City Code","Currency","Item","Item Code","Address 1","Address 2","Address 3","Address 4","Telephone","Rating","Location 1","Location 2","Location 3","No. of","Dates","Dates","Days","Days","Min","Min","Basis","Twin","Single","Triple","Quad","Twin for sole use","Child","Child Age","Child Age","Meals included","Distance to City Centre (Kms)","Child Details","Special Conditions"
"","","","","","","","","","","","","","","","","Rooms","From","To","From","To","Pax","Nights","","Price","Price","Price","Price","Price","Price","From","To","","",""
"Australia","AA","Palm Cove, QLD","PALC","AUD(Australian Dollars)","ALASSIO ON THE BEACH(1BD POOL)","ALA","139 WILLIAMS ESPLANADE","PALM COVE","QUEENSLAND 4879","AUSTRALIA","61-7-40591550","4","Waterfront/Beach","","","24","14 Jun 2007","30 Jun 2007","Mon","Sun","1","2","Room","181.00","181.00","","","181.00","","","","Breakfast not included","1","","Cancellations: (14 Jun 2007-31 Mar 2008) 0-5 days prior 100% of total; 6-10 days prior 100% for 1 Night; 11 days or more No charge; "
"Australia","AA","Palm Cove, QLD","PALC","AUD(Australian Dollars)","ALASSIO ON THE BEACH(1BD POOL)","ALA","139 WILLIAMS ESPLANADE","PALM COVE","QUEENSLAND 4879","AUSTRALIA","61-7-40591550","4","Waterfront/Beach","","","24","01 Jul 2007","31 Oct 2007","Mon","Sun","1","2","Room","231.00","231.00","","","231.00","","","","Breakfast not included","1","","Cancellations: (14 Jun 2007-31 Mar 2008) 0-5 days prior 100% of total; 6-10 days prior 100% for 1 Night; 11 days or more No charge; "
"Australia","AA","Palm Cove, QLD","PALC","AUD(Australian Dollars)","ALASSIO ON THE BEACH(1BD POOL)","ALA","139 WILLIAMS ESPLANADE","PALM COVE","QUEENSLAND 4879","AUSTRALIA","61-7-40591550","4","Waterfront/Beach","","","24","01 Nov 2007","31 Mar 2008","Mon","Sun","1","2","Room","181.00","181.00","","","181.00","","","","Breakfast not included","1","","Cancellations: (14 Jun 2007-31 Mar 2008) 0-5 days prior 100% of total; 6-10 days prior 100% for 1 Night; 11 days or more No charge; "
"Australia","AA","Palm Cove, QLD","PALC","AUD(Australian Dollars)","ANGSANA RESORT (1 BDRM BEACH)","ANG2","1 VEIVERS ROAD","PALM COVE","QUEENSLAND 4879","AUSTRALIA","61-7-40553000","5","Waterfront/Beach","","","67","14 Jun 2007","30 Jun 2007","Mon","Sun","1","1","Room","412.50","412.50","","","412.50","0","2","12","Breakfast not included","0","At this hotel an additional bed has not been provided in the room, child will need to share the existing bedding.","Cancellations: (14 Jun 2007-31 Mar 2008) 0-17 days prior 100% of total; 18-33 days prior 50% of total; 34 days or more No charge; "
"Australia","AA","Palm Cove, QLD","PALC","AUD(Australian Dollars)","ANGSANA RESORT (1 BDRM BEACH)","ANG2","1 VEIVERS ROAD","PALM COVE","QUEENSLAND 4879","AUSTRALIA","61-7-40553000","5","Waterfront/Beach","","","67","01 Jul 2007","30 Nov 2007","Mon","Sun","1","1","Room","463.00","463.00","","","463.00","0","2","12","Breakfast not included","0","At this hotel an additional bed has not been provided in the room, child will need to share the existing bedding.","Cancellations: (14 Jun 2007-31 Mar 2008) 0-17 days prior 100% of total; 18-33 days prior 50% of total; 34 days or more No charge; "
testFormat.Fmt:




8.0
36
1 SQLCHAR 0 50 """ 0 country SQL_Latin1_General_CP1_CI_AS
2 SQLCHAR 0 50 "","" 1 countryCode SQL_Latin1_General_CP1_CI_AS
3 SQLCHAR 0 200 "","" 2 city SQL_Latin1_General_CP1_CI_AS
4 SQLCHAR 0 50 "","" 3 cityCode SQL_Latin1_General_CP1_CI_AS
5 SQLCHAR 0 50 "","" 4 currency SQL_Latin1_General_CP1_CI_AS
6 SQLCHAR 0 500 "","" 5 item SQL_Latin1_General_CP1_CI_AS
7 SQLCHAR 0 50 "","" 6 itemCode SQL_Latin1_General_CP1_CI_AS
8 SQLCHAR 0 400 "","" 7 address1 SQL_Latin1_General_CP1_CI_AS
9 SQLCHAR 0 400 "","" 8 address2 SQL_Latin1_General_CP1_CI_AS
10 SQLCHAR 0 400 "","" 9 address3 SQL_Latin1_General_CP1_CI_AS
11 SQLCHAR 0 400 "","" 10 address4 SQL_Latin1_General_CP1_CI_AS
12 SQLCHAR 0 100 "","" 11 telephone SQL_Latin1_General_CP1_CI_AS
13 SQLCHAR 0 50 "","" 12 rating SQL_Latin1_General_CP1_CI_AS
14 SQLCHAR 0 100 "","" 13 location1 SQL_Latin1_General_CP1_CI_AS
15 SQLCHAR 0 100 "","" 14 location2 SQL_Latin1_General_CP1_CI_AS
16 SQLCHAR 0 100 "","" 15 location3 SQL_Latin1_General_CP1_CI_AS
17 SQLCHAR 0 100 "","" 16 noOfRooms SQL_Latin1_General_CP1_CI_AS
18 SQLCHAR 0 100 "","" 17 datesFrom SQL_Latin1_General_CP1_CI_AS
19 SQLCHAR 0 100 "","" 18 datesto SQL_Latin1_General_CP1_CI_AS
20 SQLCHAR 0 50 "","" 19 daysFrom SQL_Latin1_General_CP1_CI_AS
21 SQLCHAR 0 50 "","" 20 daysTo SQL_Latin1_General_CP1_CI_AS
22 SQLCHAR 0 100 "","" 21 minPAX SQL_Latin1_General_CP1_CI_AS
23 SQLCHAR 0 100 "","" 22 minNights SQL_Latin1_General_CP1_CI_AS
24 SQLCHAR 0 50 "","" 23 basis SQL_Latin1_General_CP1_CI_AS
25 SQLCHAR 0 100 "","" 24 twinPrice SQL_Latin1_General_CP1_CI_AS
26 SQLCHAR 0 100 "","" 25 singlePrice SQL_Latin1_General_CP1_CI_AS
27 SQLCHAR 0 100 "","" 26 triplePrice SQL_Latin1_General_CP1_CI_AS
28 SQLCHAR 0 100 "","" 27 quadPrice SQL_Latin1_General_CP1_CI_AS
29 SQLCHAR 0 100 "","" 28 twinForSoleUsePrice SQL_Latin1_General_CP1_CI_AS
30 SQLCHAR 0 100 "","" 29 childPrice SQL_Latin1_General_CP1_CI_AS
31 SQLCHAR 0 100 "","" 30 childAgeFrom SQL_Latin1_General_CP1_CI_AS
32 SQLCHAR 0 100 "","" 31 childAgeTo SQL_Latin1_General_CP1_CI_AS
33 SQLCHAR 0 50 "","" 32 mealsIncluded SQL_Latin1_General_CP1_CI_AS
34 SQLCHAR 0 50 "","" 33 distanceToCityCentre SQL_Latin1_General_CP1_CI_AS
35 SQLCHAR 0 500 "","" 34 childDetails SQL_Latin1_General_CP1_CI_AS
36 SQLCHAR 0 1500 ""
" 35 specialConditions SQL_Latin1_General_CP1_CI_AS
My problem is that once inserted, column 35(childDetails) and 36(specialConditions) are being merged into one. I think it may be an error with one of the values i have for the terminator in the format file but im unsure what exactly.

Does anyone have any ideas?

View 9 Replies View Related

Help Needed Little Urgent---how To Convert The String Date To Standard Date Format In SQL Table

Sep 28, 2007

Using DTS package in 2000 version, I am dumping TXT file contents into SQL Table,

I have one column having date in format YYYYMMDD(20070929) and corresponding column in SQL is datetime, but it fails on data type mismatch.

I have no choice of making date column in SQL to string or Varchar etc,

is there any way to make that date column in SQL to convert the value upon transformation from format (YYYYMMDD) to M/DD/YYYY (9/29/2007).

many many thanks,

View 2 Replies View Related

Unable To Insert Converted Date Into Date Column (Data Type)

Aug 24, 2015

PHP Code:

INSERT INTO [GPO].dbo.tblMetric  (KPI_ID, METRIC_ID, GOAL, REPORTING_MONTH, ACTUALS) 
SELECT 
    
      1 AS KPI_OWNER_ID
    , 23 AS METRIC_ID 
    , .75 AS GOAL 
    , CAST(Z.REPORTING_MONTH as DATE) AS REPORTING_MONTH
    , SUM(CAST(FTP_COUNT AS DECIMAL))/SUM(CAST(FULL_COUNT AS DECIMAL)) AS ACTUALS

[Code] ....

The insert column I am trying to get into is a date type. The original state of the field is YYYYMM varchar. How to get this into the table.

View 3 Replies View Related

Integration Services :: How To Load Multiple Date Format Column Date Into Table Using SSIS

Jun 15, 2015

i have a excel file in which i have a date column it having the below date formats below 

Install Date

20140721

31.07.2014

07.04.2015

20150108

20140811

20150216

7/21/2014

11.08.2014

07.08.2014

So using SSIS how we would load this date column into the table into one format like dd/mm/yyyy or any single date format

View 6 Replies View Related







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