SQLDATETIME In Bcp File...

Sep 22, 2005

Hi,
i m using sql server 2005 YUKON...and in my format file i have one datetime column..the format of it is as follow :(bulk_format.fmt)

9.0
3
1SQLCHAR 012 " " 1 number SQL_Latin1_General_CP1_CI_AS
2 SQLDATETIME 0 8 " " 2 date_time SQL_Latin1_General_CP1_CI_AS
3SQLCHAR 04 "
" 3alphabet SQL_Latin1_General_CP1_CI_AS


and the format of my input data file is as follow:
12345896236507-08-2005a
56785698412305-06-2009b
91023698547502-08-2003c
35691458963201-02-2000d

now,whenever i m trying to run this in CMD...it gives me the error as:
Starting Copy...
SQLState = 42000, NativeError=4896
error= [microsoft][sql native client][sql server] Invalid column value from bcp client for colid 2
BCP copy in failed.....

So, now can anyone pleaseeeeeeeee tell me..how to deal with this????
any help will be greatly appreciated...
thnks..

View 1 Replies


ADVERTISEMENT

SqlDateTime Overflow

Aug 6, 2007

I've seen a few comments on this error and they've all been basically "You're passing a bad date time". I don't think that's what's happening in my case though.
I'm trying to write a record to my SQL database using a business logic layer class that writes the record with a stored procedure. Here's the codebehind on the page: Protected Sub btnSubmit_Click(ByVal sender As Object, ByVal e As System.EventArgs)
'Create New User
UsersBLL.NewUser(txtFirstName.Text, _
txtLastName.Text, _
txtPhone1.Text, _
ddlOffice.SelectedIndex, _
lblManager.Text, _
lblManagerAlt.Text, _
txtDepartment.Text, _
cbxNewPosition.Checked, _
cbxContractor.Checked, _
Calendar1.SelectedDate.ToString, _
txtJobTitle.Text, _
ddlFunctionCodes.SelectedIndex)

End Sub 
Here's the BLL function that I'm calling:
    Public Shared Function NewUser(ByVal UsersNameFirst As String, _                    ByVal UsersNameLast As String, _                    ByVal UsersPhone1 As String, _                    ByVal OfficesID As Int32, _                    ByVal UsersID_Manager As Int32, _                    ByVal UsersID_ManagerAlt As Int32, _                    ByVal UsersDepartment As String, _                    ByVal UsersNewPosition As Boolean, _                    ByVal UsersContractor As Boolean, _                    ByVal UsersStartDate As DateTime, _                    ByVal UsersJobTitle As String, _                    ByVal FunctionCodesID As Int32, _                    Optional ByVal UsersGSN As String = Nothing, _                    Optional ByVal UsersEmail As String = Nothing, _                    Optional ByVal UsersNameMiddle As String = Nothing, _                    Optional ByVal UsersKnownAs As String = Nothing, _                    Optional ByVal UsersPhone2 As String = Nothing, _                    Optional ByVal UsersPhoneMobile1 As String = Nothing, _                    Optional ByVal UsersPhoneMobile2 As String = Nothing, _                    Optional ByVal UsersSSN As String = Nothing, _                    Optional ByVal UsersContractType As String = Nothing, _                    Optional ByVal UsersContractAgency As String = Nothing, _                    Optional ByVal UsersEndDate As DateTime = Nothing, _                    Optional ByVal UsersCompanyCode As String = Nothing, _                    Optional ByVal UsersCostCenter As String = Nothing, _                    Optional ByVal UsersRole As String = Nothing, _                    Optional ByVal StatusesID As Int32 = Nothing)        Dim dbConnection As SqlConnection, Command As SqlCommand        dbConnection = New SqlConnection(DBConnectionString)        dbConnection.Open()        Command = New SqlCommand("EXECUTE NewUser", dbConnection)        Command.Connection = dbConnection        Command.CommandText = "NewUser"        Command.CommandType = Data.CommandType.StoredProcedure        Command.Parameters.Add(New SqlParameter("@UsersNameFirst", UsersNameFirst))        Command.Parameters.Add(New SqlParameter("@UsersNameLast", UsersNameLast))        Command.Parameters.Add(New SqlParameter("@UsersPhone1", UsersPhone1))        Command.Parameters.Add(New SqlParameter("@OfficesID", OfficesID))        Command.Parameters.Add(New SqlParameter("@UsersID_Manager", UsersID_Manager))        Command.Parameters.Add(New SqlParameter("@UsersID_ManagerAlt", UsersID_ManagerAlt))        Command.Parameters.Add(New SqlParameter("@UsersNewPosition", UsersNewPosition))        Command.Parameters.Add(New SqlParameter("@UsersContractor", UsersContractor))        Command.Parameters.Add(New SqlParameter("@UsersStartDate", UsersStartDate))        Command.Parameters.Add(New SqlParameter("@UsersJobTitle", UsersJobTitle))        Command.Parameters.Add(New SqlParameter("@FunctionCodesID", FunctionCodesID))        Command.Parameters.Add(New SqlParameter("@UsersGSN", UsersGSN))        Command.Parameters.Add(New SqlParameter("@UsersEmail", UsersEmail))        Command.Parameters.Add(New SqlParameter("@UsersNameMiddle", UsersNameMiddle))        Command.Parameters.Add(New SqlParameter("@UsersKnownAs", UsersKnownAs))        Command.Parameters.Add(New SqlParameter("@UsersPhone2", UsersPhone2))        Command.Parameters.Add(New SqlParameter("@UsersPhoneMobile1", UsersPhoneMobile1))        Command.Parameters.Add(New SqlParameter("@UsersPhoneMobile2", UsersPhoneMobile2))        Command.Parameters.Add(New SqlParameter("@UsersSSN", UsersSSN))        Command.Parameters.Add(New SqlParameter("@UsersContractType", UsersContractType))        Command.Parameters.Add(New SqlParameter("@UsersContractAgency", UsersContractAgency))        Command.Parameters.Add(New SqlParameter("@UsersEndDate", UsersEndDate))        Command.Parameters.Add(New SqlParameter("@UsersCompanyCode", UsersCompanyCode))        Command.Parameters.Add(New SqlParameter("@UsersCostCenter", UsersCostCenter))        Command.Parameters.Add(New SqlParameter("@UsersCostCenter", UsersCostCenter))        Command.Parameters.Add(New SqlParameter("@UsersRole", UsersRole))        Command.Parameters.Add(New SqlParameter("@StatusesID", StatusesID))        Return Command.ExecuteScalar()        dbConnection.Close()  
 
Here's the stored procedure I'm running in SQL:
  (
@UsersGSNvarchar(20) = Nothing,
@UsersNameFirstvarchar(20),
@UsersNameMiddlevarchar(20) = Nothing,
@UsersNameLastvarchar(20),
@UsersKnownAsvarchar(20) = Nothing,
@UsersPhone1varchar(50),
@UsersPhone2varchar(50) = Nothing,
@UsersPhoneMobile1varchar(20) = Nothing,
@UsersPhoneMobile2varchar(20) = Nothing,
@UsersEmailvarchar(50) = Nothing,
@OfficesIDint,
@UsersDepartmentvarchar(50),
@UsersSSNvarchar(5) = Nothing,
@UsersNewPositionbit,
@UsersContractorbit,
@UsersContractTypevarchar(20) = Nothing,
@UsersContractAgencyvarchar(50) = Nothing,
@UsersStartDatedatetime,
@UsersEndDatedatetime = Nothing,
@UsersJobTitlevarchar(50),
@FunctionCodesIDint,
@UsersCompanyCodevarchar(20) = Nothing,
@UsersCostCentervarchar(20) = Nothing,
@UsersID_Managerint,
@UsersID_ManagerAltint,
@UsersRolevarchar(20) = "User",
@StatusesIDint = 1
)
AS
SET NOCOUNT OFF;

INSERT INTO [Users]
(UsersGSN,
UsersNameFirst,
UsersNameMiddle,
UsersNameLast,
UsersKnownAs,
UsersPhone1,
UsersPhone2,
UsersPhoneMobile1,
UsersPhoneMobile2,
UsersEmail,
OfficesID,
UsersDepartment,
UsersSSN,
UsersNewPosition,
UsersContractor,
UsersContractType,
UsersContractAgency,
UsersStartDate,
UsersEndDate,
UsersJobTitle,
FunctionCodesID,
UsersCompanyCode,
UsersCostCenter,
UsersID_Manager,
UsersID_ManagerAlt,
UsersRole,
StatusesID)

VALUES
(@UsersGSN,
@UsersNameFirst,
@UsersNameMiddle,
@UsersNameLast,
@UsersKnownAs,
@UsersPhone1,
@UsersPhone2,
@UsersPhoneMobile1,
@UsersPhoneMobile2,
@UsersEmail,
@OfficesID,
@UsersDepartment,
@UsersSSN,
@UsersNewPosition,
@UsersContractor,
@UsersContractType,
@UsersContractAgency,
@UsersStartDate,
@UsersEndDate,
@UsersJobTitle,
@FunctionCodesID,
@UsersCompanyCode,
@UsersCostCenter,
@UsersID_Manager,
@UsersID_ManagerAlt,
@UsersRole,
@StatusesID);  
 
Seems about as simple as it can get to me. UsersStartDate is a datetime (which I'm picking from a calendar control on the web page) and it's passing (for example) "08/01/2007 12:00:00 AM". I've debugged and that's the value being passed.
 Now when I go to my DB and write a simple insert query and insert exactly that date, it works fine. Maybe my development machine date settings are changing it somehow before it sends to the DB?
Also I'm pretty sure there's a lot of redundant passing of all those vars but I'm brand new to tiered apps and just learning. If there's a simpler way, feel free to enlighten me. :)

View 8 Replies View Related

SqlDateTime Overflow

Mar 13, 2006

Hi All,
Please help!!! I've looked all over the place and tried all the solutions that worked for others. I just want to insert a Null value to a DateTime field in my SQL db! I am calling dv_ItemInserting on ItemInserting of my FormView.
I tried using a stored procedure to fix this problem SET @opDate = NullIf(@opDate, NULL). I am still getting the same error.
Please forward any info you have. Thanks!!!
----------------------------------------------
Error:
SqlDateTime overflow. Must be between 1/1/1753 12:00:00 AM and 12/31/9999 11:59:59 PM.
Protected Sub dv_ItemInserting(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.FormViewInsertEventArgs)
 If e.Values.Item("opDate").Equals(Nothing) OrElse e.Values.Item("opDate").Equals(DateTime.MinValue) Then'Tried the followings and they do not work !!!     
      'SqlDataSource1.InsertParameters("opDate").DefaultValue = System.DBNull.Value      'e.Values.Item("opDate") = System.Data.SqlTypes.SqlDateTime.Null.Value
 end if End sub

View 3 Replies View Related

Error: SqlDateTime Overflow !!!???

Jul 24, 2004

When I run my query

dr = Me.SqlComm_Chk_ATLGroup.ExecuteReader

it give me this error:

SqlDateTime overflow. Must be between 1/1/1753 12:00:00 AM and 12/31/9999 11:59:59 PM.


This is my Query :

SELECT break_time, break_rep_no, break_type, break_user_id
FROM breaks
WHERE (break_date = @p1) AND (break_group = @p2) AND (break_time > @p3) AND (break_time < @P4)
ORDER BY break_time

This is the code

Dim dr As SqlClient.SqlDataReader

Me.SqlConn.Open()
Me.SqlComm_Chk_ATLGroup.Parameters(0).Value = #7/23/2004#
Me.SqlComm_Chk_ATLGroup.Parameters(1).Value = 0
Me.SqlComm_Chk_ATLGroup.Parameters(2).Value = #10:00:00 AM#
Me.SqlComm_Chk_ATLGroup.Parameters(3).Value = #2:00:00 PM#

dr = Me.SqlComm_Chk_ATLGroup.ExecuteReader

While dr.Read

End While

Me.SqlConn.Close()

Note : when I store the time in a string and display it it gives me 10:00:00 AM 1/1/0001 or something like that ?

Where is the problem?

View 3 Replies View Related

PLEASE HELP ME: SqlDateTime Overflow. Must Be Between 1/1/1753 12:00:00 AM And 12/31/9999 11:59:59 PM.

Feb 21, 2007

I cannot for the life of me figure out why im still getting this
error. I have tried everything i can think of from using dbnull.value
to setDOBnull() to datetime.minvalue. Can anyone help me? Here's the code on my BLL:   
Public Function AddEmployee(ByVal SSN As String, ByVal FirstName As
String, ByVal LastName As String, ByVal PreferredName As String, ByVal
MaidenName As String, ByVal MaritalStatus As Nullable(Of Char), ByVal
DOB As Nullable(Of Date), ByVal Gender As Nullable(Of Char), ByVal
Ethnicity As String, ByVal StartDate As Nullable(Of Date), ByVal
TerminationDate As Nullable(Of Date)) As Boolean        ' Create a new employeeRow instance        Dim employees As New HRMS.EmployeesDataTable()        Dim employee As HRMS.EmployeesRow = employees.NewEmployeesRow()        Dim sqldatenull As SqlDateTime        sqldatenull = SqlDateTime.MinValue.Value        employee.SSN = SSN        employee.FirstName = FirstName        employee.LastName = LastName        If PreferredName Is Nothing Then employee.SetPreferredNameNull() Else employee.PreferredName = PreferredName        If MaidenName Is Nothing Then employee.SetMaidenNameNull() Else employee.MaidenName = MaidenName        If Not MaritalStatus.HasValue Then employee.SetMaritalStatusNull() Else employee.MaritalStatus = MaritalStatus.Value        If Not DOB.HasValue Then employee.SetDOBNull() Else employee.DOB = DOB.Value        If Not Gender.HasValue Then employee.SetGenderNull() Else employee.Gender = Gender.Value        If Ethnicity Is Nothing Then employee.SetEthnicityNull() Else employee.Ethnicity = Ethnicity       
If StartDate = DateTime.MinValue Then employee.StartDate =
SqlDateTime.MinValue.Value Else employee.StartDate = StartDate.Value        'If StartDate = DateTime.MinValue Then employee.SetDOBNull() Else employee.StartDate = StartDate.Value        'If Not StartDate.HasValue Then employee.StartDate = sqldatenull Else employee.StartDate = StartDate.Value       
If TerminationDate = DateTime.MinValue Then employee.TerminationDate =
SqlDateTime.MinValue.Value Else employee.TerminationDate =
TerminationDate.Value P

View 8 Replies View Related

SqlDateTime Overflow. Must Be Between 1/1/1753 12:00:00 AM And 12/31/9999 11:59:59 PM

Jul 16, 2007

Hi there...
 i have a search page with consitst of DatePicker and DataView
this is how i'm binding my dataview
<asp:ObjectDataSource runat="server" EnableCaching="false" ID="ods" TypeName="daab.Employee"                                                        SelectMethod="GetEmployee">                                                        <SelectParameters>                                                                                                                         <asp:ControlParameter ControlID="DatePicker1" ConvertEmptyStringToNull="true" PropertyName="SelectedDate" Name="SearchDate" Direction="Input" Type="DateTime" />                                                        </SelectParameters>                                                    </asp:ObjectDataSource>
..........................................................................................
the searchDate is optional user may select date from datepicker or leave it blank if (!string.IsNullOrEmpty(DatePicker1.SelectedDate))
{ //
}
else
{
this.ods.SelectParameters["SearchDate"].DefaultValue = DBNull.Value.ToString();
}
 when i execute the above code i get this error:, what i'm missing?
error Message = "SqlDateTime overflow. Must be between 1/1/1753 12:00:00 AM and 12/31/9999 11:59:59 PM."

View 10 Replies View Related

SqlDateTime Overflow. Must Be Between 1/1/1753 12:00:00 AM And 12/31/9999 11:59:59 PM.

Apr 10, 2008

hey,
i will make calender(by use Asp.net 2003 - C# - framework 2.0 ) that stored and retreive data from Database(SQL Server 2000), that success , but if add this function (Calendar1_DayRender)

Server Error in '/bwarq' Application.


SqlDateTime overflow. Must be between 1/1/1753 12:00:00 AM and 12/31/9999 11:59:59 PM. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.Data.SqlTypes.SqlTypeException: SqlDateTime overflow. Must be between 1/1/1753 12:00:00 AM and 12/31/9999 11:59:59 PM.Source Error:




Line 1999:DA.SelectCommand.Parameters.Add("@eventdate",eventdate);
Line 2000:DataTable DT=new DataTable();
Line 2001:DA.Fill(DT);
Line 2002:DA.SelectCommand.Connection.Close();return DT;
Line 2003:}
Source File: c:inetpubwwwroot4paldataaccess.cs    Line: 2001 
 
and i want to see my files here:
 
1- DataAccess(put here Stored proceure)public static DataTable GetCalendar(DateTime eventdate)
{SqlDataAdapter DA=new SqlDataAdapter("GetCalendar",createConn());
DA.SelectCommand.CommandType=CommandType.StoredProcedure;
DA.SelectCommand.Parameters.Add("@eventdate",eventdate);DataTable DT=new DataTable();
DA.Fill(DT);DA.SelectCommand.Connection.Close();return DT;
}
 
2- User Control Page
 private void Calendar1_SelectionChanged(object sender, System.EventArgs e)
{
DataTable DT=DataAccess.GetCalendar(Calendar1.SelectedDate);if(DT.Rows.Count == 0)
{DGEvent.Visible = false;
}
else
{DGEvent.Visible = true;
DGEvent.DataSource=DT;
DGEvent.DataBind ();
}
 
}private void Calendar1_DayRender(object sender, System.Web.UI.WebControls.DayRenderEventArgs e)
{
DataTable DT2=DataAccess.GetCalendar(Calendar1.SelectedDate);
// If the month is CurrentMonthif (! e.Day.IsOtherMonth )
{for(int i=0 ; i< DT2.Rows.Count;i++)
{if ((DT2.Rows[i]["eventdate"].ToString() != DBNull.Value.ToString()))
{
DateTime dtEvent= (DateTime)DT2.Rows[i]["eventdate"];if (dtEvent.Equals(e.Day.Date))
{
e.Cell.BackColor = Color.PaleVioletRed;
}
}
}
}
//If the month is not CurrentMonth then hide the Dates
else
{
e.Cell.Text = "";
}
}

 
so,  i want the exaclty solution for this problem,plz
 

View 1 Replies View Related

SqlDateTime Overflow. Must Be Between 1/1/1753 12:00:00 AM And 12/31/9999 11:59:59 PM.

Apr 17, 2008

Yes, I've parsed many a topic on many a site regarding this issue.sigh.I am using a calendar control within a TemplateField on a DetailsView.I know that my SQL DB will accept NULL for my DATETIME field, because if I don't bind the control to the insert, the insert succeedes, yeilding a null for DATETIME in the new record.My problem is that I want the user to be able to choose to not select a date.    I find that I have to bind selected value to the insert parameter, so that if they do select a date, it get inserted.( duhh!! )      When I do though, and the user does not select a date, I get the above error.My best guess?  it is sending a datetime value of 00:00:0000 00:00:00 (or something like that anyhow)?So... does anyone have any ideeas on a simple way to evaluate the value when the form is submitted?   and how to set it to NULL if it is, for example "in the past" or "00:00:0000....." ?
,Gary"We truly fail, only when we quit."

View 11 Replies View Related

SqlDatetime-Overflow On Production Server

Jun 4, 2008

Hey everybody!
I'm getting a pretty annoying error on my production server when i want to run an app ..
Error Msg (german): SqlDateTime-Überlauf; muss zwischen 1/1/1753 12:00:00 AM und 12/31/9999 11:59:59 PM liegen.
Funny thing is that on my client development machine i'm not getting an error at all. The DateTimes I use (C# and SQL Server) are dd/mm/yyyy hh:mm:ss formatted. I also don't write to the databse - only read!
Anyone familiar with this issue?
Thanks in advance & best regards!

View 2 Replies View Related

Converting DateTime To SqlDateTime Format

Mar 30, 2006

Hi,
I have a function that generates a range of DateTimes, which I then cast to SqlDateTime to compare with SqlDateTime values in a database.
The problem is my converted DateTimes come out in this type of format "6/2/2006 12:00:00 AM"
wheras my SqlDateTimes in the database are in this format "2006-01-18T00:00:00.0000000-12:00"
Any ideas how I can convert the DateTime values to SqlDateTime correctly so that I can compare them?  As I said I tried creating a new SqlDateTime object with the DateTime value ie
DateTime dt = new DateTime("");
SqlDateTime sdt = new SqlDateTime(dt);
But that doesn't work correctly, its still not in the format that is in the database.

View 1 Replies View Related

SqlDateTime Overflow. Must Be Between 1/1/1753 12:00:00 AM And 12/31/9999 11:59:59 PM

Dec 1, 2005

Hi. I am getting the error described in the title - SqlDateTime overflow. I have read what is available online but am still not able to get rid of it. Help much appreciated... thanks.

The Full Error Is:


Code:


System.Data.SqlTypes.SqlTypeException: SqlDateTime overflow. Must be between 1/1/1753 12:00:00 AM and 12/31/9999 11:59:59 PM. at System.Data.SqlTypes.SqlDateTime.FromTimeSpan(TimeSpan value) at System.Data.SqlTypes.SqlDateTime.FromDateTime(DateTime value) at System.Data.SqlTypes.SqlDateTime..ctor(DateTime value) at System.Data.SqlClient.MetaType.FromDateTime(DateTime dateTime, Byte cb) at System.Data.SqlClient.TdsParser.WriteValue(Object value, MetaType type, Int32 actualLength, Int32 encodingByteSize, Int32 offset, TdsParserStateObject stateObj) at System.Data.SqlClient.TdsParser.TdsExecuteRPC(_SqlRPC[] rpcArray, Int32 timeout, Boolean inSchema, SqlNotificationRequest notificationRequest, TdsParserStateObject stateObj) at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async) at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result) at System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(DbAsyncResult result, String methodName, Boolean sendToPipe) at System.Data.SqlClient.SqlCommand.ExecuteNonQuery() at ASP.audiobook_viewdetails_aspx.DetailsView1_ItemInserting(Object Src, DetailsViewInsertEventArgs Args) in C:InetpubwwwrootdushkinmediasupportwebPresentationTieraudiobook_servicesaudiobook_viewdetails .aspx:line 151



And, below is the method that is raising the errors. The
culprit is "created_date" as "DateTime".


Code:


Sub DetailsView1_ItemInserting(ByVal Src As Object, ByVal Args As DetailsViewInsertEventArgs)

'validate the controls

If Args.Values("ISBN") = "" Then
Args.Cancel = True
MSG.Text = "-- Missing ISBN number"
End If

If Args.Values("author_first") = "" Then
Args.Cancel = True
MSG.Text = "-- Missing first name"
End If

If Args.Values("author_last") = "" Then
Args.Cancel = True
MSG.Text = "-- Missing last name"
End If

If Args.Values("publisher") = "" Then
Args.Cancel = True
MSG.Text = "-- Missing Publisher"
End If

If Args.Values("text_description") = "" Then
Args.Cancel = True
MSG.Text = "-- Missing item description"
End If

If Not IsNumeric(Args.Values("regular_price")) Then
Args.Cancel = True
MSG.Text = "-- regular price is not numeric"
Else
If Args.Values("regular_price") < 0 Then
Args.Cancel = True
MSG.Text = "-- regular price is out of range"
End If
End If

If Not IsNumeric(Args.Values("discount_price")) Then
Args.Cancel = True
MSG.Text = "-- Discount price is not numeric"
Else
If Args.Values("discount_price") < 0 Then
Args.Cancel = True
MSG.Text = "-- Discount price is out of range"
End If
End If

'if all the controls are valid, decalre the types
Dim audiobookID As Integer
Dim title As String
Dim author_first As String
Dim author_last As String
Dim publisher As String
Dim ISBN As String
Dim regular_price As String
Dim discount_price As String
Dim text_description As String
Dim created_date As DateTime

' ||||| Set up a Connection Object to the SQL DB
Dim MyConn As System.Data.SqlClient.SqlConnection = New System.Data.SqlClient.SqlConnection("server=ARIA;database=dushkinmedia;Integrated Security=SSPI")
' ||||| Pass in the StoreProcedure or Command String, as well as the Connection object
Dim MyCmd As New System.Data.SqlClient.SqlCommand("sp_RegisterNewAudioBook", MyConn)
' ||||| Set the Command Type (Stored Procedure, Text, etc)
MyCmd.CommandType = System.Data.CommandType.StoredProcedure
' ||||| Create Parameter Objects for values passed in
Dim objParam1, objParam2, objParam3, objParam4, objParam5, objParam6, _
objParam7, objParam8, objParam9, objParam10, objParam11, objParam12, _
objParam13, objParam14, objParam15 As System.Data.SqlClient.SqlParameter
' ||||| Add your parameters to the parameters Collection
objParam1 = MyCmd.Parameters.Add("@audiobookID", Data.SqlDbType.Int)
objParam2 = MyCmd.Parameters.Add("@title", Data.SqlDbType.VarChar)
objParam3 = MyCmd.Parameters.Add("@author_first", Data.SqlDbType.VarChar)
objParam4 = MyCmd.Parameters.Add("@author_last", Data.SqlDbType.VarChar)
objParam5 = MyCmd.Parameters.Add("@publisher", Data.SqlDbType.VarChar)
objParam6 = MyCmd.Parameters.Add("@ISBN", Data.SqlDbType.VarChar)
objParam7 = MyCmd.Parameters.Add("@regular_price", Data.SqlDbType.VarChar)
objParam8 = MyCmd.Parameters.Add("@discount_price", Data.SqlDbType.VarChar)
objParam9 = MyCmd.Parameters.Add("@text_description", Data.SqlDbType.Text)
objParam10 = MyCmd.Parameters.Add("@created_date", Data.SqlDbType.DateTime)
'objParam10 = MyCmd.Parameters.AddWithValue("@img_name", imgName)
objParam11 = MyCmd.Parameters.AddWithValue("@img_data", System.Data.SqlDbType.Image)
'objParam12 = MyCmd.Parameters.AddWithValue("@img_contenttype", imgcontenttype)
'objParam13 = MyCmd.Parameters.AddWithValue("@aud_name", audName)
objParam14 = MyCmd.Parameters.AddWithValue("@aud_data", System.Data.SqlDbType.VarBinary)
'objParam15 = MyCmd.Parameters.AddWithValue("@aud_contenttype", audcontenttype)
' ||||| Set the Parameter values to the passed in values
objParam1.Value = audiobookID
objParam2.Value = title
objParam3.Value = author_first
objParam4.Value = author_last
objParam5.Value = publisher
objParam6.Value = ISBN
objParam7.Value = regular_price
objParam8.Value = discount_price
objParam9.Value = text_description
objParam10.Value = created_date
'objParam11.Value = imgBinaryData
'objParam14.Value = audBinaryData

Try

' ||||| Check if Connection to DB is already open, if not, then open a connection
' ||||| DB not already Open...so open it

MyConn.Open()
MyCmd.ExecuteNonQuery()

' ||||| Close the Connection Closes with it
MyConn.Close()


Catch e As Exception
Beep()
MSG.Text = e.ToString

End Try

'Response.Redirect("~/audiobook_services/audiobook_view.aspx")

End Sub




Any help at all would be MUCH appreciated... Thanks in advance.

View 2 Replies View Related

SqlDateTime Overflow. Must Be Between 1/1/1753 12:00:00 AM And 12/31/9999 11:59:59 PM.

Jun 27, 2006

Hi,

Is there a way to catch the exeption (SqlDateTime overflow. Must be between 1/1/1753 12:00:00 AM and 12/31/9999 11:59:59 PM) with in SQL Server, so it does not need to be caught in the code calling the procedure. E.g. I do not want to send null to the stored procedure.

 

e.g. The stored procedure should be able to catch dates that are outside the range 1/1/1975 and 12/31/9999 and change them to the limits.

E.g.

IF @StartDate < CONVERT(DateTime, '01/01/1753 12:00:00')

BEGIN

    SET @StartDate = CONVERT(DateTime, '01/01/1753 12:00:00')

END

IF @EndDate > CONVERT(DateTime, '01/01/1753 11:59:59')

BEGIN

    SET @EndDate = CONVERT(DateTime, '12/31/9999 11:59:59')

END

 

This still throws an exception because the StartDate or EndDate when tested fail the condition.

View 7 Replies View Related

Reporting Services :: Parsing SSRS Config File And Dynamically Changing File Path Of Config File In Code

Sep 2, 2015

Currently have a single hard coded file path to the SSRS config file which parses the file and provides the reporting services web service url.  My question is how would i run this same query against 100s of servers that may or may not share the same file path as the one hard coded ?

Is there a way to query the registry to find the location of the config file of any server ? which could be on D, E, F, H, etc. 

I know I can string together the address followed by "reports" and named instance if needed, but some instances may not have used the default virtual directory name (Reports).

Am I going about this the hard way ? Is there a location where the web service url exists in a table ? I could not locate anything in the Reporting service database. Basically need to inventory all of my reporting services url's.

View 2 Replies View Related

File Will Not Attach To SQL Reason File Is Not Primary File

May 10, 2007

I have a customer they are running raid 5 on a windows 2000 server one of the drives went bad. The customer replaced the drive and raid rebuilt the drive, every thing seamed to be fine but there is one database file that cannot be attached to SQL. The file is 15G so I know there is information the error states that the file is not a Primary file. Any clue on how to fix this?

mdf file size 5,738,944 KB
ldf file size 10,176 KB

View 4 Replies View Related

An Attempt To Attach An Auto-named Database For File (file Location).../Database.mdf Failed. A Database With The Same Name Exists, Or Specified File Cannot Be Opened, Or It Is Located On UNC Share.

Sep 2, 2007

Greetings, I have just arrived back into the country (NZ) and back into ASP.NET.
 I am having trouble with the following:An attempt to attach an auto-named database for file (file location).../Database.mdf failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share.
It has only begun since i decided i wanted to use IIS, I realise VWD comes with its own localhost, but since it is only temporary, i wanted a permanent shortcut on my desktop to link to my intranet page.
 Anyone have any ideas why i am getting the above error? have searched many places on the internet and not getting any closer.
Cheers ~ J
 

View 3 Replies View Related

Attach Mdf File And Data File Without Log File

Mar 1, 2006

how can i attach the mdf file with a corrupted/deleted Log file
my log file is deleted how can i attach the mdf file

View 1 Replies View Related

Maintenance Commands Affect On Log File / Log File Maintenance Without Log File Backups?

Jun 18, 2015

I am testing some maintenance tasks sql commands such as index rebuild, index reorg, update statistics and db integrity check on a SQL Server 2014 Database. This is a new non-production vendor database (DB Size 500 GBs, Log Size 25 GBs) which eventually will be created in production. Currently, it is in full recovery model and without log backups. The database has a whole lot of indexes. I am just trying to rebuild and reorganize all the indexes (that need it), in addition to trying to get an idea of how long these maintenance task will take and the space needed in the log file to complete these tasks/commands. I would like to execute these tasks manually (the first time) to gather the duration and space required information. Eventually, I would probably schedule a weekly job to perform this maintenance.

I ran the index rebuild task on the database and noticed that the log file grew by over 50 GBs. I killed the process and truncated and shrunk the log file back down.

1. Does the index rebuild, index reorg, update statistics and db integrity check commands all use the log file?

2. Does Indexs Reorg have less impact on log file then Index Rebuild?

3. Should a truncate log and shrink log file be performed after these maintenance commands?

4. Should a full database backup be performed after these maintenance commands? Or before the maintenance commands?

I have read and understand that shrinking is not good for the database (could lead to more fragmentation and more data file growth when data is added) and I know about rebuilding indexes when fragmentation is GT 30% and reorganizing indexes when fragmentation is GT 5% and LE 30%.

Since this is a non-production database maybe I should set the recovery model to simple, run the maintenance commands and leave the database in simple recovery model unless the vendor needs it in full recovery model for some unknown reason.

5. With the simple recovery model the log file should be reused in a circular manner and not grow during these maintenance tasks. Is this correct?

View 3 Replies View Related

Help Please (Check File Exists/ Archive File/ Check If File Empty)

Mar 10, 2008



Hello World,

I'm new to SSIS and would like a little assistance getting started, if possible...


Here is what I want to do:


Check if file exist (C:DTS UpgradeFilexxx.txt) --->

Archive file (C:DTS UpgradeArchive) --->

Check if file has data (true or false)


AND/OR

If there are any good website that have good direction, let me know


Thanks in advance for your help!!!

View 5 Replies View Related

SQL Server 2012 :: Write A Process To Get File Size In Kb And Record Count In A File?

Jul 31, 2014

I need to write a process to get file size in kb and record count in a file. I was planning on writing a c# console app that takes the file path and name as a param however should i use a CLR?

I cant put a script in the ssis when it's bringing the file down because it has been deemed that we only use ssis for file consumption.

View 1 Replies View Related

SQL Server Admin 2014 :: Creating Additional Data File For A Particular File Group?

Jul 6, 2015

For a database, we have 4 data files in a particular file group and the file sizes are almost 70 GB each.

Do I come across any performance issues if I create/pre-allocate an additional data file in the same file group so that the existing files don't grow too much?

View 5 Replies View Related

Integration Services :: Flat File Error File Being Created In-spite Of No Errors

Jun 23, 2015

I have a package in which there are only one Data flow Task and it has only three components. 1) Source , which is a SQL db 2) destination and 3) OLE DB Destination flat file Error output file.   I want the error file to be created ONLY if there is any error while dumping the data into destination DB. But , the issue is, the error flat file is being created inspite of No error while dumping the  data from Source to Destination.

View 5 Replies View Related

Integration Services :: Renaming / Replacing Part Of A File In File System Task

May 14, 2015

I'm copying files to a folder with the naming convention as follows in the source folder:

CM_ABC_MY_TEST.txt

In the destination folder, this filename needs to appear as:

CM_XYZ_MY_TEST.txt

In my File System Task, I'm pretty sure I'm going to need an expression with a replace, substring, etc. But am having a hard time nailing down the exact syntax.

View 10 Replies View Related

Integration Services :: Get FileName Fo Each File Created Via Dynamic Flat File Destination

Jul 24, 2015

Need to know how I can get the dynamic filename created in the FlatFile destination for insert into a package audit table?

Scenario: Have created a package that successfully outputs Dynamiclly named flat files { Format: C:Test’Comms_File_’ + ‘User::FileNumber’+’_’+Date +’.txt’

E.g.: Comms_File_1_20150724.txt, Comms_File_2_20150724.txt  etc} using Foreach Loop Container  :

* Enumerator Set to: “Foreach ADO Enumerator” with the ADO object source variable selected to identify how many total loop iterations there are i.e. Let’s say 4 thus 4 files to be created

*Variable Mappings : added the User::FileNumber – indicates which file number current loop iteration is i.e. 1,2,3,4

For the DataFlow task have a OLDBSource and a FlatFile Destination where Flat File ConnectionString is set up as:

@[User::Output_Path] + "Comms_File"+ @[User:: FileNumber] +"_" + replace((DT_WSTR, 10) (DT_DBDATE) GETDATE(),"-","")+ ".txt"

All this successfully creates these 4 files:

Comms_File_1_20150724.txt, Comms_File_2_20150724.txt, Comms_File_3_20150724.txt, Comms_File_4_20150724.txt

Now the QUESTION is how do I get these filenames as I need to insert them into a DB Audittable. The audit table looks like this:

CREATE TABLE dbo.MMMAudit
  (
     AuditID      INT IDENTITY(1, 1) NOT NULL,
     PackageName     VARCHAR(100) NULL,
  
FileName           VARCHAR(100) NULL,
     LoadTime        DATETIME NULL,
     NumberofRecords INT NULL
  ) 

To save the Filename & how many records in each file in our Audit Table, am using an Execute SQL Task and configuring it as this:

Execute SQL Task

Parameter mapping - Mapped the User Variable (RecordsInserted) and System Variable( PackageName) to Insert statement as shown below

SQLStatement: INSERT INTO [dbo].[MMMAudit] ( 
PackageName,NumerofRecords,LoadTime)
 (?,?.GETDATE)

Again this all works terrific & populates the dbo.MMMAudit table as shown below BUT I also need to insert the respsctive file name – How do I do that?

AuditID PackageName FileName  NumberOfRecords
1           MMM       NULL                      12
2          MMM  NULL                23
3          MMM  NULL      14
4          MMM  NULL              1                     

View 2 Replies View Related

How To Create, Install And Deploy Dts File For Sqlserver 2000 And Dtsx File For 2005 ?

Apr 24, 2007

Hi,



I am looking for tutorials about how to create dts et dtsx files.

Thanks for your help.



Arioule.

View 1 Replies View Related

Script Task To Compare File From FTP With File On Local Archive Behaved Strangely!

May 9, 2008

In my script task I have the following code. The task I'm trying to accomplish is:
If the filename on FTP can be found in the local archive folder of e: drive then show message "FileAlreadyThere" (I will ultimatley change it to do nothing); if the filename on FTP cannot be found in the local archive folder of e: drive then transfer the file to the local package folder on d: drive.

While the script task is executing I was watching it closely, but the problem i saw is that:
If some files on FTP are already in local archive folder and some are not, then it the files which are already in the archive folder are dumped to the package folder; then after that the files which are not in the archive folder are then dumped to the package folder. But I only want the new files on FTP to be transferred to the package folder for further processing.

Then after this is finished, I saw all the files in the package folder are refreshed one after another, after the first round of refresh the second round starts, after the second round finishes it then stopped. I saw it refreshes itself because the 'Date Modified' of the file changes. And I saw the script task turned green.

I don't see how the code below produced this result. Something is wrong in the logic of the loop? Anyone has any idea why it's behaving the way it is now? And how to change the code to accomplish what I want? Thanks a lot!!

--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Imports System
Imports System.IO
Imports System.Data
Imports System.Math
Imports Microsoft.SqlServer.Dts.Runtime
Public Class ScriptMain
Public Sub Main()
Dim cm As ConnectionManager = Dts.Connections.Add("FTP")
cm.Properties("ServerName").SetValue(cm, "ftp2.name.com")
cm.Properties("ServerUserName").SetValue(cm, "username")
cm.Properties("ServerPassword").SetValue(cm, "password")
cm.Properties("ServerPort").SetValue(cm, "21")
cm.Properties("Timeout").SetValue(cm, "0")
cm.Properties("ChunkSize").SetValue(cm, "1000") '1000 kb
cm.Properties("Retries").SetValue(cm, "1")
Dim ftp As FtpClientConnection = New FtpClientConnection(cm.AcquireConnection(Nothing))
ftp.Connect()
ftp.SetWorkingDirectory("/directory")
Dim fileNames() As String
Dim folderNames() As String
ftp.GetListing(folderNames, fileNames)
If fileNames Is Nothing Then
MsgBox("NoFileOnFTP")
Else
Dim fileName As String
For Each fileName In fileNames
If File.Exists("c: emp" + fileName) Then
MsgBox("FileAlreadyThere")
Else
ftp.ReceiveFiles(fileNames, "c: emp", True, True)
End If
Next
End If

ftp.Close()
End Sub
End Class

View 3 Replies View Related

XML Format File For Bulk Insert Of Text File With Fixed Length Columns

Jan 2, 2008

Hey All,

Similar to a previous post (http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=244646&SiteID=1), I am trying to import data into a SQL Table.

I am trying to program a small application that will import product data obtained through suppliers via CD-ROM. One supplier in particular uses Fixed width colums, and data looks like this:




Example of Data

0124015Apple Crate 32.12

0124016Bananna Box 12.56

0124017Mango Carton 15.98

0124018Seedless Watermelon 42.98
My Table would then have:
ProductID as int
Name as text
Cost as money

How would I go about extracting the data with an XML Format file? I am stumbling over how to tell it where to start picking up data for a specific column.
Is there any way that I could trim the Name column (i.e.: "Mango Carton " --> "Mango Carton")?

I don't know if it makes any difference, but I've been calling SQL from my code by doing this:




Code in C# Form

SqlConnection SqlConnection = new SqlConnection(global::SQLClients.Properties.Settings.Default.ClientPhonebookConnectionString);
SqlCommand cmd = new SqlCommand();

cmd.CommandType = CommandType.Text;
cmd.CommandText = "INSERT INTO PhonebookTable(Name, PhoneNumber) VALUES('" + txtName.Text.ToString() + "', '" + txtPhoneNumber.Text.ToString() + "')";
cmd.Connection = SqlConnection;

SqlConnection.Open();
cmd.ExecuteNonQuery();
SqlConnection.Close();
RefreshData();
I am running Visual Studio C# Express 2005 and SQL Server Express 2005.



Thanks for your time,


Hayden.

View 1 Replies View Related

SQL 2012 :: Find Out Number Of Columns In Flat File Before Process That Particular File

Apr 14, 2014

I need find out the number of columns in flat file before i process that particular file.I have file name in @filename variable and file path is @filepath variable.But do not not that how i will check the column name in before i will process that file.

@filePath = C:DatabaseSourceFilesCAHCVSSourceFiles
And i am using for each loop container to read the file one by one and put the file name in @filename variable.and my file name like

Product_20120607060930.txt
Product_20130708060930.txt

[code]....

Now what i have to do is i need to make sure that ID,Name,City,County,Phone is there in flat file.if it is not there then i have to send mail to client saying that file is not valid.I need to also calculate the size of flat file.

View 4 Replies View Related

SQL 2012 :: TempDB Log File Usage Constantly Rising And File Keeps Growing?

Jun 16, 2014

The TEMPDB transaction log file keeps growing.The database server is new and the transaction log was presized to 1 GB on installation. After installing a number of databases, the log file grew over a day to 38GB. Issuing a manual checkpoint was the only way to free some space to allow it to be shrunk back to a usable size. The usage of the file is still going up.

I am struggling to find what process is causing the log to be used so heavily. Looking at the log reuse wait desc for tempdb returns "Nothing" and tempdb itself isn't being used very much or growing in size.

View 9 Replies View Related

SQL Server Admin 2014 :: Can Delete A Data-file Or File-group

Apr 27, 2015

In a server we had File Growth,And then We had to Add New Hard Drive And New File On It.And Now We have New server with a Huge Hard Drive.But all files remaind.Can I Reduce This files to One data file or not ?

View 3 Replies View Related

Is It Possible To Write A Format File That Skips A Few Bytes Of Header In Data File?

Jul 23, 2005

Hi,I am trying to use BULK INSERT with format file. All of our data hasfew bytes of header in the data file which I would like to skip beforedoing BULK INSERT.Is it possible to write format file to skip these few bytes ofheader before doing BULK INSERT? For example, I have a 1 GB data filewith 1000 byte header. Except for first 1000 bytes, rest of the data isgood for BULK INSERT.Thanks in advance. Sorry if it is really a dumb question as I am newto BULK INSERT and practicing still.Bob

View 7 Replies View Related

Shrink File Tool From EM Took All The Empty Space Allocated To Data File

Jul 20, 2005

I've production sql server 7 sp3 on windows NT. I had a 8GB data file ofwhich 5GB were used and 3GB were unused. I wanted to take back the unused3GB.So I did the following with EM GUI:1. I tried to "truncate fre space from end of the file". Didn't truncatethe file. I believe there was no empty space at the end of the file.2. Next I chose the option to "shrink file to 5GB". And to my horror thedata file instead of taking just 5GB took the empty spaces also and the sizeof the used data file went to 8GB.Any idea what's going on?TIA,SP

View 2 Replies View Related

Integration Services :: Excel Destination With Run Date-1 Inside File Not The File Name

Aug 26, 2015

I have a ssis package where I need to have excel destination.  In the Excel file, I need to have few rows with some text and then populate data below the text. One the text is like this:

Data as of:  08/25/2015

if the report ran today, then Data as of will have Yesterday. So, if the user opens that excel file after a week, then user should see same  Data as of:  08/25/2015. not today()-day(1).

I was planing to handle on excel side with today()-day(1). but it only works the day it was run. Then the excel file is open after few days later, then it might as Data as of:  08/30/2015 which is not true. It should still stay Data as of:

 08/25/2015 on what ever date the excel file is open. The SSIS package  runs only once. 

How do I handle this so that whenever user open the file, they will see Data as of:  08/25/2015. This is not a column in excel. It is like a description of data in excel.

View 3 Replies View Related

Help Getting Error When Using Operation Rename A File In The File System Task Editor?

Aug 18, 2006

Does anyone know how to do this using variables?  Everytime I try it, I get the

Error: Failed to lock variable for read access with error 0xc00100001. 

 I also tried it writing a script and still the same error.  If I hard code the values into the variables it works fine but I will be running this everday so that it will pull in the current date along with the filename.  So the value of the variables will change everyday.  Here is my expression:

@[User::Variable] +(DT_WSTR,4) YEAR( GETDATE() )+"0"+(DT_WSTR,2) MONTH( GETDATE() ) + (DT_WSTR,2) DAY( GETDATE() )

The result:

C:Documents and SettingsmroushDesktopOSU20060818

the 20060818 part will change everyday ie.(tomorrow will be 20060819, next day 20060820 and so on.)

 

View 6 Replies View Related







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