I have gotten my pages to work up to the final edit page. The code executes on load. Variables are passed by session but I get an SQL syntax error. I've tested the sp I'm calling and it works correctly. Here's the code"
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArg s) Handles Me.Load
Dim strSelDate
Dim strShift
Dim strAbsent
Dim strTO
Dim strHeadCount
Dim strSTDHeadCount
Dim strMPNotes
Dim Notes2
Dim strSQL
Dim strRID
strRID = Session.Item("R ID").ToString ()
strSelDate = Session.Item("S elDate").ToStri ng()
strShift = Session.Item("S hift").ToString ()
strAbsent = Session.Item("A bsent").ToStrin g()
strTO = Session.Item("T O").ToString ()
strHeadCount = Session.Item("H eadCount").ToSt ring()
strSTDHeadCount = Session.Item("S TDHeadCount").T oString()
strMPNotes = Session.Item("N otes").ToString ()
'Notes2 = strMPNotes.Repl ace("'", "''")
strSQL = "UP_MANPOWER_RE CORD_UPDATE '" & strSelDate & "', '" & strShift & "', " & strHeadCount & ", " & strSTDHeadCount & ", " & strAbsent & ", " & strTO & ", '" & Notes2 & "', " & strRID
Dim objConn As New Data.SqlClient. SqlConnection(" Data Source=XXXXXX;I nitial Catalog=XXXXXX; User ID=XXXXXX;passw ord=XXXXXX;")
Dim objCmd As New Data.SqlClient. SqlCommand(strS QL, objConn)
objConn.Open()
objCmd.ExecuteN onQuery()
objConn.Close()
End Sub
Here's the error I get:
System.Data.Sql Client.SqlExcep tion: Line 1: Incorrect syntax near '.'.
Can anyone enlighten this drowning noob??
Oct 24 '07
28 2179
hehe oops, my mistake, I didn't look at the variable name close enough to see it said it was Date.
If you set a breakpoint here: -
Dim objConn As New Data.SqlClient.SqlConnection("Data Source=XXXXXX;Initial Catalog=XXXXXX;User ID=XXXXXX;password=XXXXXX;")
-
what does the value of your sql query strSQL, look like? Maybe there's something that can be caught by seeing how it is displayed?
By the way, is that a stored procedure you're trying to run there?
Yeah. Here's the code for the SP:
ALTER PROCEDURE UP_MANPOWER_REC ORD_UPDATE
@Date datetime,
@Shift varchar(10),
@HeadCount int,
@STDHeadCount int,
@Absent int,
@TO int,
@Notes varchar(1000),
@RID int
AS
Update Manpower_Data
set Date = @Date, Shift_ID = (select shift_id from shift where shift=@Shift) , HeadCount = @HeadCount, STDHeadCount= @STDHeadCount, Absent= @Absent, [TO] = @TO, Notes= @Notes
where RID = @RID
Plater 7,872
Recognized Expert Expert
ah ha! That's why. I suspected it from the begining and shoulda listened to myself.
That's not how you call stored procedures in .NET.
Here is a (long) example taken directly from one of my projects.
dbcon is the name of my open dbconnection
"InsertNewBoard Assembly" is the name of my stored procedure. You can see how parameters are added, including the OUTPUT paramter. -
Public Shared Function InsertNewBoardAssembly(ByVal Name As String, ByVal BoardAssemblyNumber As String, ByVal RevNumber As Integer, ByVal BOMID As Int64, ByVal PartID As Int64, ByVal Notes As String) As Int64
-
Dim retval As Int64 = -1
-
Dim logmsg As String = ""
-
-
Try
-
Dim ModifiedDate As DateTime = DateTime.Now
-
Dim sc As New SqlCommand("InsertNewBoardAssembly", dbcon)
-
sc.CommandType = CommandType.StoredProcedure
-
-
sc.Parameters.Add("@Name", SqlDbType.VarChar)
-
sc.Parameters("@Name").Value = quoteReplace(Name)
-
-
sc.Parameters.Add("@BoardAssemblyNumber", SqlDbType.VarChar)
-
sc.Parameters("@BoardAssemblyNumber").Value = quoteReplace(BoardAssemblyNumber)
-
-
sc.Parameters.Add("@RevNumber", SqlDbType.Int)
-
sc.Parameters("@RevNumber").Value = RevNumber
-
-
sc.Parameters.Add("@BOMID", SqlDbType.BigInt)
-
sc.Parameters("@BOMID").Value = BOMID
-
-
sc.Parameters.Add("@PartID", SqlDbType.BigInt)
-
sc.Parameters("@PartID").Value = PartID
-
-
sc.Parameters.Add("@Notes", SqlDbType.VarChar)
-
sc.Parameters("@Notes").Value = quoteReplace(Notes)
-
-
sc.Parameters.Add("@ModifiedDate", SqlDbType.DateTime)
-
sc.Parameters("@ModifiedDate").Value = ModifiedDate
-
-
'out
-
sc.Parameters.Add("@BoardAssemblyID", SqlDbType.BigInt)
-
sc.Parameters("@BoardAssemblyID").Direction = ParameterDirection.Output
-
Dim numrows As Integer = sc.ExecuteNonQuery()
-
retval = DirectCast(sc.Parameters("@BoardAssemblyID").Value, Int64)
-
sc.Dispose()
-
Catch ee As Exception
-
ReportError("InsertNewBoardAssembly", ee)
-
End Try
-
Return retval
-
End Function
-
What does this error mean?
BC31029: Method 'Protected Sub Page_Load(sende r As Object, e As System.EventArg s, rDate As Date, Shift As String, HeadCount As Integer, STDHeadCount As Integer, Absent As Short, rTO As Integer, Notes As String, RID As Integer)' cannot handle Event 'Public Event Load(sender As Object, e As System.EventArg s)' because they do not have the same signature.
Plater 7,872
Recognized Expert Expert
Two of my field names are seen as keywords when I try to enter them in the args portion of the sub routine. How can I correct this. Renaming them in the DB won't work as the number of procedures and reports that read all of this is huge.
Enclose column names (and other database objects) with square brackets
[myTableName].[MyColumnName]=@Somevariable
Enclose column names (and other database objects) with square brackets
[myTableName].[MyColumnName]=@Somevariable
Ok. Here's what I have:
Dim objCmd As New Data.SqlClient. SqlCommand("UP_ MANPOWER_RECORD _UPDATE", objConn)
objCmd.CommandT ype = Data.CommandTyp e.StoredProcedu re
objCmd.Paramete rs.Add("@rDate" , Data.SqlDbType. DateTime)
objCmd.Paramete rs("@rDate").Va lue = strSelDate
objCmd.Paramete rs.Add("@Shift" , Data.SqlDbType. VarChar)
objCmd.Paramete rs("@Shift").Va lue = strShift
objCmd.Paramete rs.Add("@HeadCo unt", Data.SqlDbType. Int)
objCmd.Paramete rs("@HeadCount" ).Value = strHeadCount
objCmd.Paramete rs.Add("@STDHea dCount", Data.SqlDbType. Int)
objCmd.Paramete rs("@STDHeadCou nt").Value = strSTDHeadCount
objCmd.Paramete rs.Add("@Absent ", Data.SqlDbType. Int)
objCmd.Paramete rs("@Absent").V alue = strAbsent
objCmd.Paramete rs.Add("@rTO", Data.SqlDbType. Int)
objCmd.Paramete rs("@rTO").Valu e = strTO
objCmd.Paramete rs.Add("@Notes" , Data.SqlDbType. VarChar)
objCmd.Paramete rs("@Notes").Va lue = Notes2
objCmd.Paramete rs.Add("@RID", Data.SqlDbType. Int)
objCmd.Paramete rs("@RID").Valu e = strRID
I get System.FormatEx ception: Input string was not in a correct format.
error. Is this due to not having single qoutes around the varchar variables? I put in quoteReplace.st ring name and the app this it's an undeclared variable.
Plater 7,872
Recognized Expert Expert
I am guessing it has to do with the date parameter.
When you set the type to Date, the parameter expects you to add an object of type DateTime, not a string?
EDIT: actually the same holds true for all of them, the parameters of type Int, want you to add an object of type Int and not a string.
Plater 7,872
Recognized Expert Expert
What does this error mean?
BC31029: Method 'Protected Sub Page_Load(sende r As Object, e As System.EventArg s, rDate As Date, Shift As String, HeadCount As Integer, STDHeadCount As Integer, Absent As Short, rTO As Integer, Notes As String, RID As Integer)' cannot handle Event 'Public Event Load(sender As Object, e As System.EventArg s)' because they do not have the same signature.
it means you accidently deleted something and part of your page_load() function got overriden with the declaration of your other function.
Straighten out the functions and you should be fine.
it means you accidently deleted something and part of your page_load() function got overriden with the declaration of your other function.
Straighten out the functions and you should be fine.
Got them straightened out. I have remarked out all of the variables in the sp calls and executed it to see where I get a error. On the headcount variable I get a Object must implement IConvertible. error message. The first two pass fine.
Is this a bug or is there something that I didn't put in the code?
Plater 7,872
Recognized Expert Expert
strHeadCount is a string yes?
Convert it to an int with:
Int.Parse(strHe adCount)
strHeadCount is a string yes?
Convert it to an int with:
Int.Parse(strHe adCount)
It didn't like that line. Is there another way to cast a string to an int in VB.Net?
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Keiron Waites |
last post by:
Please see the problem in action here: http://www.leadbullet.biz/contact.php
If you mouse over the fields, you will see that text is shown on the right.
The text makes the other fields move when it is shown - even though the
width of the text is less than the width of the field. WHY?
This is driving me nuts - please help!
TIA,
|
by: Marty |
last post by:
It seems all of the sudden that user controls that
contain images are referencing image sources relative to
the document that I drop the control on. This obviously
does not work beacuase the image source is relative to
the user control, not necessarily the form. Can anyone
tell me why this would be the case?
|
by: Simon Harris |
last post by:
Ok, this really is driving me nuts!!! :(
'All' I am trying to do is get the value of a named element. My XML doc
is:
<?xml version="1.0" encoding="utf-16" standalone="yes" ?>
- <Page>
<Title>Test</Title>
<MetaKeywords>Test</MetaKeywords>
|
by: ipmccun |
last post by:
Hello all:
Perhaps someone can shed some light on this: I'm trying to create a
situation, while debugging, where a long running request (sleeps for
15s) and a short running request execute concurrently. Right now, no
matter what I do, it seems that they execute serially. I've verified
(by watching netstat) that two simultaneous connections are being made
to the server, so I'm sure this isnt the standard IE "only two
connections to the...
|
by: trond |
last post by:
Hello all,
Before I start I'd like to point out that I am a complete novice when
it comes to asp.net - My background is in network and operating
systems, and although I have been doing a bit of hobby programming in
vb.net and web programming in asp/vbscript in the past, I am pretty
much a beginner at asp.net.
What I'm trying to do, is to take the "PersonalHomePage" starter kit
that MS supplies with VS2005 and tweak it a bit, to make it...
| |
by: mitsura |
last post by:
Hi,
I need to read a simle XML file. For this I use the SAX parser. So far
so good.
The XML file consist out of number of "Service" object with each object
a set of attributes.
I read through the XML file and for each "<Service>" entry I create a
new service object.
When I am in the "<Service>" part of the XML file and I encounter
|
by: jason.neo |
last post by:
Hi all experts,
I am going nuts with this Invalid postback or callback argument thingy
with .Net 2.0
I am building a file attachment module which relays on a Datatable
stored in session (yeah i know its unhealthy, but its the only "clean"
approach which I can think of to avoid tranfering temp files onto the
server) to maintain the list of attached files before the "commit"
action is done to transfer all the files onto the server.
|
by: mattlightbourn |
last post by:
Hi all,
I have a problem which has been driving me nuts. Crosstab queries!
I have a database witch a few different tables to do with garment manufacturing.
I have a table for a client account, garment type (Jacket, skirt, etc), client sizing spec and descriptives (measurement names i.e: Shoulder to cuff, inside leg, etc), available sizes (ie. 4,6,8,10,12,14,16,18,20,S,M,L,SM,ML,One) and pattern adjustments (if size 10 is the base, the...
|
by: DuncanIdaho |
last post by:
Hello experts
IE 7.0.5730.11
Opera 9.27
Firefox 2.0.0.14
This problem only occurs in Opera and Firefox (amazing, IE does
something right, or maybe not)
Anyway, the problem is that when I put an image in a <divor a <td>
|
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: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
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: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
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...
| |