i have problem whith store datetime value to database table the my system date formate is dd/mm/yyyy the date is store in mm/dd/yyyy formate what is the problem
my code is as follow
Public Function AddIndent(ByVal cnSQL As SqlConnection, ByVal ds As SqlTransaction, ByVal strIndentNo As String, ByVal dteIndentDate As Date, ByVal strIndentForDep t As String, ByVal strlocation As String, _
ByVal strworkDept As String, ByVal strjob As String, ByVal strnatureofexpe nse As String, ByVal strCategory As String, _
ByVal strdesc As String, ByVal strIL As String, ByVal blnConfirm As Boolean, ByVal blnCancel As Boolean, _
ByVal blnOrdered As Boolean, ByVal blnClosed As Boolean, ByVal strMakerId As String) As Boolean
Dim cmSQL As SqlCommand
Dim strSQL As String
Dim intRowsAffected As Integer
Try
Dim SQLConfirm As Integer
Dim SQLCancel As Integer
Dim SQLOrdered As Integer
Dim SQLClosed As Integer
SQLConfirm = IIf((blnConfirm ), 1, 0)
SQLCancel = IIf((blnCancel) , 1, 0)
SQLOrdered = IIf((blnOrdered ), 1, 0)
SQLClosed = IIf((blnClosed) , 1, 0)
' Build Insert statement to insert new product into the products table
strSQL = "INSERT INTO workindents(Wor kIndentNo,WorkI ndentDate,Origi nDeptName,WorkL ocation,WorkDep tName,Job,Natur eofExpense,work Category,WorkDe scription,Impor tLocal,ConfirmF lag," & _
"CancelFlag,ord eredflag,CloseF lag,MakerID,dtm Created) Values('" & strIndentNo & " ',cast('" & dteIndentDate & "' as datetime),'" & strIndentForDep t & _
"','" & strlocation & "','" & strworkDept & "','" & strjob & "','" & strnatureofexpe nse & "','" & strCategory & "','" & strdesc & "','" & strIL & _
"'," & SQLConfirm & "," & SQLCancel & "," & SQLOrdered & "," & SQLClosed & _
",'" & strMakerId & "','" & Today & "')"
'cnSQL = New SqlConnection(s trconn)
'cnSQL.Open()
cmSQL = New SqlCommand(strS QL, cnSQL, ds)
cmSQL.ExecuteNo nQuery()
' Close and Clean up objects
'cnSQL.Close()
cmSQL.Dispose()
'cnSQL.Dispose( )
AddIndent = True
' Refresh Product List
'PopulateProduc tList()
'FindProductByN ame(lstProducts , ProductName)
Catch Exp As SqlException
MsgBox(Exp.Mess age, MsgBoxStyle.Cri tical, "SQL Error")
AddIndent = False
Catch Exp As Exception
MsgBox(Exp.Mess age, MsgBoxStyle.Cri tical, "General Error")
AddIndent = False
End Try
End Function
my code is as follow
Public Function AddIndent(ByVal cnSQL As SqlConnection, ByVal ds As SqlTransaction, ByVal strIndentNo As String, ByVal dteIndentDate As Date, ByVal strIndentForDep t As String, ByVal strlocation As String, _
ByVal strworkDept As String, ByVal strjob As String, ByVal strnatureofexpe nse As String, ByVal strCategory As String, _
ByVal strdesc As String, ByVal strIL As String, ByVal blnConfirm As Boolean, ByVal blnCancel As Boolean, _
ByVal blnOrdered As Boolean, ByVal blnClosed As Boolean, ByVal strMakerId As String) As Boolean
Dim cmSQL As SqlCommand
Dim strSQL As String
Dim intRowsAffected As Integer
Try
Dim SQLConfirm As Integer
Dim SQLCancel As Integer
Dim SQLOrdered As Integer
Dim SQLClosed As Integer
SQLConfirm = IIf((blnConfirm ), 1, 0)
SQLCancel = IIf((blnCancel) , 1, 0)
SQLOrdered = IIf((blnOrdered ), 1, 0)
SQLClosed = IIf((blnClosed) , 1, 0)
' Build Insert statement to insert new product into the products table
strSQL = "INSERT INTO workindents(Wor kIndentNo,WorkI ndentDate,Origi nDeptName,WorkL ocation,WorkDep tName,Job,Natur eofExpense,work Category,WorkDe scription,Impor tLocal,ConfirmF lag," & _
"CancelFlag,ord eredflag,CloseF lag,MakerID,dtm Created) Values('" & strIndentNo & " ',cast('" & dteIndentDate & "' as datetime),'" & strIndentForDep t & _
"','" & strlocation & "','" & strworkDept & "','" & strjob & "','" & strnatureofexpe nse & "','" & strCategory & "','" & strdesc & "','" & strIL & _
"'," & SQLConfirm & "," & SQLCancel & "," & SQLOrdered & "," & SQLClosed & _
",'" & strMakerId & "','" & Today & "')"
'cnSQL = New SqlConnection(s trconn)
'cnSQL.Open()
cmSQL = New SqlCommand(strS QL, cnSQL, ds)
cmSQL.ExecuteNo nQuery()
' Close and Clean up objects
'cnSQL.Close()
cmSQL.Dispose()
'cnSQL.Dispose( )
AddIndent = True
' Refresh Product List
'PopulateProduc tList()
'FindProductByN ame(lstProducts , ProductName)
Catch Exp As SqlException
MsgBox(Exp.Mess age, MsgBoxStyle.Cri tical, "SQL Error")
AddIndent = False
Catch Exp As Exception
MsgBox(Exp.Mess age, MsgBoxStyle.Cri tical, "General Error")
AddIndent = False
End Try
End Function
Comment