Current location: Hot Scripts Forums » Programming Languages » ASP.NET » Passing the buck (Variable)


Passing the buck (Variable)

Reply
  #1 (permalink)  
Old 01-03-05, 06:21 PM
techknow's Avatar
techknow techknow is offline
Newbie Coder
 
Join Date: Apr 2004
Location: Lomita, Ca
Posts: 56
Thanks: 0
Thanked 0 Times in 0 Posts
Passing the buck (Variable)

I am attempting to pass a var using the url. I want to use the the var to grab a single record from a database... Basically a master/detail scenerio. Here is my code without the connection string for obvious reasons. Everything basically works but the details information is not showing up. You can see it live @ http://thebillingcompany.net/Dynamic/ViewCharges02.aspx

Code:
<%@ Page Language="VB"  Debug="true" ContentType="text/html" ResponseEncoding="iso-8859-1" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.OleDb" %>

<script runat="server">
	Sub Page_Load
		Dim ChargeID as Integer
  		Dim conTBC as OleDbConnection
		Dim cmdSelect as OleDbCommand
		Dim ChargeSelect as String
		
		'Retrieve ID
		ChargeID = Request.QueryString( "ID" )
	
		conTBC = New OleDbConnection ("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=###Removed for Post###" )
		ChargeSelect = "Select * From Charges Where ID = @ChargeID"
		cmdSelect = New OleDbCommand ( ChargeSelect, conTBC )
		cmdSelect.Parameters.Add( "@ChargeID", ChargeID )
		
		conTBC.Open()
		dgrdCharges.Datasource = cmdSelect.ExecuteReader()
		dgrdCharges.DataBind()
		ConTBC.Close()
	End Sub
</script>



<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css">
<!--
body {
	background-color: #006699;
}
.style3 {color: #FFFFFF; font-weight: bold; }
-->
</style></head>
<body>
<table width="100%" height="100%"  border="0" cellpadding="0" cellspacing="0">
  <tr background="../Images/Logo02.gif">
    <td height="125" background="../Images/Logo02.gif"><div align="left"><img src="../Images/Logo01.gif" width="561" height="125"></div></td>
    <td><div align="right"><img src="../Images/Logo03.gif" width="26" height="125"></div></td>
  </tr>
  <tr valign="top">
    <td colspan="2"><div align="center">
        <p>&nbsp;</p>
        <table width="85%" height="90%"  border="1" cellpadding="7" cellspacing="0">
          <tr>
            <td bgcolor="#0099CC"><p align="center">
			
			<asp:datagrid
			id="DgrdCharges" 
			EnableViewState="False"
			CellPadding="7"
			runat="server"  /> 
			
</p>
            </td>
          </tr>
        </table>
    </div></td>
  </tr>
</table>
</body>
</html>
__________________
Best Regards,

TechKnow
Head-Nerd-In-Charge
Advanced Tech Knowledge

Http://justoneguy.com

http://atkhost.com
Reply With Quote
  #2 (permalink)  
Old 01-04-05, 07:33 AM
koncept
Guest
 
Posts: n/a
got it, i've made this mistake many times my self

change this line
ChargeSelect = "Select * From Charges Where ID = @ChargeID"
to be
ChargeSelect = "Select * From Charges Where ID =" & ChargeID
Reply With Quote
  #3 (permalink)  
Old 01-04-05, 01:42 PM
techknow's Avatar
techknow techknow is offline
Newbie Coder
 
Join Date: Apr 2004
Location: Lomita, Ca
Posts: 56
Thanks: 0
Thanked 0 Times in 0 Posts
Better but I still get an error

Now I get:

Invalid SQL statement; expected 'DELETE', 'INSERT', 'PROCEDURE', 'SELECT', or 'UPDATE'.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Data.OleDb.OleDbException: Invalid SQL statement; expected 'DELETE', 'INSERT', 'PROCEDURE', 'SELECT', or 'UPDATE'.
__________________
Best Regards,

TechKnow
Head-Nerd-In-Charge
Advanced Tech Knowledge

Http://justoneguy.com

http://atkhost.com
Reply With Quote
  #4 (permalink)  
Old 01-04-05, 02:47 PM
techknow's Avatar
techknow techknow is offline
Newbie Coder
 
Join Date: Apr 2004
Location: Lomita, Ca
Posts: 56
Thanks: 0
Thanked 0 Times in 0 Posts
I figured it out...

I was passing the wrong var.

Yes, I do realize I have to wear the dunce hat and sit in the corner...

http://justoneguy.com/webpix/idiot.jpg

It was not the ID database field being passed.
__________________
Best Regards,

TechKnow
Head-Nerd-In-Charge
Advanced Tech Knowledge

Http://justoneguy.com

http://atkhost.com
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Passing variable between two sites hellind2 ASP 3 10-17-04 08:48 AM
what is the best method to find last word in variable ? GS300 PHP 6 09-15-04 09:13 PM
help passing variable via form move3rd PHP 11 04-21-04 10:43 AM
Passing a table or variable through a link? chinablack1480 PHP 1 12-07-03 03:55 AM
PAssing variables dbalka Perl 3 10-29-03 05:00 PM


All times are GMT -5. The time now is 01:01 PM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.