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(s, 518399, max(payrolldate)) 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.AddDays(7)
-
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
-
'it's empty
-
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 this code, I get the following error
System.Data.SQL Client.SQLExcep tion: Syntax error converting from character string, line 57. Which is this line:
adapter.Fill(ds )
When I debug this, I put the line break on that line and look at the Table Value, which shows 0, but I know that there is data for that time frame. Can anyone please assist?
0 1425 Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Justin Wong |
last post by:
CREATE PROCEDURE dbo.Synchronization_GetNewRecords
(
@item varchar(50),
@last datetime
)
AS
SET NOCOUNT ON
|
by: Anthony |
last post by:
I have an inventory database that Im trying to create a report out of
the IP address are a lookup on a seperat table but I keep getting the
above error can I change the table row to something to fix this or
what.
SELECT i.INVENTORY_ITEM_ID AS ,i.HOST_NAME AS , '' AS Flag, i.MEMO AS Comments, 'Seattle' AS City, 'Washington'
AS State,
CASE WHEN fv.value = 'EL EET1410' THEN '1111 3rd
Ave.' WHEN fv.value = 'EL WFL17' THEN '999 3rd Ave.'...
|
by: kufre |
last post by:
I need some fresh eyes to take a look at this code for me and let me
know what it is I'm doing wrong because I keep getting all kinds of
error message with this code. I've had several people help me with this
code and every thing that've told me I've done but for the life of me I
can't seem to get this working right.
First I keep getting "Type mismatch" error message for this line of
code: StrProject = Str(Me!cboProjectID) but if I take...
|
by: Roy Rodsson via .NET 247 |
last post by:
Hi all!
I am using a stored procedure in SQL2000 for retrieving fileinformations from a db.
the table as an uniqueidentifier for the file information.
The stored procedure has a variable called fileIds that is oftype varchar.
I am putting in a comma separated string with ids (such as:'9B176B0C-CA03-49C9-A2E7-063038E7CF20','9B176B0C-CA03-49C9-A2E7-063038E7CF22','9B176B0C-CA03-49C9-A2E7-063038E7CF23')
However, when I execute the sp via...
|
by: SealedClassSingleton |
last post by:
Hi,
When calling a stored procedure on a SQL 2005 DB with the managed SQL
ADOprovider I got the following exception:
Syntax error converting character string to uniqueidentifier
when I use the following value for a unqiueidentifier variable
{A00C9D36-CC20-475F-A285-777CC739199C}. If I use another random GUID the
stored procedure executes fine. The value that gives problems, is a key that
| |
by: ronca |
last post by:
Error Syntax error converting the varchar value $568.25 to a column of data type
Statement I'm using
Select Top 1000 *
From mass.dbo.dbo_MASS
where _amount > 5000
Want only row with _amount >5000
Help please
|
by: rahuls |
last post by:
Hi everyone, I have a couple of questions?
1.this is part of my main function
//////////////////////////////
int main()
{
FILE *f1;
int i,j;
j=100000000;
int intData;
|
by: werks |
last post by:
Hello
Every time i input the character ' and % in the textfield it generate an error in my query.
The error:
Syntax error in query expression 'Title LIKE '%' %%';'.
My code:
adoList.Open "SELECT * FROM qryOPAC WHERE Title LIKE '%" & varExp & "%';",CoNN,3,3
|
by: SnehaAgrawal |
last post by:
Hi I get the error "Syntax error converting datetime from character string "for
the following sql statement in Stored proc.
SET @dynamicSQL =N'SELECT CUSTID,SHCodeLink FROM AccountMaster where CONVERT(DATETIME,OPDATE,105) < = '''+CONVERT(DATETIME,@ACCYEAR,105) +''' And GLCode = '+@DIVGLCODE
EXEC(@dynamicsql)
|
by: Yesurbius |
last post by:
I am receiving the following error when attempting to run my query. In my mind - this error should not be happening - its a straight-forward query with a subquery. I am using Access 2003 with all the latest patches.
If I do not group the query (ie. remove aggregation) it will work. If I recall, it also works if my subquery does not have joins.
I want to accomplish this with pure SQL .. I could easily write a VBA function to handle...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |