Heaven forbid you repeat yourself or provide a code example.... dickhead. It may be wrong but it works the way I want so until I see an example I am going to keep it this way and move on. I will worry about figuring out what exactly you are talking about later.
User 11833437
Posts
-
VB.NET/MS ACCESS Saving today's date produces 2020-02-25 08:28:00.946341400 -
VB.NET/MS ACCESS Saving today's date produces 2020-02-25 08:28:00.946341400If dtPick5.Value.ToString("MM/dd/yyyy" isn't the correct way then can you post an example of how to properly do it?
-
VB.NET/MS ACCESS Saving today's date produces 2020-02-25 08:28:00.946341400Thanks for the answer. I figured it out once I stopped over thinking it. dtPick5.Value.ToString("MM/dd/yyyy" did the trick for both issues.
-
VB.NET/MS ACCESS Saving today's date produces 2020-02-25 08:28:00.946341400It is actually saving it to the table in these formats. How can I get the app to save it in the correct format in the access table? Also, what causes the ..946341400?
-
VB.NET/MS ACCESS Saving today's date produces 2020-02-25 08:28:00.946341400When I save the attendance date from a datetimepicker as a date prior to today's date it records acceptable format but not what I really want. When I select today's date it records a date like this 2020-02-25 08:28:00.946341400. The secondary issue is what I eluded to above. I set the custom format in the form_load to "MM, dd, yyyy" and when I select a date prior to today's date it records the date like this 2020-01-29 08:34:25. Here is the Save Button code
Dim inserted As Integer = 0
For Each row As DataGridViewRow In dgvAttend.Rows
Dim isSelected As Boolean = Convert.ToBoolean(row.Cells("chkbox").Value)
If isSelected Then
Access.AddParam("@DTE", dtPick5.Value)
Access.AddParam("@SID", row.Cells("StudentID").Value)
Access.AddParam("@LN", row.Cells("LastName").Value)
Access.AddParam("@FN", row.Cells("FirstName").Value)Access.ExecQuery("INSERT INTO Attend (TrainDate,StudentID,LastName,FirstName) " & "VALUES (@DTE,@SID,@LN,@FN); ") inserted = inserted + 1 End If Next If inserted > 0 Then MessageBox.Show(String.Format("{0} records inserted.", inserted), "ACJTracker", MessageBoxButtons.OK, MessageBoxIcon.Information) End If
Here is the form load
dtPick5.Format = DateTimePickerFormat.Custom
dtPick5.CustomFormat = "MM, dd, yyyy"
RefreshAttendGrid()Here is the refresh Grid
dtPick5.Format = DateTimePickerFormat.Custom
dtPick5.CustomFormat = "MM, dd, yyyy"' RUN QUERY Access.ExecQuery("SELECT StudentData.StudentID, StudentData.LastName, StudentData.FirstName FROM StudentData ORDER BY StudentID ASC") ' REPORT & ABORT ON ERRORS If NoErrors(True) = False Then Exit Sub dgvAttend.DataSource = Access.DBDT
Does anyone know how I correct these issues?
-
VB.NET/MS ACCESS Display data from queryThis is how I fixed with help from a post on an another site. I do have one question though. If I comment out the first db connection - ConnDB() I get an error. Why does it need two connection to work? It makes a connection in the using command. I had setup a data table from a class I wrote to make a connection and set it up so I declare Private Access As New DBControl at the top and I can add parameters and do my additions and edits that way. I didn't know how to make that work with the existing connection to the Access DBControl so I just did another connection. Not the best but I am a beginner and don't know how to do things with more efficiency yet.
Private Sub tbStudentID2_TextChanged(sender As Object, e As EventArgs) Handles tbStudentID2.TextChanged
mySql = "SELECT DateDiff('d', [DateofRank], [currentDate]) FROM StudentData"
'"SELECT DateDiff('d', [DateofRank], [currentDate]) FROM StudentData WHERE id={id}"
ConnDB()
'myCommand = New OleDbCommand(mySql, myConnection)
'myCommand.ExecuteNonQuery()Dim studentID As Integer If Not Integer.TryParse(tbStudentID2.Text, studentID) Then ' Not a valid ID tbDays.Text = String.Empty Else Using command As New OleDbCommand("SELECT DateDiff('d', \[DateofRank\], \[currentDate\]) FROM StudentData WHERE StudentID = @StudentID", myConnection) command.Parameters.AddWithValue("@StudentID", studentID) ConnDB() Dim days As Object = command.ExecuteScalar() tbDays.Text = If(Convert.IsDBNull(days), String.Empty, Convert.ToString(days)) End Using ' ADD PARAMETERS - ORDER MATTERS !!! Access.AddParam("@TIG", tbDays.Text) Access.AddParam("@SID", tbStudentID2.Text) ' RUN COMMAND Access.ExecQuery("UPDATE StudentData " & "SET TimeinGrade=@TIG " & "WHERE StudentID=@SID") ' REPORT & ABORT ON ERRORS If NoErrors(True) = False Then Exit Sub End If End Sub
-
VB.NET/MS ACCESS Display data from queryThat did the trick. Thank you very much.
-
VB.NET/MS ACCESS Display data from queryI have a textbox that I need to run this query when the value changes for the textbox.
Private Sub tbStudentID2_TextChanged(sender As Object, e As EventArgs) Handles tbStudentID2.TextChanged
mySql = "SELECT DateDiff('d', [DateofRank], [currentDate]) FROM StudentData"
ConnDB()
myCommand = New OleDbCommand(mySql, myConnection)
myCommand.ExecuteNonQuery()
myRead = myCommand.ExecuteReader
Do While myRead.Read = True
tbDays.Text = myRead(0).ToString()
Loop
End Sub86 is display no matter which record I choose. I think it is just retrieving the first record in the in the table. I want to display the number of days since a student has tested by subtracting DateofRank from currentDate. I am open to other ideas on how to achieve this.
-
VB.NET/MS ACCESS Fill column and all entries in the that column with the current dateThat did the trick. I added mycommand.ExecuteNonQuery() and it worked perfect.
-
VB.NET/MS ACCESS Fill column and all entries in the that column with the current datedoesn't this execute the command? myCommand = New OleDbCommand(mySql, myConnection)
-
VB.NET/MS ACCESS Fill column and all entries in the that column with the current dateNo luck. I don't get an error it just doesn't do anything to the column.
-
VB.NET/MS ACCESS Fill column and all entries in the that column with the current dateI want to fill all the entries in a column with the current date so that I can compare it to a DateofTest column and determine how many days since the last test. I think I can figure out the number of days but I can't figure out how to fill the column with the current date.
Private Sub Reports_Shown(sender As Object, e As EventArgs) Handles MyBase.Shown
mySql = "Update Studentdata, SET currentDate = Date()"
ConnDB()
myCommand = New OleDbCommand(mySql, myConnection)End Sub
-
DirecotoryServices - Find all Windows 7 and Windows 10 Computers in DomainI am creating a tool to delete user profiles by age on all windows 7 and windows 10 devices on our domains. I have it working using this filter ("(objectClass=computer)") but want to refine that to only get windows 7 and windows 10 devices because my department manages desktops/laptops not servers. In order to make the tool more efficient and not attempt to connect to devices I don't have admin access to. So I tried this filter... mySearcher.Filter = "(&(objectClass=computer)(operatingSystemVersion=*server*))" my thought was to do something like this if OS IsNot Windows Server 2012 or Windows Server 2008 then do something. I loaded the operatingSystem property but can't get it to display. I have tried it in the datagridview and when that didn't work I just tried to do a consolewriteline and that didn't work either. I want to test my concept before adding the code to use WMI to delete profiles by just displaying the hostname and OS version to make sure it is pulling the information from AD and not giving me servers. Can someone help? Here is the code(I am just working with the v06 domain at the moment):
Dim mySearcher As DirectorySearcher = New DirectorySearcher(enTry)
mySearcher.PropertiesToLoad.Add("dNSHostName")
mySearcher.PropertiesToLoad.Add("operatingSystem")
mySearcher.PropertiesToLoad.Add("operatingSystemVersion")
mySearcher.Filter = "(&(objectClass=computer)(operatingSystem=*server*))" '("(objectClass=computer)")Dim resEnt As SearchResult For Each resEnt In mySearcher.FindAll() Select Case dMain Case "v06" Try hostName = GetProperty(resEnt, "dNSHostName") OSystem = GetProperty(resEnt, "operatingSystem") Dim result1 As Net.NetworkInformation.PingReply = ping.Send(hostName, 1000) If result1.Status = Net.NetworkInformation.IPStatus.Success Then Dim row2 As String() = New String() {hostName, "N/A", OSystem} dgvLocal.Rows.Add(row2) Else My.Computer.FileSystem.WriteAllText("C:\\ExodusErrorLog.txt", hostName & " - Device is not pingable!" & vbCrLf & vbCrLf, True) End If Catch ex As Exception My.Computer.FileSystem.WriteAllText("C:\\ExodusErrorLog.txt", hostName & " - " & ex.Message & vbCrLf & vbCrLf, True)
-
How to compare 2 different text file lines and then process information if a match is in both file lines - Please helpThanks for the help. It worked perfectly.
-
How to compare 2 different text file lines and then process information if a match is in both file lines - Please helpThat totally makes sense. I just didn't change sites to site1 in all instances. I know that BEC will never equal BIR, R03sites has numerous sites and what I wanted to do was loop through all the sites in R03sites and write an error to the console on non-matching items and process the match. I just don't know how to do what I want a better way. I am sure you could make the loop stop when it finds a match but I don't know how to do it yet. I am still new to programming and have never worked with 2 text files at once, I have mostly just used text files to read computer names or ip addresses and then do something straightforward with it or write text to a log file. I appreciate the help. I left work but will give this a try tomorrow.
-
How to compare 2 different text file lines and then process information if a match is in both file lines - Please helpThis line If Trim(Sites) = Trim(strSiteCode) Then is supposed to find the matching entry in both Sites and R03sites files ie. BEC , BEC and then process the shortcut creation and write to console if no match is found. Then loop through the rest of the file. I would like to learn how to make it stop when it finds the match but I can't even make it work the way I need it to yet.
-
How to compare 2 different text file lines and then process information if a match is in both file lines - Please helpThanks for the response. You're suggestion helped but the if then statement still doesn't work. Also, Sites data never changes each computer at each site has a Sites data file with the appropriate entry. It only has one line in the file and it is formatted like this: BEC,BEC. Here is the new code:
Do
line = sr.ReadLine()
Console.WriteLine("line = " & line)
Console.WriteLine("Start processing loop")
If line IsNot Nothing Then
arrStr = Split(line, ",")
siteArr = Split(Sites, ",")
Site1 = siteArr(0)
If arrStr.Length >= 3 Then
strSiteCode = arrStr(0)
strVistaFQDN = arrStr(1)
strPort = arrStr(2)
Console.WriteLine(Trim(Site1) & " , " & Trim(strSiteCode))
Console.WriteLine("s=" & strVistaFQDN & " p=" & strPort)
Console.WriteLine("Array populated... Enter if then statement")
If Trim(Sites) = Trim(strSiteCode) Then
'Console.WriteLine(Trim(Sites) & " , " & Trim(strSiteCode))
'Console.WriteLine("s=" & strVistaFQDN & " p=" & strPort)
Console.WriteLine("Successfully processed!")
Exit Do
Else
Console.WriteLine("Error: No Matching Information in the Sitecode and R03sites files!")
End If
End If
End If
Loop Until line Is NothingHere is the output: \Dell>bcmass line = BEC,test.beckley.com,19233 Start processing loop BEC , BEC s=test.beckley.com p=19233 Array populated... Enter if then statement Error: No Matching Information in the Sitecode and R03sites files! line = BIR,test.birmingham.com,19230 Start processing loop BEC , BIR s=test.birmingham.com p=19230 Array populated... Enter if then statement Error: No Matching Information in the Sitecode and R03sites files! line = Start processing loop
-
How to compare 2 different text file lines and then process information if a match is in both file lines - Please helpThanks for the response. I made the suggested changes and am still having issues. This is what I have now:
Sub Main()
'--------------------------------------------------------------------------------------------------------
'Declare Variables
Dim strSiteCode
Dim strVistaFQDN
Dim strPort
Dim arrStr
Dim Sites As String = My.Computer.FileSystem.ReadAllText("c:\dell\Sites2.txt")
'--------------------------------------------------------------------------------------------------------
'Start processingUsing sr As New StreamReader("c:\\dell\\R03Sites3.csv") Dim line As String ' Read and display lines from the file until the end of ' the file is reached. Do line = sr.ReadLine() Console.WriteLine("line = " & line) Console.WriteLine("Start processing loop") If line IsNot Nothing Then arrStr = Split(line, ",") If arrStr.Length >= 3 Then strSiteCode = arrStr(0) strVistaFQDN = arrStr(1) strPort = arrStr(2) Console.WriteLine(Trim(Sites) & " , " & Trim(strSiteCode)) Console.WriteLine("s=" & strVistaFQDN & " p=" & strPort) Console.WriteLine("Array populated... Enter if then statement") If Trim(Sites) = Trim(strSiteCode) Then 'Console.WriteLine(Trim(Sites) & " , " & Trim(strSiteCode)) 'Console.WriteLine("s=" & strVistaFQDN & " p=" & strPort) Console.WriteLine("Successfully processed!") Exit Do Else Console.WriteLine("Error: No Matching Information in the Sitecode and R03sites files!") End If End If End If Loop Until line Is Nothing End Using End Sub
Here is the output (I cut the R03 file down to 2 entries): C:\Dell>bcmass line = BEC,test.beckley.com,19233 Start processing loop BEC,BEC , BEC s=test.beckley.com p=19233 Array populated... Enter if then statement Error: No Matching Information in the Sitecode and R03sites files! line = BIR,test.birmingham.com,19230 Start processing loop BEC,BEC ,
-
How to compare 2 different text file lines and then process information if a match is in both file lines - Please helpI am attempting to build a command line tool that will create shortcuts for an application on the start menu and desktop. I have existing code that I use elsewhere to create the shortcuts. However, the program looks at two different files one file has only the site code and the other has the other information needed to created the shortcut by site for a whole region. The idea is to go through both lines until it finds the 3 letter abbreviation for the site in both files. For example one file only contains BEC (sites2.txt - the city) and the other file (R03Sites2.csv - Region) contains 50 lines with a different cities and all the pertinent information.
Sub Main()
'--------------------------------------------------------------------------------------------------------
'Declare Variables
Dim strSiteCode
Dim strVistaFQDN
Dim strPort
Dim arrStr'-------------------------------------------------------------------------------------------------------- 'Start processing Using sr As New StreamReader("c:\\dell\\R03Sites2.csv") Dim line As String ' Read and display lines from the file until the end of ' the file is reached. Do line = sr.ReadLine() Dim Sites As String = My.Computer.FileSystem.ReadAllText("c:\\dell\\Sites2.txt") If Not (line Is Nothing) Then Console.WriteLine("Start processing loop") arrStr = Split(sr.ReadLine, ",") strSiteCode = arrStr(0) strVistaFQDN = arrStr(1) strPort = arrStr(2) Console.WriteLine("Array populated... Enter if then statement") If Trim(Sites) = Trim(strSiteCode) Then Console.WriteLine(Trim(Sites) & " , " & Trim(strSiteCode)) Console.WriteLine("s=" & strVistaFQDN & " p=" & strPort) 'build shorcuts here. Code to build shortcuts is working correctly when ran 'statically but it never finds a match so it always moves to the else and writes 'Console.WriteLine("Error: No Matching Information in the Sites and R03sites files!") 'There is only 1 line is Sites and an array is created for the data in R03sites. 'My intention is to match the line in Sites to the portion of the a
-
Visual Basic program to recursively take ownership of a folder and all its sub-contentsMika thank you so much for helping with this tool. Your suggestion was the difference. I was able to take ownership of only the parent directory at first. So I decided to try and implement recursive permissions first. I got that to work right away. So I put that piece of code at the of the same sub routine that I called the change of ownership and it worked on the first try after permissions were applied. I had ownership of every sub-directory and full control permissions. I have a few more tasks to implement but this was the major obstacle. Once again thank you very much.:thumbsup: Here is the code for the whole thing. Some of it is generated by visual studio express. I also used several examples I found on the internet and molded them into what I needed. 'CSC TAKE OWNERSHIP AND DATA RECOVERY TOOL 'This tools will recursively take ownership of the c:\windows\csc folder. Then copy the affected users 'folder and backup their user profile to a network share then remove all the folders under c:\windows\csc\v2.06\namespace and delete all user profiles. Imports System.IO Imports System Imports System.Drawing Imports System.Windows.Forms Imports System.Security.AccessControl Public Class Form1 Inherits System.Windows.Forms.Form #Region " Windows Form Designer generated code " Public Sub New() MyBase.New() InitializeComponent() End Sub Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) If disposing Then If Not (components Is Nothing) Then components.Dispose() End If End If MyBase.Dispose(disposing) End Sub Private components As System.ComponentModel.IContainer Friend WithEvents Label1 As System.Windows.Forms.Label Friend WithEvents FolderBrowserDialog1 As System.Windows.Forms.FolderBrowserDialog Friend WithEvents folderName As System.Windows.Forms.TextBox Friend WithEvents tbUserName As System.Windows.Forms.TextBox Friend WithEvents bnBrowseFolder As System.Windows.Forms.Button Friend WithEvents bnDoit As System.Windows.Forms.Button Friend WithEvents bnQuit As System.Windows.Forms.Button Friend WithEvents Label2 As Label Friend WithEvents PictureBox1 As PictureBox Friend WithEvents Label3 As Label Friend WithEvents LinkLabel1 As LinkLabel Friend WithEvents Label4 As System.Windows.Forms.Label Private Sub InitializeComponent() Dim resources As Sys