Hello everyone,
can anyone plz help me in solving the problem i am facing....
i have
vb.net code working fine with dotnet1.1 .now im moving my this code to dotnet2.0...and there i found error in my following code while communication with
SQL Server..........
the erroe was like this
"string to date conversion is not valid"
The code is here.......
Public Function LoginUser() As Long
Dim HostName As String = System.Net.Dns.GetHostName
Dim HostIP As String = GetIPAddress()
Dim cn As New SqlConnection(connString)
Dim cmd As New SqlCommand
Try
cmd.Connection = cn
cmd.CommandText = "INSERT INTO [Login_History] (User_Id,Date_In,Store_Id,Host_Name,Host_IP) VALUES (" & Users.CurrentlyLoggedInUser.UserID & ",'" &
CDate(Format(DateTime.Now.ToString, "yyyy/MM/dd [H:mm:ss]")) & "'," & Users.CurrentStoreID & ",'" & HostName & "','" & HostIP & "')"
cn.Open()
cmd.ExecuteNonQuery()
cmd.CommandText = "SELECT @@IDENTITY"
LoginUser = CheckLongForDBNull(cmd.ExecuteScalar)
Catch x As Exception
MsgBox(x.ToString & " " & x.StackTrace)
Finally
cn.Close()
cmd.Dispose()
cn.Dispose()
End Try
End Function