Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Error: Bad Vaiable Type

Status
Not open for further replies.

01310564

Programmer
Oct 9, 2003
96
GB
Has anyone ever come across this error message? I can't find any reference to it anywhere.

I think it's something to do with running my application on windows 2000 because it works perfectly on XP machines.

Cheers,

Hugh
 
Ok here we go...

I have developed a program that is now being used on several PCs and it is working great on all of them except from 1 which uses windows 2000 (the rest run on XP).

The peice of code in question creates a new record in a table, updates a record in an existing table and then refreshes the information on the screen.

The reason why i posted so little information was i assume (Correct me if i'm wrong) that this isn't a problem with my code because it is working fine on five other computers but rather a problem with VS 2002 and Windows 2000 (or something not being installed on that computer) and was intreasted if anyone else had even heard of such a problem.

If you think that the code would help then please let me know and I will post it.

Thanks

Hugh
 
Does the Win 2000 PC have the same version of the .NET Framework as the XP PCs?


I used to rock and roll every night and party every day. Then it was every other day. Now I'm lucky if I can find 30 minutes a week in which to get funky. - Homer Simpson
 
That was my first thought but the 2000 machine has the same versions of the .net framework installed and also has bean patched to the max.

Anyway here is the code.


Cursor = Windows.Forms.Cursors.WaitCursor
durationD = DateDiff(DateInterval.Day, frm.expected_date, frm.DTPdays.Value)
durationH = IIf(frm.txthours.Text = "", "0", frm.txthours.Text)

frm.Close()
cbo_productselect.SelectedIndex = currentindex
' new_stage_date = get_working_hours_datetime(DateAdd(DateInterval.Hour, durationH, DateAdd(DateInterval.Day, durationD, CDate(txt_exp_stream_comp.Text))))
Dim conn As New ADODB.Connection()
Dim cmd As New ADODB.Command()
Dim rs As New ADODB.Recordset()


conn.ConnectionString = connection_Str
conn.Open()
cmd.CommandType = ADODB.CommandTypeEnum.adCmdText
cmd.CommandText = "select * from stream where diwor = " & cbo_productselect.SelectedValue
cmd.ActiveConnection = conn
rs.Open(cmd, , ADODB.CursorTypeEnum.adOpenKeyset, ADODB.LockTypeEnum.adLockOptimistic)

new_stage_date = rs.Fields("exp_stage_comp_date").Value
new_stage_date = get_working_hours_datetime(DateAdd(DateInterval.Hour, durationH, DateAdd(DateInterval.Day, durationD, new_stage_date)))

Do Until isworkingday(new_stage_date)
new_stage_date = DateAdd(DateInterval.Day, 1, new_stage_date)
Loop


Dim cmd1 As New ADODB.Command()
Dim rs1 As New ADODB.Recordset()

cmd1.CommandType = ADODB.CommandTypeEnum.adCmdText

cmd1.CommandText = "SELECT SUM(dbo.Stages.P_duration_H) AS Hours, SUM(dbo.Stages.p_duration_D) AS Days from Product_Stages LEFT OUTER JOIN Stages ON Product_Stages.Stage_diwor = Stages.Diwor RIGHT OUTER JOIN Stream ON Product_Stages.Product_Diwor = Stream.Product_Diwor WHERE (dbo.Product_Stages.Diwor NOT IN (SELECT product_stage_diwor FROM stream_stages WHERE stream_diwor = " & cbo_productselect.SelectedValue & ")) AND (dbo.Stream.Diwor = " & cbo_productselect.SelectedValue & ") GROUP BY Stream.Diwor HAVING(SUM(Stages.P_duration_H) > 0) OR (SUM(Stages.p_duration_D) > 0)"

cmd1.ActiveConnection = conn
rs1.Open(cmd1, , ADODB.CursorTypeEnum.adOpenKeyset, ADODB.LockTypeEnum.adLockOptimistic)

If rs1.EOF = False And rs1.BOF = False Then
new_stream_date = get_working_hours_datetime(DateAdd(DateInterval.Hour, rs1.Fields("Hours").Value, DateAdd(DateInterval.Day, get_totaldays_from_working_days(new_stage_date, rs1.Fields("days").Value), new_stage_date)))
Else
MsgBox("Unable to calculate completion time!", MsgBoxStyle.Exclamation, "Error")
End If

rs.Fields("exp_stream_comp_date").Value = new_stream_date
rs.Fields("exp_stage_comp_date").Value = new_stage_date


rs.Update()

Case_info1.Delayes.Clear()

get_case_info.SelectCommand.CommandText = "SELECT Delayes.Diwor, Delayes.Stage, Delayes.case_diwor, Delayes.Stream_diwor, Delayes.Delayed_Reason, Delayes.Delay_duration_days, Delayes.Delay_duration_Hours, Delayes.comments, Users.Users_name FROM Delayes LEFT OUTER JOIN Users ON Delayes.user_diwor = Users.Diwor WHERE case_diwor = " & IIf(Stream_diwor = 0, case_diwor, "(SELECT MAX(case_diwor) AS case_diwor FROM stream WHERE diwor = " & Stream_diwor & ")")

get_case_info.Fill(Case_info1, "Delayes")

Case_info1.VW_Cases.Clear()

get_case_info.SelectCommand.CommandText = "SELECT * FROM VW_Cases WHERE case_diwor = " & IIf(Stream_diwor = 0, case_diwor, "(SELECT MAX(case_diwor) AS case_diwor FROM stream WHERE diwor = " & Stream_diwor & ")")

get_case_info.Fill(Case_info1, "VW_Cases")

mainfrm.get_todays_tasks()
cbo_productselect.SelectedIndex = currentindex

txt_exp_stream_comp.Text = new_stream_date
txt_exp_stage_comp.Text = new_stage_date
Cursor = Windows.Forms.Cursors.Default



'Just checks to see if a date is on a working day
Public Function isworkingday(ByVal start_date As Date) As Boolean
Dim conn As New ADODB.Connection()
Dim cmd As New ADODB.Command()
Dim rs As New ADODB.Recordset()

'get the public holidays from the database

'checks to see that the day of the week is ok
If Weekday(start_date) <> 1 And Weekday(start_date) <> 7 Then
conn.ConnectionString = "Provider=SQLOLEDB.1;Persist Security Info=False;User ID=sa;Initial Catalog=MortTrak;Data Source=PHEONIX"
conn.Open()
cmd.CommandType = ADODB.CommandTypeEnum.adCmdText
cmd.CommandText = "select * from public_holidays where convert(datetime,hol_Datetime,103) > convert(datetime,'" & start_date & "',103)"
cmd.ActiveConnection = conn
rs.Open(cmd, , ADODB.CursorTypeEnum.adOpenKeyset, ADODB.LockTypeEnum.adLockOptimistic)

'checks to see if the start date is equall to any of the public hols
Do Until rs.EOF
If rs.Fields("hol_Datetime").Value = start_date Then
Return False
Exit Function
End If
rs.MoveNext()
Loop

Return True
Else
Return False
End If

rs.Close()

End Function



Cheers,

Hugh
 
wich antivirus do you have?

Christiaan Baes
Belgium

I just like this --> [Wiggle] [Wiggle]
 
The only idea i have as to which line the error occurrs on is that the information is entered into the database so the error must occur after that.

We use Norton Corprate edition.

Cheers,

Hugh
 
Ok having installed VS.net on a win 2000 workstation i can now tell you that the error occurs somewhere compleatly diffrent than where i thought it did....

Red Text = Line of Error

Private Sub cmd_OK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmd_OK.Click
'This fources them to enter a sensible reason for the delay
If Len(txt_comment.Text) < 20 Then
MsgBox("You must enter a sensible reason for this delay!", MsgBoxStyle.Exclamation, "Error")
Exit Sub
End If

Dim rs As New ADODB.Recordset()
Dim conn As New ADODB.Connection()
Dim cmd As New ADODB.Command()

'open the delayes table for writing too
conn.ConnectionString = connection_string
conn.Open()
cmd.CommandType = ADODB.CommandTypeEnum.adCmdText
cmd.CommandText = "select * from delayes"
cmd.ActiveConnection = conn
rs.Open(cmd, , ADODB.CursorTypeEnum.adOpenKeyset, ADODB.LockTypeEnum.adLockOptimistic)

'Add a new record and record the deatils
rs.AddNew()
rs.Fields("Stage").Value = stage
rs.Fields("case_diwor").Value = case_diwor
rs.Fields("Stream_diwor").Value = Stream_diwor
rs.Fields("Delayed_Reason").Value = cbo_reason.Text
rs.Fields("Delay_duration_days").Value = DateDiff(DateInterval.Day, expected_date, DTPdays.Value)
rs.Fields("Delay_duration_Hours").Value = IIf(txthours.Text = "", 0, txthours.Text)
rs.Fields("comments").Value = txt_comment.Text
rs.Fields("user_diwor").Value = user_diwor
rs.Update()
End Sub


Hope this helps

cheers,

Hugh.
 
I might be crazy, but I think you should rewrite this to use the SqlClient.

Do you have the correct MDAC on the machine that it fails on

What type is Delay_Duration_Days in the DB. DateDiff returns a long. You might need to convert it to an int.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top