Data Conversion From String To Decimal When Saving Data To SQL Server 2005 Using An ADO Recordset
Feb 12, 2008
Hello,
I am wondering what conversion rules apply, when a string, which contains a number, is saved to a SQL Server 2005 into a column of type decimal.
This is the code I€™m using (C++):
CString cValue = "0.75"
_variant_t vtFieldValue;
vtFieldValue = _variant_t(cValue)
pRecordSet->Fields->Item["MyColumn"]->Value = vtFieldValue;
"pRecordSet" is an ADO recordset. The database column "MyColumn" is of type "decimal(19,10)".
The most important question for me is, if the regional settings of the database server or the regional settings of the client PC are considered during the conversion from the string to the decimal value. For example in standard French regional settings the "." would not be recognized as decimal separator.
I am also wondering if the language of the database instance, in which this data is saved, is considered during this conversion or any other settings of this database instance.
So my general question is: Does anybody know exactly what rules apply during the above mentioned conversion?
Thank you for your help.
Regards,
Volker
View 2 Replies
ADVERTISEMENT
Mar 28, 2008
I'm very new to SSIS so please be patient and very detailed. Thank you in advance!
I have a SQL Table (tblImporData) with 2 columns: "Data" (varchar(40)) and "AccountNumber" (varchar(7)). I need to take the information in the "Data" column and parse it out into 3 different fields into a new table. I created the new table (tblExportData) with the following fields and data types: AcctNumber (varchar(7)), SiteName(nvarchar(10)), Balance (numeric(8,2)), and Active (nvarchar(1)).
Example of Data Field that I'm breaking up: 01Binford 001999Y
I've created a SSIS Package and in the dataflow I have an OLE DB Source going into a Derived Column. The derived column has the following information to split the data.
Derived Name Derived Column Expression Data Type Ln
AcctNumber Replace 'AcctNumber' AcctNumber String[DT_STR] 7
SiteName <add as new column> SUBSTRING(Data,3,10) Unicode string 10
Balance <add as new column> SUBSTRING(Data,13,6) Unicode String 6
Active <add as new column> SUBSTRING(Data,19,1) Unicode String 1
So it should split my example into the following:
AcctNumber SiteName Balance Active
12345 Binford 001999 Y
Everything works fine if the table I'm dumping the information to in SQL has varchar data types for all columns. But I need to convert my balance field from 001999 to 19.99. I tried putting a data conversion transform in that has the input column = Balance, Output Alias = Balance, Data Type = numeric [DT_NUMERIC], Precision = 8, and Scale = 2. I then changed the "Balance" data type to numeric(8,2) for the SQL table I'm dumping to, and added an OLE DB Destination to that table and mapped the columns.
When I try to run the package I'm getting an error at the Data Conversion that says the following:
[Data Conversion [698]] Error: Data conversion failed while converting column "Balance" (162) to column "Balance" (724). The conversion returned status value 2 and status text "The value could not be converted because of a potential loss of data.".
[Data Conversion [698]] Error: SSIS Error Code DTS_E_INDUCEDTRANSFORMFAILUREONERROR. The "output column "Balance" (724)" failed because error code 0xC020907F occurred, and the error row disposition on "output column "Balance" (724)" specifies failure on error. An error occurred on the specified object of the specified component. There may be error messages posted before this with more information about the failure.
[DTS.Pipeline] Error: SSIS Error Code DTS_E_PROCESSINPUTFAILED. The ProcessInput method on component "Data Conversion" (698) failed with error code 0xC0209029. The identified component returned an error from the ProcessInput method. The error is specific to the component, but the error is fatal and will cause the Data Flow task to stop running. There may be error messages posted before this with more information about the failure.
[DTS.Pipeline] Error: SSIS Error Code DTS_E_THREADFAILED. Thread "WorkThread0" has exited with error code 0xC0209029. There may be error messages posted before this with more information on why the thread has exited.
So, what am I doing wrong? Is there a different way I should be doing this? As always, your help is appreciated more than you'll ever know!
View 6 Replies
View Related
Jan 31, 2008
The following T-SQL code is run in a vb.net (2003) module.
I am acquiring data from an OPC server into an array of data type object. It is necessary to declare the array as an object for the OPC server to return data. The OPC returns the data in 15 mS.
I now need to save this data to a table in SQL 2005 running on a 2003 server.
The table for saving the data has already been created and saving the data is actually an 'update ... set ... where' statement.
The statement is
For i as short = 1 to itemCount
sql_command = "Update [IO Log].[dbo].[IO Log] Set TagValue = " & itemValue(i) & " where TagName =' " & tagName(i)
sql_command.executeNonQuery
Next
The TagValue field datatype is decimal(18,6)
The itemValue(i) datatype is object / variant. The itemValue array contains 95% values of type Single and the rest are Integers.
The TagName datatype is varchar(50)
The tagName(i) datatype is string
When I run the loop (255 iterations) with the above query it takes 1500 mS.
If I force a conversion by changing the query to
sql_command = "Update [IO Log].[dbo].[IO Log] Set TagValue = Convert(decimal, " & itemValue(i) & ") where TagName =' " & tagName(i)
it takes 900 mS to execute for 255 iterations.
I tried one more variation
sql_command = "Update [IO Log].[dbo].[IO Log] Set TagValue = Convert(decimal(18,6), " & itemValue(i) & ") where TagName =' " & tagName(i)
which takes 1200 mS to execute for 255 iterations.
If I use the following code
dim tempValue as decimal = 123456789012.123456D
sql_command = "Update [IO Log].[dbo].[IO Log] Set TagValue = " & tempValue & " where TagName =' " & tagName(i)
it excutes in under 100 mS for 255 iterations.
There seems to be a problem during implicit / explicit conversion of type object/variant to decimal.
I need to save the data received from the OPC (255 tags) in under 150 mS.
Could somebody help?
View 18 Replies
View Related
Oct 2, 2007
I'm getting some data from a flat file with a SSIS Package, it comes a integer but I would like to converted to a decimal with a 3 scale.
Example:
Flat File: 2070015000950011800
In the data conversion I had it with a 3 scale, but what I got was this:20700.00015000.0009500.00011800.000But what I want is something like this:20.70015.0009.50011.800
I dont know if you guys get the idea. But I will apreciate if anyone can help me.
Thanks,
Erick
View 2 Replies
View Related
Feb 20, 2008
Hi all, I have an requirement that, I want to save data getting from text boxes etc..,on button click the data should be saved in database and also the data must be saved as word document with a file name with in the same database table which i am saving the data..i hope it's clear... I reached upto saving the data under button click..but I stuck up in converting the data to word and saving the same data in server ..??how to convert page data into word and at the same time i want that doc file to save in a table in serverThanks & Regards,Vamsee.
View 1 Replies
View Related
Nov 24, 2006
Hi, all here,
Thank you very much for your kind attention.
I am wondering if it is possible to use SSIS to sample data set to training set and test set directly to my data mining models without saving them somewhere as occupying too much space? Really need guidance for that.
Thank you very much in advance for any help.
With best regards,
Yours sincerely,
View 5 Replies
View Related
Apr 4, 2006
I have a simple Integration Services project and the problem is that decimal fields are importing as real (I'm loosing the digits behind the decimal point).
The project contains a data flow task importing a flat file (.csv) to an SQL Server destination. My .csv file has two decimal type fields. Example:
Field 1: 12345.67
Field 2: .123456
My database table that I'm importing to has two fields. The only way that I can get this data to import is to define the fields as "float" in both the text file and database table. I want the database table fields to be defined as decimal or numeric, not float:
Field 1: decimal(7,2)
Field 2: decimal(6,6)
When all fields are defined as decimal (in both the flat file and database file), I get the following results:
Field 1: 12345.00
Field 2: .000000
How does one import decimal data from a flat file (.csv)?
Thank you in advance!
View 1 Replies
View Related
Nov 13, 2007
String or binary data would be truncated.The statement has been terminated. (.Net SqlClient Data Provider)
Hi i am getting the above error when i add a table to my Diagram, it happens inside VS05 (server explorer) as well as in SQL Express Server management studio CTP
the thing that is weird is that both tables are fine before i add the realtionship, both the Primary Key and the Foreign Key has the same data type which is Int. i am able to add the relationships but when i go to save the relationship diagram i get that above error
i believe that this error is caused when u try and insert data into a column that is larger that the column size, but in this case all am doing is creating a relation ship between the primary key in one table and a foreign key in the second table. ie i am not inserting data into either table
I looked at the size property of both columns under questions and both reflect a size of 4, I think that is 4 bytes of size,
so my question becomes is there any other place where the size of a column field is specified,
stumped, thanks in advance,
View 1 Replies
View Related
May 25, 2007
I am trying to insert data from a web form to a SQL Database. I am receiving the following error: {"String was not recognized as a valid Boolean."} I am also receiving a similar error for text boxes that have dates.
Below is the code that I am using:
<asp:SqlDataSource
id="SqlDataSource1"
runat="server"
connectionstring="<%$ ConnectionStrings:ConnMktProjReq %>"
selectcommand="SELECT LoanRepName,Branch,CurrentDate,ReqDueDate,ProofByEmail,ProofByEmail,FaxNumber,ProjectExplanation,PrintQuantity,PDFDisc,PDFEmail,LoanRepEmail FROM MktProjReq"
insertcommand="INSERT INTO MktProjReq(LoanRepName, Branch, CurrentDate, ReqDueDate, ProofByEmail, ProofByEmail, FaxNumber, ProjectExplanation, PrintQuantity, PDFDisc, PDFEmail, LoanRepEmail) VALUES (@RepName, @BranchName, @Date, @DueDate, @ByEmail, @ByFax, @Fax, @ProjExp, @PrintQty, @Disc, @Email, @RepEmail)">
<InsertParameters>
<asp:FormParameter Name="RepName" FormField="LoanRepNameBox"/>
<asp:FormParameter Name="BranchName" FormField="BranchList"/>
<asp:FormParameter Name="Date" FormField="CurrentDateBox" Type="DateTime"/>
<asp:FormParameter Name="DueDate" FormField="ReqDueDateBox" Type="DateTime"/>
<asp:FormParameter Name="ByEmail" FormField="ProofByEmailCheckbox" Type="boolean"/>
<asp:FormParameter Name="ByFax" FormField="ProofByFaxCheckbox" Type="boolean"/>
<asp:FormParameter Name="Fax" FormField="FaxNumberBox"/>
<asp:FormParameter Name="ProjExp" FormField="ProjectExplanationBox"/>
<asp:FormParameter Name="PrintQty" FormField="PrintQuantityBox"/>
<asp:FormParameter Name="Disc" FormField="PDFByDiscCheckbox" Type="boolean"/><asp:FormParameter Name="Email" FormField="PDFByFaxCheckbox" Type="boolean"/>
<asp:FormParameter Name="RepEmail" FormField="LoanRepEmailBox"/>
</InsertParameters>
</asp:SqlDataSource>protected void Button1_Click(object sender, EventArgs e)
{
SqlDataSource1.Insert();
}
I have been searching forums for parsing data, but I haven't found anything that works. Can anyone provide guidance.
Thank you,
Paul
View 2 Replies
View Related
Jan 22, 2008
Dear All,
I hope someone can help me in this problem. I create the Procedure to generate the dynamic SQL statement, and execute the dynamic SQL at end of the Procedure. When I done in Server Management Studio, all thing is OK, return me the record.
But when i use it in ASP, the statement as below
Code Block
Dim objCmd
Set objCmd = Server.CreateObject("ADODB.Command")
With objCmd
set .ActiveConnection = objCn
.CommandText = "MyProcedure"
.CommandType = 4
.Parameters.Append = .CreateParameter("@Par1", 200, 1, 10, Par1)
.Parameters.Append = .CreateParameter("@Par2", 200, 1, 8, Par2)
.Parameters.Append = .CreateParameter("@Par3", 200, 1, 1, Par3)
Set objRs = .Execute ()
If Not objRs.EOF Then
ID = objRs.Fields.Item (0).value
Name = objRs.Fields.Item (1).value
End If
objRs.close
End With
set ObjCmd = nothing
The Error below display, Why??
Code BlockError Type:
ADODB.Recordset (0x800A0E78)
Operation is not allowed when the object is closed.
And this is work fine in SQL 2000 before
View 3 Replies
View Related
Oct 26, 2006
Hi All,
i'm using a "data conversion" object to convert a numeric field to a string just before i save the record set to the database.
the problem is when this numeric field is > 0 it looses the precision on its decimal value.
example, if numeric value is 0.32
after converting this to a string, the new value will be : .32
it's lost the 0 infront of it. i can't do this converion in the query level because it's a derived field, so i need to convert it to a string before stroing it.
when converting to string i'm using the code page 1252 (ANSI - Latin I). i also tried with unicode string both looses this 0 infront.
can any one help on this?
View 7 Replies
View Related
Nov 30, 2015
I am trying to upload data from CSV to Sql table. I have a column as 'arrived_date' value '13:45' etc and while trying to load data i am getting error as "data conversion failed ,truncation may occur while loading data". In flat file connection this column datatype is string but in my table datatype is as time(). There is a error with conversion. I tried to change data type in advanced editor but no use. Using data conversion after flatfile makes my error disappear but it is giving error right at the file not even going through from file?
View 10 Replies
View Related
Oct 12, 2006
I am newbie in asp and sql, and I am using VS & SQL expresswhen I try to submit I get following error"Conversion failed when converting character string to smalldatetime data type"Following is my insert statement<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:oncallConnectionString %>"SelectCommand="SELECT data.* FROM data" InsertCommand="INSERT INTO data(Apps, Location, Impact, System, Date, Start_Time, End_Time, Duration, Problem, Cause, Solution, Case, Comments) VALUES ('@DropDownList1','@DropDownList2','@DropDownList3','@TextBox6','@DropDownCalendar1','@DropDownCalendar2','@DropDownCalendar3','@TextBox1','@TextBox2','@TextBox3','@TextBox4','@TextBox5','@TextBox7')"></asp:SqlDataSource>These are @DropDownCalendar1','@DropDownCalendar2','@DropDownCalendar3' defined as datetime in database.I would appriciate if somebody could help.
View 7 Replies
View Related
Mar 25, 2007
Hello, I have problem with this code.(This program presents - there is GridView tied to a SQL database that will sort the data selected by a dropdownList at time categories. There are 2 time categories in DropDownList - this day, this week.
Problem: when I choose one categorie in dropDownlist for examle this week and submit data on the server I got this error.
Conversion failed when converting character string to smalldatetime data type.
Here is code:
<%@ Page Language="C#" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
string datePatt = @"yyyymmdd";
// Get start and end of day
DateTime StartDate = DateTime.Today;
string @StartDate1 = StartDate.ToString(datePatt);
string @EndDate = StartDate.AddDays(1).ToString(datePatt);
// Get start and end of week
string @startOfWeek = StartDate.AddDays(0 - (int)StartDate.DayOfWeek).ToString(datePatt);
string @startOfNextWeek = StartDate.AddDays(7 - (int)StartDate.DayOfWeek).ToString(datePatt);
switch (DropDownList1.SelectedValue)
{
case "1":
// day
SqlDataSource1.SelectCommand = "SELECT [RC_USER_ID], [DATE], [TYPE] FROM [T_RC_IN_OUT]" + "WHERE" + "[DATE] >=" + "'@StartDate1'" + " AND [DATE] < " + "'@EndDate'";
break;
case "2":
//week
SqlDataSource1.SelectCommand = "SELECT [RC_USER_ID], [DATE], [TYPE] FROM [T_RC_IN_OUT]" + "WHERE" + "[DATE] >=" + "'@startOfWeek'" + "AND [DATE] <" + "'@startOfNextWeek'";
break;
}
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
<title>Untitled Page</title>
<style type="text/css">
body {
font: 1em Verdana;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="True" OnSelectedIndexChanged="DropDownList1_SelectedIndexChanged"
Style="z-index: 100; left: 414px; position: absolute; top: 22px">
<asp:ListItem Selected="True" Value="1">jeden den</asp:ListItem>
<asp:ListItem Value="2">jeden tyden</asp:ListItem>
</asp:DropDownList>
<asp:GridView ID="GridView1" runat="server" Style="z-index: 102; left: 228px; position: absolute;
top: 107px" DataSourceID="SqlDataSource1" AutoGenerateColumns="True">
</asp:GridView>
<br/> <br/>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="Data Source=CRSQLEXPRESS;
Initial Catalog=MyConn;Integrated Security=True"
ProviderName="System.Data.SqlClient"></asp:SqlDataSource>
</div>
</form>
</body>
</html>
View 4 Replies
View Related
Oct 3, 2007
I am running the following query:
select distinct hqvend, hqvprd,fprod,idesc,ilead,sum(cast(fqty as int) )as fqty, (cast(hqvend as varchar(5))+'/'+ltrim(rtrim(fprod))+'/'+cast(ilead as varchar(3))) as Keydata,'L1/'+rtrim(fprod) as LocPartno from tblkfpl01 inner join hqtl01 on (fprod=hqprod) inner join iiml01 on (hqvend=ivend and hqprod=iprod) where cast(cast(hqeff as varchar(8)) as smalldatetime) <= (Select CONVERT(varchar(8), getdate(), 1)) and cast(HQDIS as varchar(8)) >= (Select CONVERT(varchar(8), getdate(), 1)) and hqvend like '134%' group by hqvend,fprod,hqvprd,idesc,ilead order by hqvend,fprod
The bold sections are giving me the error message. The query works as written above, butis only evaluating on one date, contained in hqeff. However, when I try to modify the second date, HQDIS, by casting it the same way as the one before it:
select distinct hqvend, hqvprd,fprod,idesc,ilead,sum(cast(fqty as int) )as fqty, (cast(hqvend as varchar(5))+'/'+ltrim(rtrim(fprod))+'/'+cast(ilead as varchar(3))) as Keydata,'L1/'+rtrim(fprod) as LocPartno from tblkfpl01 inner join hqtl01 on (fprod=hqprod) inner join iiml01 on (hqvend=ivend and hqprod=iprod) where cast(cast(hqeff as varchar(8)) as smalldatetime) <= (Select CONVERT(varchar(8), getdate(), 1)) and cast(cast(HQDIS as varchar(8)) as smalldatetime) >= (Select CONVERT(varchar(8), getdate(), 1)) and hqvend like '134%' group by hqvend,fprod,hqvprd,idesc,ilead order by hqvend,fprod
I get the error message. I need to select based on both dates (hqeff AND HQDIS), but cannot seem to be able to it.... Both fields are of type Dedimal, with a length of 8, and dates stored in them look like: 20071003 (YYYYMMDD).
Any suggestions?
View 2 Replies
View Related
Oct 21, 2007
Hi,
I have SQL Server 2005 database table with the following data definition as follows:
ID int
LST_TIME varchar(5)
LST_DATE varchar(21)
LST_WEEK int
SUBJECT varchar(100)
Date format (Month,day YEAR) eg.- October, 21 2007
Time format, 00 - 23 hours, HH:MM eg. - 18:58
, and a VB code as below:
Dim Command As New SqlClient.SqlCommand("SELECT * FROM dbo.LISTS WHERE (LST_WK = DATEPART(wk, GETDATE())) AND (CONVERT(datetime, LST_DATE) = CONVERT(datetime, CONVERT(varchar, GETDATE(), 110)))
AND(CONVERT(smalldatetime, LST_TIME) = CONVERT(smalldatetime, CONVERT(varchar(5), GETDATE(), 108)))", conn)
Dim dataReader As SqlClient.SqlDataReader = Command.ExecuteReader(CommandBehavior.CloseConnection)
While dataReader.Read()
Dim NewAlert As New Alert(dataReader("SUBJECT").ToString(), DateTime.Parse(dataReader("LST_DATE").ToString(),
DateTime.Parse(dataReader("LST_TIME").ToString())))
:
:
:
I am encountering error: System.Data.SqlClient.SqlException: Conversion failed when converting character string to smalldatetime data type, which points to the codes in bold. Just wondering anyone out there has got a solution to my problem. Thank you.
View 5 Replies
View Related
Apr 10, 2008
Recently i traspased a database from sql server 2000 in spanish to sql server 2005 in english. I change the language of the user sa to spanish and the database is in spanish. . The problem is our dateformat is dmy, i try to force with set dateformat dmy, but always i execute a stored procedure that have a date as input it fail. The error is:
Msg 295, Level 16, State 3, Procedure pa_CalendarioGestion, Line 40
Conversion failed when converting character string to smalldatetime data type.
The code of stored procedure in this line is:
set @diaActual = dateadd("d", @i, @fechaInicio)
This stored procedure in sql server 2000 in spanish not have any problems. For this reason i think the problem is in the configuration.
I hope someone can help me. Thanks.
View 10 Replies
View Related
Sep 6, 2007
Hi i am working on sending data from a dat file to table in sql server Database and i am using the Data conversion transformation in ssis to convert string of fixed length into numeric (11,5) which is the datatype for the price field in the table and its returning an error saying that status vale 6 and error text as Conersion Failed sue to overflow of specific type ... Can anyone let me know how to overcome this error.
View 6 Replies
View Related
Oct 10, 2006
I am newbie in asp and sql, and I am using VS & SQL express
when I try to submit I get following error
"Conversion failed when converting character string to smalldatetime data type"
Following is my insert statement
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:oncallConnectionString %>"
SelectCommand="SELECT data.* FROM data" InsertCommand="INSERT INTO data(Apps, Location, Impact, System, Date, Start_Time, End_Time, Duration, Problem, Cause, Solution, Case, Comments) VALUES ('@DropDownList1','@DropDownList2','@DropDownList3','@TextBox6','@DropDownCalendar1','@DropDownCalendar2','@DropDownCalendar3','@TextBox1','@TextBox2','@TextBox3','@TextBox4','@TextBox5','@TextBox7')">
</asp:SqlDataSource>
These are @DropDownCalendar1','@DropDownCalendar2','@DropDownCalendar3' defined as datetime in database.
I would appriciate if somebody could help.
Thanks
View 3 Replies
View Related
Feb 21, 2006
When using AquaData or JDBC (inet tds driver), when doing an insert using SqlServer 2005, I get error "String or binary data would be truncated" when the data is actually OK. There are no triggers, etc. that would confuse the situation. It works fine in SqlServer 2000.
The scenario is as follows:
Create table:
create table test3 (
name varchar (18) ,
tbname varchar (18)
)
Create and populate table:
create table maxtable (
tablename varchar (18) not null,
[...]
)
Try to insert into test3:
insert into test3 (name, tbname)
select i.name, o.name
from dbo.sysindexes i, sysobjects o, maxtable m
where i.indid > 0 and i.indid < 255
and i.id = o.id and i.indid = 1
and o.name = lower(m.tablename)
And I get the error "String or binary data would be truncated." The values being selected for i.name and o.name have maximum length of 18. There are other rows in sysindexes and sysobjects with longer values, but they are not being selected.
The error does not occur with SQL Server Management Studio, and does not occur using SqlServer 2000.
View 6 Replies
View Related
Jul 15, 2014
All source and target date fields are defined as data type "smalldatetime". The "select" executes without error though when used with "insert into" it fails with the error:
Msg 295, Level 16, State 3, Line 25: Conversion failed when converting character string to small date-time data type..I am converting from a character string to smalldatetime since the source and target date columns are "smalldatetime". All other columns for the source and target are nvarchar(255). I assume there is an implicit conversion that I don't understand. In a test, I validated that all dates selected evaluate ISDATE() to 1.
USE [SCIR_DataMart_FromProd_06_20_2014]
GO
IF OBJECT_ID ('[SCIR_DataMart_FromProd_06_20_2014].[dbo].[IdentifierLookup]', 'U') IS NOT NULL
DROP TABLE [SCIR_DataMart_FromProd_06_20_2014].[dbo].[IdentifierLookup]
[code]....
View 9 Replies
View Related
Sep 26, 2007
I am working with a legacy SQL server database from SQL Server 2000. I noticed that in some places that they use decimal data types, that I would normally think they should be using integer data types. Why is this does anyone know?
Example: AutomobileTypeId (PK, decimal(10,0), not null)
View 5 Replies
View Related
Dec 8, 2013
I am creating a table on SQL Server. One of the columns in this new table contains whole integer as wells as decimal values (i.e. 4500 0.9876). I currently have this column defined as Decimal(12,4). This adds 4 digits after the decimal point to the whole integers. Is there a data type that will have the decimal point only for decimal values and no decimal point for the whole integers?
View 2 Replies
View Related
Jul 24, 2006
Hello!
I would like to cast (convert) data type decimal(24,4) to
decimal(21,4). I could not do this using standard casting function
CAST(@variable as decimal(21,4)) or CONVERT(decimal(21,4),@variable)
because of the following error: "Arithmetic overflow error converting
numeric to data type numeric." Is that because of possible loss of the
value?
Thanks for giving me any advice,
Ziga
View 6 Replies
View Related
Jun 4, 2007
Hi
I have only read ( select access) in a sql server database(2000). I am able to scripts the database.
Can any ony have any idea how to extract the data from database?
not the backup of db, i don't have the access.
No DTS to extract data into text file.
some thing like save the table with data?
I have more than 300 tables.
Thanks
sandipan
View 1 Replies
View Related
Nov 6, 2007
Hi,
I have a problem. The thing is that when I enter the values in a text boxes like evendate.text = "02/11/07" and desc.text="hello how r u" then I click on Save Button and its save in the SQL DATABASE but after this if I click on Refresh Button every time from the internet Explorer its automatically again save the data in the database although I have empty the textboxes.
The code is below:
<script runat="server"> sub SaveEvent(sender as object, e as EventArgs) dim con as new SQLConnection("server=london-home; Database=tony; uid=rashid2; pwd=test; ")
dim cmd as new SQLCommand("insert into events values('" & desc.text & "','" & DateTime.Parse(eventdate.text) & "')",con) con.open() cmd.executenonquery() con.close() clearform() display() end sub sub display() dim con as new SQLConnection("server=london-home; Database=tony; uid=rashid2; pwd=test; ") dim cmd as new SQLCommand("select * from events",con) con.open() dim SDR as SQLDataReader SDR = cmd.ExecuteReader() if SDR.HasRows = true then ViewEvents.DataSource = SDR ViewEvents.DataBind() end if con.close() end sub sub clearform() eventdate.text="" desc.text="" end sub sub Reset(sender as object, e as EventArgs) clearform() end sub</script>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>Untitled Document</title>
<style type="text/css">
#display_prod{float:left;}
#prod{margin-top:0;}
</style>
</head><body>
<table border="1" align="center" cellpadding="5" cellspacing="0"><tr><td valign="top">
<form id="prod" runat="server" enctype="multipart/form-data"><table id="display_prod" width="554" border="1" cellspacing="0" cellpadding="0" align="left" height="400"> <tr valign="top" height="20"> <td> </td> <td> <table border="1" align="center" cellpadding="10" cellspacing="0"> <tr> <td>PRODUCTS DESCRIPTION <asp:Label runat="server" ID="lbl"></asp:Label></td> </tr> </table> </td> </tr> <tr valign="top"> <td> <table align="left" id="menu" width="150" border="1" cellpadding="0" cellspacing="0"> <tr align="center"> <td><a href="home.aspx">Main</a></td> </tr> <tr align="center"> <td><a href="Events.aspx">Change Password</a></td> </tr> <tr align="center"> <td><a href="events.aspx">Events</a></td> </tr> </table> </td> <td align="left"> <table width="390" border="1" cellpadding="0" cellspacing="0"> <tr> <td width="100" >Enter Date :</td> <td width="243" ><asp:TextBox runat="server" ID="eventdate" BackColor="#FFFFFF" Width="100"></asp:TextBox> mm/dd/yy</td> </tr> <tr> <td>Description :</td> <td><asp:TextBox runat="server" ID="desc" TextMode="MultiLine" Columns="20" Rows="3" BackColor="#FFFFFF" MaxLength="200"></asp:TextBox> max 200</td> </tr> <tr> <td> </td> <td> <asp:Button runat="server" ID="btnsubmit" Text="Save" OnClick="SaveEvent"></asp:Button> <asp:Button runat="server" ID="btnreset" Text="Reset"></asp:Button> </td> </tr> </table> <table width="390" border="1" align="left" cellpadding="0" cellspacing="0"> <tr> <td> <asp:DataGrid runat="server" ID="ViewEvents" AutoGenerateColumns="false"> <columns> <asp:TemplateColumn> <itemtemplate> <table id="tt" border="1" cellpadding="5" cellspacing="0"> <tr> <td><asp:Label runat="server" ID="eventname" Text='<%#container.DataItem("event_name")%>' ></asp:Label></td> <td><asp:Label runat="server" ID="pdesc" Text='<%# trim(DataBinder.Eval(Container.DataItem,"event_date","{0:MM/dd/yyyy}")) %>' ></asp:Label></td> </tr> </table> </itemtemplate> </asp:TemplateColumn> </columns> </asp:DataGrid> </td> </tr></table> </td> </tr> </table>
</form>
</td></tr></table></body></html>
View 2 Replies
View Related
Aug 29, 2007
Hi everybody there
i have a small problem with this code, it cann't save changes on Datatable to the database SQL Server Mobile ..
the execution work succesfully but without changes in the database !
here is the code, please try to help :
Code Snippet
#Region " << Declarations >> "
Dim objCon As New SqlCeConnection("Data source=Storage CardFull_Database.sdf")
Dim objDA As SqlCeDataAdapter
Dim objCmdBldr As SqlCeCommandBuilder
Dim objTB As New DataTable("MyTB")
Dim objBS As New BindingSource
#End Region
Private Sub frmDatabase_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
objDA = New SqlCeDataAdapter("Select * From MyTB", objCon)
objDA.MissingSchemaAction = MissingSchemaAction.AddWithKey
objTB.Clear()
objDA.Fill(objTB)
objBS.DataSource = objTB
End Sub
' Add New Record for example
Private Sub mnuAddNew_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuAddNew.Click
If Not CType(objBS.Current, DataRowView).IsNew Then
objBS.AddNew()
Dim dRowView As DataRowView = objBS.Current
dRowView.BeginEdit()
dRowView("id") = 10
dRowView("name") = "Someone"
dRowView.EndEdit()
End If
' Calling Save Methode
mnuSave_Click(sender, e)
End Sub
' Save Values
Private Sub mnuSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuSave.Click
objBS.EndEdit()
objCmdBldr = New SqlCeCommandBuilder(objDA)
objDA.Update(objTB)
End Sub
View 2 Replies
View Related
Aug 31, 2004
Hi There,
I'm using C# to get a value for a DOUBLE precision variable, called "Length", from a textBox using the following line:
Length = Convert.ToDouble( txtLength.Text )
I'm also using the following lines to prepare my stored procedure call:
arParms[9] = new SqlParameter("@Length", SqlDbType.Decimal, 5);
arParms[9].Value = record.Length;
My stored procedure has the following parameter definition:
@Length decimal(9,3)
My problem is that if someone types a value bigger than 999999 in the textbox he will get for sure the following error:
System.Data.SqlClient.SqlException: Error converting data type numeric to decimal.
I don't know how to either make sql or C# to truncate the value or catch the exception to automatically assign 0 to the parameter.
Please Help.
Moshe
View 1 Replies
View Related
May 21, 2008
String or binary data would be truncated. I get this error when entering data using sql server management studio express.
I am not running a sql to insert or update the table. This is through the EDI.
The data type is varchar(100). I enter one character and it errors on me. So this isn't a string being too long problem.
Any ideas?
View 2 Replies
View Related
Jun 6, 2007
Hi All,
I need a solution for the following:
I have a field with datatype string, length 8, in the form yyyymmdd (f.e. 20070604).
Now I need to transfer this field into a field with datatype dt_DBDATE or DT_DBDATE.
I tried to perform this with a derrived column and type cast (DT_DATE) or (DT_DBDATE), but this does not work.
Any hint for me!!!
Thanks in Advance
ulrike
View 5 Replies
View Related
Jun 18, 2007
I have created a simple package that uses a sql command to pull data from an oracle database and inserts the data into a sql 2005 table. Some of the data fields that i am pulling from contain two digits after the decimal point, however this data is lost when it gets into sql. I have even tried putting the data into a flat file, and still the data is lost.
In the package I have a ole db source connection which is the oracle database and when i do the preview i see all the data I need. I am very confused and tried a number of things to get the data into sql, but none work. Any ideas would be very helpful.
thanks
View 6 Replies
View Related
May 12, 2015
We saved huge log data from user behaviour in our site .
But In data mining time , we saw that most of them cant use for data mining
What is the best practice about data gathering from user movement in site?
is there any best practice Template for this ?
View 0 Replies
View Related
Jan 7, 2008
Hi Experts,
I am extracting data from SQL Server 2005 to flat file destination. I am using SQL Command to specify the data selection query. One of my query uses Replicate function to derive a column value. When I execute this package it fails with the error "Data conversion failed. The data conversion for column "value" returned status value 4 and status text "Text was truncated or one or more characters had no match in the target code page".
The reason for the problem is that, it is taking the InputColumnWidth of the flat file destination as 8000 and I specified the OutputColumnWidth as 4.
If I change the OutputColumnWidth to 8000, it is working without any error but resulting in the column width of 8000.
I tried using DerivedColumn Transformation's Type cast and DataConversion Transformation but still I am getting the same error in the respective Transformation components.
Can anyone suggest how to solve this issue.
View 11 Replies
View Related