This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import arcpy | |
import numpy | |
input = r"C:\Work\Waypoints.shp" | |
arr = arcpy.da.FeatureClassToNumPyArray(input, ('ident', 'Latitude', 'Longitude')) | |
for row in arr: | |
ident = row["ident"] | |
lat = row["Latitude"] | |
lon = row["Longitude"] | |
sql = "INSERT INTO MyTable(WaypointName,Lat,Lon) VALUES('" + str(ident) + "'," + str(lat) + "," + str(lon) + ");" | |
print sql |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
' this button allows the user to switch between read only and editing | |
Private Sub ToggleReadOnlyButton_Click() | |
SetFormEditability | |
End Sub | |
' you can only toggle the form's allowedits property is it is clean so if the | |
' form is dirty then ask if it's ok to flush changes | |
Private Sub SetFormEditability() | |
If Me.Dirty = True Then | |
If MsgBox("Save changes?", vbYesNo, "Confirm") = vbYes Then |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Private Sub VitalSignDataGrid_CellClick(sender As System.Object, e As System.Windows.Forms.DataGridViewCellEventArgs) Handles VitalSignsDataGridView.CellClick | |
Me.LogEntryRichTextBox.DataBindings.Add("Text", Me.WorkLogDataGridView.DataSource, "LogEntry") | |
End Sub |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'adapted from https://msdn.microsoft.com/library/y8c0cxey%28v=vs.100%29.aspx | |
Dim MyDataset As New DataSet | |
Private Sub WorkLogForm_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load | |
'set up the master data table | |
Dim VitalSignsSqlConnection As New SqlConnection(My.Settings.ConnectionString) | |
Dim VitalSignsDataAdapter As New SqlDataAdapter("SELECT [Acronym],[NetworkVSName] as VitalSign,[VSID] FROM vwVitalSignsMatrix", VitalSignsSqlConnection) | |
VitalSignsSqlConnection.Open() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pyodbc | |
connection = pyodbc.connect(r'Driver={SQL Server};Server=MyServerName;Database=MyDatabase;') | |
cursor = connection.cursor() | |
cursor.execute("SELECT * FROM MyTable") | |
row = cursor.fetchone() | |
if row: | |
print row | |
connection.close() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- adapted from http://stackoverflow.com/questions/24259914/create-geography-line-from-points-in-t-sql | |
DECLARE @BuildString NVARCHAR(MAX) | |
SELECT @BuildString = COALESCE(@BuildString + ',', '') + CAST(Location.Long AS NVARCHAR(50)) + ' ' + CAST(Location.Lat AS NVARCHAR(50)) | |
FROM dbo.Locations | |
WHERE SurveyID = '20120103130303-533424019.813538' | |
ORDER BY CaptureDate | |
SET @BuildString = 'LINESTRING(' + @BuildString + ')'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Private Sub SurveyFlightChooserComboBox_AfterUpdate() | |
On Error GoTo Error | |
'move to the selected record | |
Me.RecordsetClone.FindFirst "[FlightID] = '" & Me![SurveyFlightChooserComboBox] & "'" | |
Me.Bookmark = Me.RecordsetClone.Bookmark | |
Exit Sub | |
Error: | |
MsgBox Err.Description & " (SurveyFlightChooserComboBox_AfterUpdate)" | |
Exit Sub | |
End Sub |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'calculate the difference in minutes between two time strings in 4 character 24 hour time format | |
StartTime24Hr = Left(StartTime24Hr, 2) & ":" & Right(StartTime24Hr, 2) | |
EndTime24Hr = Left(EndTime24Hr, 2) & ":" & Right(EndTime24Hr, 2) | |
TimeString = DateDiff("n", StartTime24Hr, EndTime24Hr) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
' this sometimes solves the sticky serverfilter problem | |
Private Sub Form_Unload(Cancel As Integer) | |
Me.ServerFilter = "" | |
Me.Refresh | |
End Sub |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
I encountered a bug in Microsoft Access 2010 where I would open a form in split view or datasheet view, | |
rearrange the order of columns, save the form, re-open the form and the column order would not reflect | |
the columns order I had tried to save. | |
Solution: | |
1. Open the form in datasheet view | |
2. Re-order the columns | |
3. Right-click a column header and click Unhide fields | |
4. Close the Unhide fields dialog | |
5. Save the form and re-open |