|
Chandra,
I double checked it and the mapping is correct.
|
|
|
|
|
You are calling the routine but the routine does not execute the SqlCommand.
It just sets it up and provides values for the parameters.
You need and _CMD.ExecuteNonQuery.
BTW using _CMD as a variable name is a bit strange in VB - smacks of C++ with a mix of _ for class level variables and all upper case for constants. But that's a matter of taste.
Regards
David R
---------------------------------------------------------------
"Every program eventually becomes rococo, and then rubble." - Alan Perlis
The only valid measurement of code quality: WTFs/minute.
|
|
|
|
|
PS Meant to say you could wrap the connection stuff in a try...finally...end try block with the close in the finally part. Note no catch - if an exception occurs it will be thrown but the close will still be done.
VB also has the using...end using construct to do this automatically so you don't need the close.
Regards
David R
---------------------------------------------------------------
"Every program eventually becomes rococo, and then rubble." - Alan Perlis
The only valid measurement of code quality: WTFs/minute.
|
|
|
|
|
David,
I have now added this to my code:
_CMD.ExecuteNonQuery()
and I get the error: Incorrect Syntax near the keyword BY.
|
|
|
|
|
So your SQL statement is wrong.
There is a payperiodenddate with a @ missing.
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|
Luc,
Thank you for noticing that. I have added that and now get the error:
'Must declare the variable for @payperiodenddateGROUP'
|
|
|
|
|
another obvious mistake. Check your SQL statement once more. The error message is very clear. Build up some confidence, and use this site for the hard stuff.
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|
Luc,
I've verified that the sql query works and that the variables are being both declared and passed to my sub.
|
|
|
|
|
Look at the SQL - it seems to me there are missing spaces before keywords.
As antip always make sure there is one e.g.instead of "GROUP...." type " GROUP..."
Regards
David R
---------------------------------------------------------------
"Every program eventually becomes rococo, and then rubble." - Alan Perlis
The only valid measurement of code quality: WTFs/minute.
|
|
|
|
|
hi all, im trying to register a ocx control tabctl32 on a windows 7 machines to run vb6.
if i run this command regsvr32 command, it finishes succesfully but if i go on a tab its still returnig the error message that the control is missing. im running as an administrator.
is there anything else i must do.
Regards
|
|
|
|
|
It's probably missing a dependancy. Google for "Dependancy Walker" and use that to open the tabctl32.ocx file and it'll show you the .DLL's it's trying to load.
|
|
|
|
|
Is there some way to stop Windows from hiding a notifyIcon? I'm not afraid of API calls if they're necessary. We're developing a program that will minimize to the tray and it's important that it's icon is always visible (it updates the user by changing the icon as events occur).
I'm sure there's a way, since the Windows icons do it.
Thanks,
Ray Phillips
Jeff Computers
StudyX.com
|
|
|
|
|
NotifyIcons do what you tell them to do, they don't just disappear. In fact you have to add extra code (a call to Dispose) to make sure they disappear when your app exits. If your NI disappears inadvertently it tells me it is being garbage collected, which implies you didn't give it enough scope. Is it a member of your form class? It should not be a local variable!
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|
What I meant was, if the user has auto hiding of their notify icons turned on, the icon gets "hidden" (where you have to push the arrow to see the "hidden" icons). We need ours to always be visible. It's not that the icon is disappearing, per se; it's being hidden until the user clicks that arrow.
Sorry for the confusion
-Ray
Jeff Computers
StudyX.com
|
|
|
|
|
You must be using Windows 7 then. I expect the official stance will be: the behavior of NotifyIcons is a user's choice, and should not be set by the app; the user can:
- have inactive icons hidden (the default?);
- have all icons show;
- choose for each individual icon (the choice persists, seems associated with the EXE file, not the process).
I am unaware of any code that would allow an app to change its own NotifyIcon behavior.
However, there is this article that may interest you: WPF NotifyIcon[^].
PS: the Windows icons that always show are "system icons", they are handled differently; I don't expect the NotifyIcon class maps to them at all.
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|
XP allows the notify icons to be hidden as well. There is a setting in XP to allow you to change an icon to be always hide, or always show. So even if you were to programmatically change it, you might have to try to detect if the user changed it manually and to change it back.
Steve Maier
|
|
|
|
|
Ho hum... that's what I was afraid of. lol. Thanks for the replies. Looks like I'll have to find a "creative solution".
The Code Project and it's community ROCKS!
-Ray
Jeff Computers
StudyX.com
|
|
|
|
|
|
LCARS x32 wrote: Looks like I'll have to find a "creative solution".
Most users would prefer that you didn't. Let the user decide whether he wants the icon hidden or not. It is not for applications (and their designers) to tell users how their desktop should be managed.
I must get a clever new signature for 2011.
|
|
|
|
|
How about a deskband?
I are Troll
|
|
|
|
|
How to approach inserting data to sql by batch number?
i have textbox and button.
if user type in textbox, let say.
'First Batch<br />
4500110 ;insert to table tblBulk<br />
4500111 ;<br />
4500112 ;<br />
4500113 ;<br />
<br />
'Second Batch<br />
4611001<br />
4611002<br />
4611003
i dont know what should i put in column2 so that
it will know the batch
---------
tblBulk
---------
column1 column2<br />
4500110<br />
4500111<br />
4500112<br />
4500113<br />
4611001<br />
4611002<br />
4611003
C# コードMicrosoft End User
2000-2008
「「「「「「「「「「「「「「「「「「「「「「「「「「「「
The best things in life are free
」」」」」」」」」」」」」」」」」」」」」」」」」」」」
|
|
|
|
|
Why don't you store the BATCH # with each transaction ?
|
|
|
|
|
solved. i used max query for batch no.
C# コードMicrosoft End User
2000-2008
「「「「「「「「「「「「「「「「「「「「「「「「「「「「
The best things in life are free
」」」」」」」」」」」」」」」」」」」」」」」」」」」」
|
|
|
|
|
I have the following code:
Imports System.Data.SqlClient
Public Class Main
Protected WithEvents DataGridView1 As DataGridView
Dim instForm2 As New Exceptions
Private Sub Button1_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles startpayrollButton.Click
Dim ssql As String = "select MAX(payrolldate) AS [payrolldate], " & _
"dateadd(dd, ((datediff(dd, '17530107', MAX(payrolldate))/7)*7)+7, '17530107') AS [Sunday]" & _
"from dbo.payroll" & _
" where payrollran = 'no'"
Dim oCmd As System.Data.SqlClient.SqlCommand
Dim oDr As System.Data.SqlClient.SqlDataReader
oCmd = New System.Data.SqlClient.SqlCommand
Try
With oCmd
.Connection = New System.Data.SqlClient.SqlConnection("Initial Catalog=mdr;Data Source=xxxxx;uid=xxxxx;password=xxxxx")
.Connection.Open()
.CommandType = CommandType.Text
.CommandText = ssql
oDr = .ExecuteReader()
End With
If oDr.Read Then
payperiodstartdate = oDr.GetDateTime(1)
payperiodenddate = payperiodstartdate.AddSeconds(604799)
Dim ButtonDialogResult As DialogResult
ButtonDialogResult = MessageBox.Show(" The Next Payroll Start Date is: " & payperiodstartdate.ToString() & System.Environment.NewLine & " Through End Date: " & payperiodenddate.ToString())
If ButtonDialogResult = Windows.Forms.DialogResult.OK Then
exceptionsButton.Enabled = True
startpayrollButton.Enabled = False
End If
End If
oDr.Close()
oCmd.Connection.Close()
Catch ex As Exception
MessageBox.Show(ex.Message)
oCmd.Connection.Close()
End Try
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles exceptionsButton.Click
Dim connection As System.Data.SqlClient.SqlConnection
Dim adapter As System.Data.SqlClient.SqlDataAdapter = New System.Data.SqlClient.SqlDataAdapter
Dim connectionString As String = "Initial Catalog=mdr;Data Source=xxxxx;uid=xxxxx;password=xxxxx"
Dim ds As New DataSet
Dim _sql As String = "SELECT [Exceptions].Employeenumber,[Exceptions].exceptiondate, [Exceptions].starttime, [exceptions].endtime, [Exceptions].code, datediff(minute, starttime, endtime) as duration INTO scratchpad3" & _
" FROM Employees INNER JOIN Exceptions ON [Exceptions].EmployeeNumber = [Exceptions].Employeenumber" & _
" where [Exceptions].exceptiondate between @payperiodstartdate and @payperiodenddate" & _
" GROUP BY [Exceptions].Employeenumber, [Exceptions].Exceptiondate, [Exceptions].starttime, [exceptions].endtime," & _
" [Exceptions].code, [Exceptions].exceptiondate"
connection = New SqlConnection(connectionString)
connection.Open()
Dim _CMD As SqlCommand = New SqlCommand(_sql, connection)
_CMD.Parameters.AddWithValue("@payperiodstartdate", payperiodstartdate)
_CMD.Parameters.AddWithValue("@payperiodenddate", payperiodenddate)
adapter.SelectCommand = _CMD
Try
adapter.Fill(ds)
If ds Is Nothing OrElse ds.Tables.Count = 0 OrElse ds.Tables(0).Rows.Count = 0 Then
MessageBox.Show("There was no data for this time period. Press Ok to continue", "No Data")
connection.Close()
Exceptions.saveButton.Enabled = False
Exceptions.Hide()
Else
connection.Close()
End If
Catch ex As Exception
MessageBox.Show(ex.ToString)
connection.Close()
End Try
Exceptions.Show()
End Sub
Private Sub payrollButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles payrollButton.Click
Payrollfinal.Show()
End Sub
End Class
and when I run my program and press this button
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles exceptionsButton.Click
I have my date range within a time that I know that my dataset should produce a result, but when I put a line break in my code here
adapter.Fill(ds)
and look at it in debug, I show a table value of 0. If I run the same query that I have to produce these results in sql analyser, I see 1 result. I have also verified that my data that is being passed to my query via the variables are correct.
Can someone see why my query on my form produces a different result than the sql analyser does?
Also here is my schema for my two tables:
Exceptions
employeenumber varchar no 50 yes no no SQL_Latin1_General_CP1_CI_AS
exceptiondate datetime no 8 yes (n/a) (n/a) NULL
starttime datetime no 8 yes (n/a) (n/a) NULL e
ndtime datetime no 8 yes (n/a) (n/a) NULL
duration varchar no 50 yes no no SQL_Latin1_General_CP1_CI_AS
code varchar no 50 yes no no SQL_Latin1_General_CP1_CI_AS
approvedby varchar no 50 yes no no SQL_Latin1_General_CP1_CI_AS
approved varchar no 50 yes no no SQL_Latin1_General_CP1_CI_AS
time timestamp no 8 yes (n/a) (n/a) NULL
employees
employeenumber varchar no 50 no no no SQL_Latin1_General_CP1_CI_AS
name varchar no 50 no no no SQL_Latin1_General_CP1_CI_AS
initials varchar no 50 no no no SQL_Latin1_General_CP1_CI_AS
loginname1 varchar no 50 yes no no SQL_Latin1_General_CP1_CI_AS
Thank you
Doug
|
|
|
|
|
Look here:
[DataSet]
Looks like you need to provide a Dataset name in the constructor.
I don't speak Idiot - please talk slowly and clearly
'This space for rent'
Driven to the arms of Heineken by the wife
|
|
|
|