473,804 Members | 4,288 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

ASP and SQL driving me nuts

BezerkRogue
68 New Member
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
Plater
7,872 Recognized Expert Expert
It didn't like that line. Is there another way to cast a string to an int in VB.Net?
What's wrong with that line? (other then if the string is empty or contains non-integer chracters it will throw an exception, but you said they were garunteed to contain correct data)
That and .TryParse() are the first choices for converting a string to an integer.
Oct 25 '07 #21
BezerkRogue
68 New Member
What's wrong with that line? (other then if the string is empty or contains non-integer chracters it will throw an exception, but you said they were garunteed to contain correct data)
That and .TryParse() are the first choices for converting a string to an integer.

I put the following line in:

Int32.Parse(str STDHeadCount) and get this error...

Conversion from type 'TextBox' to type 'String' is not valid.

Sigh....another change another error.
Oct 25 '07 #22
Plater
7,872 Recognized Expert Expert
strSTDHeadCount is a textbox object then?
Use strSTDHeadCount .Text, I thought it was string since you pulled it from the session.

That coulda been your trouble with the "." error earlier, if Session.Item("S TDHeadCount") is a textbox then Session.Item("S TDHeadCount").T oString() would come back as like "Forms.Text Box"

I would suggest you go back and only store the TEXT in the session, unless you want the whole textbox.
Oct 25 '07 #23
BezerkRogue
68 New Member
strSTDHeadCount is a textbox object then?
Use strSTDHeadCount .Text, I thought it was string since you pulled it from the session.

That coulda been your trouble with the "." error earlier, if Session.Item("S TDHeadCount") is a textbox then Session.Item("S TDHeadCount").T oString() would come back as like "Forms.Text Box"

I would suggest you go back and only store the TEXT in the session, unless you want the whole textbox.
I set them to Session.Item.Ad d("HeadCount" , txtHeadCount.Te xt) on the sending page and Session.Item("H eadCount").ToSt ring() on the receiving page.

I get Input string was not in a correct format messages. I have also tried parsing the variable to int by setting Session.Item("H eadCount") and then int32.Parse(str HeadCount).

I'm about ready to tank the whole page and start from scratch.
Oct 25 '07 #24
Plater
7,872 Recognized Expert Expert
Yeah, I'm scratchin my head now, not sure why it thinks it's a textbox.
that's really messed up.
Oct 25 '07 #25
BezerkRogue
68 New Member
Yeah, I'm scratchin my head now, not sure why it thinks it's a textbox.
that's really messed up.
I have an <%@ reference page%> statement in the pages. Do I need that when using sessions or would it help if you saw the code from both pages?
Oct 26 '07 #26
Plater
7,872 Recognized Expert Expert
I have an <%@ reference page%> statement in the pages. Do I need that when using sessions or would it help if you saw the code from both pages?
Umm....I don't know?
My aspx pages start with something like this:
Expand|Select|Wrap|Line Numbers
  1. <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
  2.  
Then I have the aspx.cs (or for vb aspx.vb) where my backend code goes.
Session was just always available to me.
Oct 26 '07 #27
BezerkRogue
68 New Member
Umm....I don't know?
My aspx pages start with something like this:
Expand|Select|Wrap|Line Numbers
  1. <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
  2.  
Then I have the aspx.cs (or for vb aspx.vb) where my backend code goes.
Session was just always available to me.
I might have found my issue. The query in the change page is pulling all of the data fields for the record by one of the fields is not being loaded into the assigned text box.

Response.write shows the variable but making the textbox visible shows no data there.
Oct 26 '07 #28
BezerkRogue
68 New Member
Umm....I don't know?
My aspx pages start with something like this:
Expand|Select|Wrap|Line Numbers
  1. <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
  2.  
Then I have the aspx.cs (or for vb aspx.vb) where my backend code goes.
Session was just always available to me.
I finally figured it out. Got it to work correctly and pass all variables in the correct data type. Thanks for the help. Sessions for the win
Oct 26 '07 #29

Sign in to post your reply or Sign up for a free account.

Similar topics

6
1613
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,
12
1620
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?
0
984
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>
2
1386
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...
4
1660
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...
2
1516
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
5
6865
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.
4
2475
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...
3
2289
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>
0
9710
marktang
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...
0
10593
Oralloy
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...
0
10340
jinu1996
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...
0
10085
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9163
agi2029
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...
0
6858
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();...
0
5527
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
3830
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3000
bsmnconsultancy
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...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.