Showing posts with label variable. Show all posts
Showing posts with label variable. Show all posts

Tuesday, March 20, 2012

Problems with mimimum value for DateTime Package Variable since SP1

Since I've installed SP1 the minimum value for a package variable has changed.

The former version used 12/30/1899 as the minimum value that can be entered.
Now the min value has changed to something about 1960.

During package execution I'd like to distinguish between two states:

1. The Variable has not yet been written to.
2. Any of my executable has written to it.

At the moment I check the value of it to be the minimum value (see above) or not.
So if I develop packages under SP1 I get into trouble.

Any way out of it?
Thanks
Fridtjof

[EDIT] The mindate in C# differs from both date values mentioned above! Consistency? Hum![/EDIT]

How did you determine that you can't put values below 1960 in there? I (or more accurately Darren who is sat right next to me) has just typed the value 01/01/1900 into the variables window and it sems to take it OK.

What specifically are you not able to do?

-Jamie

|||

Typing works fine, and the following code worked too.

Public Sub Main()

Dts.Variables("Variable").Value = DateTime.MaxValue
System.Windows.Forms.MessageBox.Show(Dts.Variables("Variable").Value.ToString())

Dts.Variables("Variable").Value = DateTime.MinValue
System.Windows.Forms.MessageBox.Show(Dts.Variables("Variable").Value.ToString())

Dts.TaskResult = Dts.Results.Success

End Sub

|||Oops, I don't really know what went wrong but it works as you mentioned.

Sorry for posting too quick...

Saturday, February 25, 2012

Problems with : SqlDataReader = Command.ExecuteReader()

I am currently tryinh to have this variable declared :
Dim SQLLecteur As SqlDataReader = Command.ExecuteReader()
And receiving the following error : 'ExecuteReader' is not member of 'String'.

1. The ExecuteReader was not present in the list following the Command.
2. The variable is declared from a : Public Shared Sub
3. This sub is located in a code library referenced in the web.config as a namespace : <add namespace="PAX20070409" />
4. If used directly in the .vb file within this sub : Protected Sub btnConnection_Click, I am not receiving any errors about the Dim.

It is pretty clear why the code is not working, but I have not been able to find a way to fix the problem. I am currently trying to find a way to make the Dim work from within my code library. If you have any idea on how this could be achieve, it would be greatly apreciated.

Thank you :)
RV3

looks that you Command is declared somewhere as string or is not declared and system use string type as default

try

dim SQLCommand as sqlclient.sqlcommand = new sqlclient.sqlcommand("Your command name")

'setup connection for your command

'open your connection

Dim SQLLecteur As SqlDataReader = SQLCommand.ExecuteReader()

'close your connection

example:

Dim queryString As String = _
"SELECT OrderID, CustomerID FROM dbo.Orders;"

Using connection As New SqlConnection(connectionString)
Dim command As New SqlCommand(queryString, connection)
connection.Open()

Dim reader As SqlDataReader = command.ExecuteReader()

' Call Read before accessing data.
While reader.Read()
Console.WriteLine(String.Format("{0}, {1}", _
reader(0), reader(1)))
End While

' Call Close when done reading.
reader.Close()
End Using|||

yOUR CODE SHOULD LOOK LIEK THIS ONE

Dim queryString As String = _
"SELECT OrderID, CustomerID FROM dbo.Orders;"

Using connection As New SqlConnection(connectionString)
Dim command As New SqlCommand(queryString, connection)
connection.Open()

Dim reader As SqlDataReader = command.ExecuteReader()

' Call Read before accessing data.
While reader.Read()
Console.WriteLine(String.Format("{0}, {1}", _
reader(0), reader(1)))
End While

' Call Close when done reading.
reader.Close()
End Using

|||

Public Shared SQLConnection As New SqlConnection(ConfigurationManager.AppSettings("BDD_LILILUX"))
Public Shared SQLCommande As SqlClient.SqlCommand = New SqlClient.SqlCommand("SQLCommande")

This is the answer, it is working marvellously fine now :)

Thank you :)

|||

Missed a line :P

Dim SQLLecteur As SqlDataReader = SQLCommande.ExecuteReader