|
SELECT tblStudent.StudentID, tblStudent.StudentName, tblMarks.Division FROM tblStudent LEFT OUTER JOIN tblMarks ON tblStudent.StudentID = tblMarks.StudentID
|
|
|
|
|
In which database u want to run this???
following is for MS-Access
-----------------------------
SELECT [studentName], [Division]
FROM tblstudent LEFT JOIN tblMarks ON [tblstudent].[studentID]=[tblMarks].[studentID];
"We can't solve problems by using the same kind of thinking we used when we created them"
|
|
|
|
|
just grab a chair, i will post you the entire code in a few minutes ok?
nelsonpaixao@yahoo.com.br
trying to help & get help
|
|
|
|
|
i m using Visual studio 2005.here i am having a problem that i have a RadioButtonList which retrives data from sql datasource. it displays the Items correctly.Now when i try to display the SelectedItems on a label i get an error.kindly help me m stuck..m a student a really new to it.please help..thanx a lot...
|
|
|
|
|
Ok, a couple of things
1. This isn't a sql question, its either vb.net or c#, depending on what you are using - you state the data is being retrived correctly, so there is no sql problem
2. With no code and no error message how can anybody work out what is wrong?
Bob
Ashfield Consultants Ltd
|
|
|
|
|
Its hard to help when one has no idea what kind of error you are getting. Please paste the line that you are using to display the SelectedItems on the label or the error. It could be something minor that you are not taking into consideration.
|
|
|
|
|
the error i am getting on browser page is :-
"Server Error in '/Website_dtc' Application.
--------------------------------------------------------------------------------
Object reference not set to an instance of an object.
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.NullReferenceException: Object reference not set to an instance of an object.
"
the RadiobuttonList is databound as follows-
"RadioButtonList1.DataSource = ds.Tables["temp1"];
RadioButtonList1.DataTextField = "buses";
RadioButtonList1.DataValueField = "buses";
RadioButtonList1.DataBind();
"
the RadiobuttonList Item is selected as:-
" protected void Button1_Click(object sender, EventArgs e)
{
lbltemp.Text = RadioButtonList1.SelectedItem.Text;
}
"
|
|
|
|
|
At a guess, either
a) you haven't selected anything in the list
or
b) you rebind the list each time the page loads, thus overwriting the selection... Might want to have a look at the IsPostBack page variable.
|
|
|
|
|
dear paddy ..
this is my Source Code for the Page--
"<%@ Page Language="C#" AutoEventWireup="true" CodeFile="searchstops_1.aspx.cs" Inherits="searchstops_1" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<!--
Design by Free CSS Templates
http://www.freecsstemplates.org
Released for free under a Creative Commons Attribution 2.5 License
Name : Monoblock
Description: A two-column, fixed-width design with dark color scheme.
Version : 1.0
Released : 20080418
-->
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>DTC_Services</title>
<meta name="keywords" content="" />
<meta name="description" content="" />
<link href="style.css" rel="stylesheet" type="text/css" media="screen" />
<script language="javascript" type="text/javascript">
<!--
function content_onclick() {
}
// -->
</script>
</head>
<body>
<form id="form1" runat="server">
<div id="header" style="width: 1202px">
<div id="logo">
</div>
<br />
<br />
<br />
<br />
<br />
<br />
<asp:Label ID="Label1" runat="server" Font-Bold="True" Font-Size="X-Large" ForeColor="Black"
Style="z-index: 100; left: 39px; position: absolute; top: 23px" Text="DELHI TRANSPORT CORPORATION"></asp:Label>
<br />
<asp:Image ID="Image2" runat="server" ImageUrl="~/PICS/logo1.gif" Style="z-index: 101;
left: 1014px; position: absolute; top: 31px" />
<br />
<br />
<!-- end #search -->
<br />
</div>
<!-- end #header -->
<div id="menu" style="width: 1202px">
<br />
<strong><span style="color: #ffffcc">
<span style="font-size: 14pt; font-family: Verdana"><a href="home.aspx">Home </a>
<a href="home.aspx">Services Offered </a>
<a href="home.aspx">Apply for DTC pass</a> <a href="home.aspx">Contact
Us</a> <a href="home.aspx">Help </a></span><span style="font-size: 14pt">
</span></span></strong></div>
<!-- end #menu -->
<div id="page" style="width: 1121px; height: 635px">
<!-- end #content -->
<div id="sidebar" style="height: 690px">
<ul>
<li>
<h2>
buses at a glance</h2>
<p>
</p>
<p>
</p>
<p>
<asp:Image ID="Image1" runat="server" ImageUrl="~/PICS/2008053054180501.jpg" Style="z-index: 100;
left: 914px; position: absolute; top: 370px" Height="126px" />
</p>
</li>
<li id="calendar">
<h2>
Services offered</h2>
<div id="calendar_wrap">
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
</div>
</li>
</ul>
</div>
<div style="clear: both;">
<div class="entry">
<asp:HyperLink ID="HyperLink4" runat="server" NavigateUrl="~/home.aspx" Style="z-index: 100;
left: 924px; position: absolute; top: 733px" Width="208px">Buses through a stoppage</asp:HyperLink>
<asp:Panel ID="Panel1" runat="server" Height="691px" Style="z-index: 105; left: 46px;
position: absolute; top: 255px" Width="823px">
<br />
<br />
<span style="font-size: 16pt">Services offered >><br />
<span style="font-size: 14pt">
Search Buses by Stops<br />
<asp:Label ID="lblsrc" runat="server" Font-Bold="False" ForeColor="Green" Style="z-index: 100;
left: 580px; position: absolute; top: 300px"></asp:Label>
<asp:Label ID="lbldes" runat="server" Font-Bold="False" ForeColor="Green" Style="z-index: 101;
left: 153px; position: absolute; top: 305px"></asp:Label>
<br />
<asp:Label ID="Label2" runat="server" Font-Italic="True" Font-Size="Smaller" ForeColor="Red"
Style="z-index: 102; left: 348px; position: absolute; top: 128px" Text="You Selected"></asp:Label>
<br />
<span style="font-size: 12pt; color: #ff0000"><em>
<asp:Label ID="Label4" runat="server" Font-Bold="True" Font-Underline="True" Style="z-index: 103;
left: 155px; position: absolute; top: 230px" Text="SOURCE"></asp:Label>
<%--<asp:RadioButtonList ID="RadioButtonList1" runat="server" Style="z-index: 104; left: 344px;
position: absolute; top: 476px" OnSelectedIndexChanged="RadioButtonList1_SelectedIndexChanged">
</asp:RadioButtonList>--%>
<br />
<br />
<asp:Label ID="Label3" runat="server" Font-Bold="True" Font-Underline="True" Style="z-index: 104;
left: 580px; position: absolute; top: 226px" Text="DESTINATION"></asp:Label>
<br />
<br />
</em></span>
<span style="font-size: 12pt; color: #cc0000"><strong>
<asp:Label ID="Label5" runat="server" Font-Size="Smaller" Style="z-index: 105; left: 264px;
position: absolute; top: 410px" Text="Following Bus Routes are available"></asp:Label>
<asp:RadioButtonList ID="RadioButtonList1" runat="server" Style="z-index: 106; left: 333px;
position: absolute; top: 467px" AutoPostBack="True" OnSelectedIndexChanged="RadioButtonList1_SelectedIndexChanged">
</asp:RadioButtonList>
<asp:Label ID="lbltemp" runat="server" Style="z-index: 108; left: 628px; position: absolute;
top: 462px"></asp:Label>
</strong></span></span></span></asp:Panel>
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<asp:HyperLink ID="HyperLink5" runat="server" NavigateUrl="~/home.aspx" Style="z-index: 102;
left: 929px; position: absolute; top: 864px" Width="204px">Apply for DTC pass</asp:HyperLink>
<asp:HyperLink ID="HyperLink2" runat="server" NavigateUrl="~/home.aspx" Style="z-index: 103;
left: 926px; position: absolute; top: 800px" Width="210px">Search by Bus No.</asp:HyperLink>
<asp:HyperLink ID="HyperLink1" runat="server" NavigateUrl="~/home.aspx" Style="z-index: 104;
left: 928px; position: absolute; top: 662px" Width="211px">Search Buses by Stops</asp:HyperLink>
</div>
</div>
</div>
<div style="font-size: 0.8em; text-align: center; margin-top: 1.0em; margin-bottom: 1.0em;">
</div>
</form></body>
</html>
"
Here is The CODE SEGMENT
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
public partial class searchstops_1 : System.Web.UI.Page
{
SqlConnection con = new SqlConnection();
SqlDataAdapter adp = new SqlDataAdapter();
DataSet ds = new DataSet();
protected void Page_Load(object sender, EventArgs e)
{
con.ConnectionString = ConfigurationManager.ConnectionStrings["dtcConnect"].ConnectionString;
con.Open();
lblsrc.Text = Session["source"].ToString();
lbldes.Text = Session["dest"].ToString();
String str;
str = "select *from busno where exists (select 1 from busroutes bs1 where bs1.busno=busno.buses and bs1.stops='" + Session["source"].ToString() + "') and exists (select 1 from busroutes bs2 where bs2.busno=busno.buses and bs2.stops='" + Session["dest"].ToString() + "')";
adp.SelectCommand = new SqlCommand(str, con);
adp.SelectCommand.ExecuteNonQuery();
adp.Fill(ds, "temp1");
RadioButtonList1.DataSource = ds.Tables["temp1"];
RadioButtonList1.DataTextField = "buses";
RadioButtonList1.DataValueField = "buses";
RadioButtonList1.DataBind();
}
protected void Button2_Click(object sender, EventArgs e)
{
Response.Redirect("searchstops.aspx");
}
protected void RadioButtonList1_SelectedIndexChanged(object sender, EventArgs e)
{
if (RadioButtonList1.SelectedIndex != -1)
lbltemp.Text = RadioButtonList1.SelectedItem.Text;
}
}
"
thanx for the help
|
|
|
|
|
Thanx Paddy..my problem was solved...
|
|
|
|
|
That error will occur if you click the button when you have not selected any of the radio buttons on the RadioButtonList1. So you need to check whether the selection has first happened. Probably using:
if (RadioButtonList1.SelectedIndex != -1)
lbltemp.Text = RadioButtonList1.SelectedItem.Text;
|
|
|
|
|
I am inserting record in table using stored procedure.
CREATE PROCEDURE add_member(
@UserName Varchar( 50 ),
@Password Varchar( 50 ),
@dob datetime,
@education Varchar(50),
@designation Varchar(50),
@name Varchar(50)
) AS
If Exists( SELECT username FROM member WHERE username = @username )
RETURN -1
ELSE
BEGIN
DECLARE @ID int -- new ID value holder
INSERT member (
username, password, dob, education, designation, name
) VALUES (
@username, @password, @dob, @education, @designation, @name
)
-- get the new identity column value
SET @id = @@IDENTITY
END
GO
-------------------------------
I am using classic asp to add records in this way -
sql = "add_member " & "'" & request.form("username") & "'" & "," & "'" & request.form("password") & "'" & "," & "'2/2/2'" & "," & request.form("education") & "," & request.form("designation") & "," & "'" & request.form("name") & "'"
set rsAdd = Server.CreateObject("ADODB.Recordset")
rsAdd.Open sql, con
Its adding new record successfully But I am not able to read id of newly added record.
Plzzzzzzz help
|
|
|
|
|
That's because you aren't returning it. You set @ID, but you need to either set an output parameter or select @ID to return it to your code.
Bob
Ashfield Consultants Ltd
|
|
|
|
|
How to return and read in asp please explain in detail
Thanks in advance
|
|
|
|
|
You can either use an OUTPUT parameter in your query (search SQL Help for OUTPUT PARAMETER) or simply do a select and return the value in a recordset just like any other select statement does. An output parameter is more efficient.
To be honest, its so long since I used ADODB that I can't remember the syntax for retriving output parameters, but I do remeber you have to close the recordset first, strange as it seems.
Hopefully this will give you some pointers to enable you to resolve your problem after a little work on Google.
Bob
Ashfield Consultants Ltd
|
|
|
|
|
Add this as you last line.
Select @ID as ID
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Then How to read this value in asp
|
|
|
|
|
The resilt can be used as either executescalar directly to a varaible or as a dataset/table using .fill.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Hi dear,
I have one problem so u please solve that.
i am using sql server 2000.
In my working time sudennly sql server service manager is stopped,then i tried to start the sql server service manager,but it can't start...how to solve this problem...
please help me.
thanks in advance...
modified on Thursday, October 23, 2008 5:45 AM
|
|
|
|
|
Have you looked in task manager to see if its really gone? You may have to kill the process. Failing that, how about a reboot?
Bob
Ashfield Consultants Ltd
|
|
|
|
|
Hi...
can anyone please tell me "What are the various debug visualizers in visual studio ?"
thanks
deep.
|
|
|
|
|
Text Visualizer, XML Visualizer, HTML Visualizer
|
|
|
|
|
I have a problem when rollback a transaction. I create a stored procedure as follow:
CREATE PROCEDURE [dbo].[sp_test] AS
begin transaction
declare @Res int
select * into abc from sysusers
delete from abc123 --an error is raised cause there is no abc123 table
Set @Res = @@Error
if @Res <> 0
Rollback transaction
else
Commit transaction
When I execute this stored procedure from Querry Analyzer:
Exec sp_test
It shows an error message:
Invalid object name 'abc123'.
Transaction count after EXECUTE indicates that a COMMIT or ROLLBACK TRANSACTION statement is missing. Previous count = 0, current count = 1.
The problem here is that: when a statement makes error (select,delete, insert), SQL Server 2000 stop executing other statement. So, the rollback transaction statement has no meaning.
Please help me to solve this problem. All I want is to rollback a stored procedure when never there is an error.
Thanks.
adfafafa
|
|
|
|
|
If there is no table abc123 then the proc will not compile so you are not getting a data error you are getting a syntax error in your code.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
I create this proc in SQL Server 2000 and I think this proc will be compiled because there is no syntax error (I have checked syntax error after creating). Instead, it will cause run-time error because there is no abc123 table in the data base.
The problem is SQL Server 2000 stop executing other statement when it gets an error in select,delete,insert or update statement.
I've tried to use:
SET XACT_ABORT ON
to rollback other statements in the transaction but it still making error cause: ROLLBACK or COMMIT are not executed after BEGIN TRAN.
Please run my proc then help me to solve this problem.
Thank you very much.
CREATE PROCEDURE [dbo].[sp_test] AS
SET XACT_ABORT ON
DECLARE @Res int
begin transaction
select * into abc from sysusers
delete from abc123
Set @Res = @@ERROR
if @Res <> 0
ROLLBACK TRANSACTION
else
COMMIT TRANSACTION
GO
adfafafa
|
|
|
|