我试图在一个滚动的12个月期间返回一些结果,例如:
MONTH IN OUT
January 210 191
February 200 111
March 132 141
April 112 141
May 191 188
etc...
Run Code Online (Sandbox Code Playgroud)
如何在日期范围内展开结果,使用月份名称填充第一列?
在MSSQL中它将是这样的:
SELECT COUNT(problem.problem_type = 'IN') AS IN,
COUNT(problem.problem_type = 'OUT') AS OUT,
DATEPART(year, DateTime) as Year,
DATEPART(month, DateTime) as Month
FROM problem
WHERE (DateTime >= dbo.FormatDateTime('2010-01-01'))
AND
(DateTime < dbo.FormatDateTime('2010-01-31'))
GROUP BY DATEPART(year, DateTime),
DATEPART(month, DateTime);
Run Code Online (Sandbox Code Playgroud)
但这是针对Oracle数据库的,因此DATEPART和DateTime不可用.
我的问题表大致是:
problem_ID Problem_type IN_Date OUT_Date
1 IN 2010-01-23 16:34:29.0 2010-02-29 13:06:28.0
2 IN 2010-01-27 12:34:29.0 2010-01-29 12:01:28.0
3 OUT 2010-02-13 13:24:29.0 2010-09-29 …Run Code Online (Sandbox Code Playgroud) 我正在使用以下查询来使用全文搜索从表中返回结果.在SQL2000中,只能搜索表中的一列或所有列.在SQL 2008中有可能吗?
我想搜索两个表,问题和解决方案(索引和在同一个表中):
DECLARE @topRank int set @topRank=(SELECT MAX(RANK)
FROM FREETEXTTABLE([Support_Calls], Problem, 'test', 1))
SELECT [ID] AS [Call No],Company_Name, Problem, Solution, CONVERT(VARCHAR(20),CAST((CAST(ftt.RANK as DECIMAL)/@topRank * 100) AS DECIMAL(13,0))) + '%' as Match
FROM [Support_Calls] INNER JOIN FREETEXTTABLE([Support_Calls], Problem, 'test') as ftt ON ftt.[KEY]=[ID] ORDER BY ftt.RANK DESC;
Run Code Online (Sandbox Code Playgroud)
从我所看到的FREETEXTTABLE不接受多个列?
如何将matchpercent的结果舍入到两位小数(%)?我正在使用以下内容返回一些结果:
DECLARE @topRank int
set @topRank=(SELECT MAX(RANK) FROM
FREETEXTTABLE(titles, notes, 'recipe cuisine', 1))
SELECT
ftt.RANK,
(CAST(ftt.RANK as DECIMAL)/@topRank) as matchpercent, --Round this
titles.title_id,
titles.title
FROM Titles
INNER JOIN
FREETEXTTABLE(titles, notes, 'recipe cuisine') as ftt
ON
ftt.[KEY]=titles.title_id
ORDER BY ftt.RANK DESC
Run Code Online (Sandbox Code Playgroud) 我正在尝试将一些代码移动到某些类文件中以清理我的代码.我遇到问题的一个方面是报告执行任务的对象和进度条之间事件的进度.
我想事件函数必须放在新类中,但是他们还需要更新调用表单上的进度条?class\object可以代替事件处理程序返回更新吗?
目前表单包含所有代码:
Function DoRestore(ByVal SQLServer As String, ByVal BackupFilePath As String, ByVal DatabaseName As String)
Dim Server As Server = New Server(SQLServer)
Server.ConnectionContext.ApplicationName = Application.ProductName
Dim res As Restore = New Restore()
Dim dt As DataTable
res.Devices.AddDevice(BackupFilePath, DeviceType.File)
dt = res.ReadFileList(Server)
res.Database = DatabaseName
res.PercentCompleteNotification = 1
AddHandler res.PercentComplete, AddressOf RestoreProgressEventHandler
AddHandler res.Complete, AddressOf RestoreCompleteEventHandler
res.SqlRestoreAsync(Server)
While res.AsyncStatus.ExecutionStatus = ExecutionStatus.InProgress
Application.DoEvents()
End While
End Function
Private Function RestoreProgressEventHandler(ByVal sender As Object, ByVal e As PercentCompleteEventArgs)
'Update progress bar (e.Percent) …Run Code Online (Sandbox Code Playgroud) 我正在使用以下代码从PictureBox打印图像.除了缩小图像(如果它们大于打印页面)以外,所有这些都很有效.我有什么方法可以做到这一点吗?
截图,纸张边界外的大图:
http://a.yfrog.com/img46/63/problemsh.png http://a.yfrog.com/img46/63/problemsh.png
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
AddHandler PrintDocument1.PrintPage, AddressOf OnPrintPage
With PageSetupDialog1
.Document = PrintDocument1
.PageSettings = PrintDocument1.DefaultPageSettings
If PictureEdit1.Image.Height >= PictureEdit1.Image.Width Then
PageSetupDialog1.PageSettings.Landscape = False
Else
PageSetupDialog1.PageSettings.Landscape = True
End If
End With
PrintDialog1.UseEXDialog = True
PrintDialog1.Document = PrintDocument1
If PrintDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
PrintPreviewDialog1.Document = PrintDocument1
If PrintPreviewDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
PrintDocument1.DefaultPageSettings = PageSetupDialog1.PageSettings
PrintDocument1.Print()
End If
End If
End Sub
Private Sub OnPrintPage(ByVal sender As Object, ByVal …Run Code Online (Sandbox Code Playgroud) 我正在尝试将一组四个单选按钮添加到表单中.还有其他单选按钮,所以我将它们放在Panel上进行分组.但是使用下面我只是将面板添加到没有单选按钮的表单中...我在这里做错了吗?
Dim arrRButton(3) As RadioButton
arrRButton(0) = New RadioButton
arrRButton(1) = New RadioButton
arrRButton(2) = New RadioButton
arrRButton(3) = New RadioButton
With arrRButton(0)
.AutoSize = True
.Checked = True
.Location = New System.Drawing.Point(77, 139)
.Name = "RadioButton5"
.Size = New System.Drawing.Size(55, 17)
.TabIndex = 48
.TabStop = True
.Text = "NEAR"
.UseVisualStyleBackColor = True
End With
'.... etc
'Panel2
Dim Panel2 As New Panel
With Panel2
.Controls.Add(arrRButton(0))
.Controls.Add(arrRButton(1))
.Controls.Add(arrRButton(2))
.Controls.Add(arrRButton(3))
.Location = New System.Drawing.Point(61, 130)
.Name = "Panel2"
.Size = …Run Code Online (Sandbox Code Playgroud) 我正在创建一个应用程序,如果在应用程序数据库中的表中添加了新行,则会通知用户.是否最好为此创建一个触发器,或者直接从应用程序每隔几秒检查一次?思考?
在我的DataGridView中将鼠标悬停在一行上时,我显示了一个工具提示 - 除了工具提示在显示它的行上闪烁时,工作效果很好.
Private Sub DataGridView1_MouseHover(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles DataGridView1.MouseMove
Dim hit As DataGridView.HitTestInfo = DataGridView1.HitTest(e.X, e.Y)
If hit.Type = DataGridViewHitTestType.Cell Then
If Not hit Is m_HoveredItem Then
Me.ToolTip2.Hide(Me.DataGridView1)
m_HoveredItem = hit
If hit Is Nothing Then
Me.ToolTip2.SetToolTip(Me.DataGridView1, "")
Else
'Me.ToolTip2.SetToolTip(Me.DataGridView1, ConnectedUsers(Me.DataGridView1.Rows(hit.RowIndex).Cells("Database").Value, Instance))
Me.ToolTip2.Show(ConnectedUsers(Me.DataGridView1.Rows(hit.RowIndex).Cells("Database").Value, Instance), DataGridView1, e.X, e.Y)
End If
End If
End If
End Sub
Run Code Online (Sandbox Code Playgroud)
我使用类似的ListView方法,效果很好:
Private m_HoveredItem As ListViewItem
Private Sub lv_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs)
Dim lvi As ListViewItem …Run Code Online (Sandbox Code Playgroud) 我正在使用附加的代码在现有集合下添加另一行\控件行(单击标签时).可能会添加相当多的行,因此我不得不使用计数器(i)多次重复代码以跟踪...
这样做有更好的方法吗?
Private Sub Label10_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles LblExpandSearch.Click
If i = 0 Then
'TextBox7
'
Dim TextBox7 As New TextBox
TextBox7.Size = New Size(302, 20)
TextBox7.Name = "TextBox7"
TextBox7.Location = New System.Drawing.Point(60, 135)
Me.ExpAdvancedSearch.Controls.Add(TextBox7)
'RadioButton5
'
Dim RadioButton5 As New RadioButton
RadioButton5.AutoSize = True
RadioButton5.Checked = True
RadioButton5.Location = New System.Drawing.Point(77, 112)
RadioButton5.Name = "RadioButton5"
RadioButton5.Size = New System.Drawing.Size(55, 17)
RadioButton5.TabIndex = 48
RadioButton5.TabStop = True
RadioButton5.Text = "NEAR"
RadioButton5.UseVisualStyleBackColor = True
ElseIf i …Run Code Online (Sandbox Code Playgroud) 我有一个具有FTP权限的字符串 - "LRSDCWAN"如果字符串包含相关字符,是否有更有效的检查相关CheckBox的方法?
If reader.Item("home_perm").Contains("L") Then
CBoxList.Checked = True
End If
If reader.Item("home_perm").Contains("R") Then
CBoxRead.Checked = True
End If
If reader.Item("home_perm").Contains("S") Then
CBoxSubDir.Checked = True
End If
If reader.Item("home_perm").Contains("D") Then
CBoxDelete.Checked = True
End If
If reader.Item("home_perm").Contains("C") Then
CBoxCreate.Checked = True
End If
If reader.Item("home_perm").Contains("W") Then
CBoxWrite.Checked = True
End If
If reader.Item("home_perm").Contains("A") Then
CBoxAppend.Checked = True
End If
If reader.Item("home_perm").Contains("N") Then
CBoxRename.Checked = True
End If
Run Code Online (Sandbox Code Playgroud)
谢谢.
我正在使用WebBrowser来打印一些HTML数据,除了在加载完成事件中调用的打印预览外,一切都很好 - 它在左上角打开一个非常小的窗口,我可以做些什么来改善这个?
Private Sub BtnPrint_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnPrint.Click
Dim webBrowserForPrinting As New WebBrowser()
AddHandler webBrowserForPrinting.DocumentCompleted, New WebBrowserDocumentCompletedEventHandler(AddressOf PrintDocument)
webBrowserForPrinting.DocumentText = HTMLTEST()
End Sub
Private Sub PrintDocument(ByVal sender As Object, ByVal e As WebBrowserDocumentCompletedEventArgs)
Dim webBrowserForPrinting As WebBrowser = CType(sender, WebBrowser)
webBrowserForPrinting.ShowPrintPreviewDialog()
End Sub
Run Code Online (Sandbox Code Playgroud) 我正在使用 DataGridView 从 DataTable 加载数据。此 DataGridView 位于选项卡 (Forms.TabPage) 上。单击此选项卡时,无论是否加载数据,数据网格都需要一两秒钟从上到下绘制。
单击选项卡时,我可以做些什么来加速绘图\渲染?
我不认为 DGV 的实际人口会导致这种情况,因为它是在表单加载过程中填充的,因此当单击选项卡时,它会加载它显示的几行 (20 - 30)。
Using cn As New SqlConnection(connectionString)
Using cmd As SqlCommand = cn.CreateCommand()
cmd.CommandType = System.Data.CommandType.Text
cmd.CommandText = _
" SELECT [finish_time], [file_name], [transfer_status]" & _
" FROM dbo.[transfer_log]"
cmd.Notification = Nothing
cn.Open()
Dim columnSpec = New DataColumn()
With columnSpec
.DataType = GetType(System.String)
.ColumnName = "ClmFinishTime"
End With
Datatable1.Columns.Add(columnSpec)
Dim columnSpec2 = New DataColumn()
With columnSpec2
.DataType = GetType(System.String)
.ColumnName = "ClmFilename"
End With
Datatable1.Columns.Add(columnSpec2)
Dim …Run Code Online (Sandbox Code Playgroud)