Showing posts with label refer. Show all posts
Showing posts with label refer. Show all posts

Friday, March 16, 2012

"Tracking"

OK. For DDL, please refer to the classical Northwind ORDERS table,
problem/challenge, find the longest duration (start_date and
end_date), during which, no orders were placed.

FYI, column names by the order of colid per syscolumns:
OrderID
CustomerID
EmployeeID
OrderDate
RequiredDate
ShippedDate
ShipVia
Freight
ShipName
ShipAddress
ShipCity
ShipRegion
ShipPostalCode
ShipCountry

Any idea/approach? TIA.Does this help?

select o1.OrderDate, o2.OrderDate, DATEDIFF( day, o1.OrderDate,
o2.OrderDate) as days_between
from dbo.Orders o1, dbo.Orders o2
where o1.OrderDate < o2.OrderDate
and not exists
(select * from dbo.Orders o3
where o3.OrderDate < o2.OrderDate
and o1.OrderDate < o3.OrderDate)
group by o1.OrderDate, o2.OrderDate
order by days_between desc

"DonLi" <donli@.yahoo.com> wrote in message
news:9a172893.0404051228.4a675061@.posting.google.c om...
> OK. For DDL, please refer to the classical Northwind ORDERS table,
> problem/challenge, find the longest duration (start_date and
> end_date), during which, no orders were placed.
> FYI, column names by the order of colid per syscolumns:
> OrderID
> CustomerID
> EmployeeID
> OrderDate
> RequiredDate
> ShippedDate
> ShipVia
> Freight
> ShipName
> ShipAddress
> ShipCity
> ShipRegion
> ShipPostalCode
> ShipCountry
> Any idea/approach? TIA.

Sunday, February 19, 2012

"Input string was not in a correct format"

I am trying to do an insert into a SQL server table but I am getting an "input string was not in correct format" error. Does this error always refer to SQL string problem? I put in a breakpoint and looked at the SQL and it looks good but until I figure this out I will be tracing through the code. Any input greatly appreciated.

MyCmd.CommandText = sSQL
MyCmd.ExecuteNonQuery() 'Line where I get the error
Thanks,
JoeThis usually indicates there is a data type mismatch problem. You've probably assigned a value to a parameter which was expecting avalue with a different data type.
|||Ok, in response to your feedback, I've shortened the SQL insert string and I plan on trying to insert first just one field and then next two fields and so on so I can determine which field is giving me a problem, however I can't even insert one field. My code:
Try
MyCmd.CommandText = "INSERT INTO tblTest (intProjectID) VALUES (1)"
MyCmd.ExecuteNonQuery()
Catch e As System.Data.SqlClient.SqlException
Response.Write(e.Message)
End Try
Is still giving me the same errror:
"Input string was not in a correct format" for the MyCmd.ExecuteNonQuery line.
intProjectID of tblTest field is type "int". What am I doing wrong?
Thanks in advance,
Joe