Wrox Programmer Forums
|
ASP.NET 3.5 Basics If you are new to ASP or ASP.NET programming with version 3.5, this is the forum to begin asking questions. Please also see the Visual Web Developer 2008 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 3.5 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 16th, 2009, 03:00 AM
Registered User
 
Join Date: Jul 2009
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default table join problem

public DataTable HomeFriend()
{
DataSet obj1 = new DataSet();
objAdapter = new SqlDataAdapter("SELECT EMPLOYEE_MASTER.emp_fname, EMPLOYEE_MASTER.emp_lname FROM EMPLOYEE_MASTER INNER JOIN FRIENDLIST_MASTER ON EMPLOYEE_MASTER.emp_id = FRIENDLIST_MASTER.friendlist_id", objConnection);
objAdapter.Fill(obj1);
return obj1.Tables[1];
}
have problem in returning table
in the broswer.
plz solve this query
 
Old July 16th, 2009, 09:06 AM
Lee Dumond's Avatar
Wrox Author
 
Join Date: Jan 2008
Posts: 923
Thanks: 12
Thanked 166 Times in 162 Posts
Default

Maybe try return obj1.Tables[0]
__________________
Visit my blog at http://leedumond.com
Follow me on Twitter: http://twitter.com/LeeDumond

Code:
if (this.PostHelpedYou)
{
   ClickThanksButton(); 
}
 
Old July 24th, 2009, 03:33 AM
Registered User
 
Join Date: Sep 2008
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to hi.huangls
Default

public DataTable HomeFriend()
{
DataSet obj1 = new DataSet();
objAdapter = new SqlDataAdapter("SELECT EMPLOYEE_MASTER.emp_fname, EMPLOYEE_MASTER.emp_lname FROM EMPLOYEE_MASTER INNER JOIN FRIENDLIST_MASTER ON EMPLOYEE_MASTER.emp_id = FRIENDLIST_MASTER.friendlist_id", objConnection);
objAdapter.Fill(obj1);
return obj1.Tables[1];
}

it appears that you have just use one SQL statement in your code,
so you need to return obj[1].Tables[0],not Tables[1];
it begins with 0,not 1;just like Array.
 
Old July 24th, 2009, 08:49 AM
Registered User
 
Join Date: Apr 2009
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to Lalit Bhardwaj Send a message via Yahoo to Lalit Bhardwaj
Default Login Form problem

Hello Sir,

I hav some problem in login form codding plz guide me , i am sending codding of this form,
mports System.Data.SqlClient
PublicClass Form1
Private constr AsString = "initial catalog=strack; data source=.; integrated security=true"
Private cn As SqlConnection
Private da As SqlDataAdapter
Private dt As DataTable
Private cmd As SqlCommand



PrivateSub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) HandlesMyBase.Load

cn = New SqlConnection(constr)
cmd = New SqlCommand("Select unm from usrn order by unm asc", cn)
da = New SqlDataAdapter
da.SelectCommand = cmd
dt = New DataTable
da.Fill(dt)
ComboBox1.DataSource = dt
ComboBox1.DisplayMember = "UNM"
EndSub
PrivateSub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Me.Close()
EndSub
PrivateSub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
cn = New SqlConnection(constr)
cmd = New SqlCommand("SELECT count(*) FROM usrn Where unm = '" & ComboBox1.SelectedItem.ToString() & "' and upw = '" & TextBox1.Text & "'", cn)
'cmd = New SqlCommand("SELECT uid FROM usrn Where unm = '" & ComboBox1.SelectedItem.ToString() & "' and upw = '" & TextBox1.Text & "'", cn)
'Try
cn.Open()
'Catch ex As Exception
' MessageBox.Show("Error Connecting to Database: " & ex.Message)
'End Try
Dim i AsInteger
i = (cmd.ExecuteScalar()).ToString()
If (i = 1) Then
Form2.Show()
Else
MsgBox("Plz enter the correct password")
EndIf
'da.SelectCommand = cmd
'Dim dr As SqlDataReader = cmd.ExecuteReader()
'If (dr.HasRows = 1) Then
' 'MessageBox.Show("Invalid Login Details", "Login Error", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1, MessageBoxOptions.DefaultDesktopOnly, AcceptButton)
' Form2.Show()
'Else
'MsgBox("Invalid password")
'End If
cn.Close()
EndSub
EndClass
 
Old July 27th, 2009, 09:39 AM
maxmax
Guest
 
Posts: n/a
Default

this willl gives answer to your solution

public DataTable HomeFriend()
{
DataSet obj1 = new DataSet();
objAdapter = new SqlDataAdapter("SELECT EMPLOYEE_MASTER.emp_fname, EMPLOYEE_MASTER.emp_lname FROM EMPLOYEE_MASTER INNER JOIN FRIENDLIST_MASTER ON EMPLOYEE_MASTER.emp_id = FRIENDLIST_MASTER.friendlist_id", objConnection);
objAdapter.Fill(obj1);
return obj1.Tables[1];
}


also for further clarification see this link
http://codesforprogrammers.blogspot.com/





Similar Threads
Thread Thread Starter Forum Replies Last Post
could i join function(return table) with a table alyeng2000 SQL Server 2000 6 September 30th, 2004 07:23 AM
Oracle 8i inner join and left join problem puteri_84 Oracle 2 August 19th, 2004 07:14 AM
Table join problem Chapter 12, p 436 PHP-Beg tomasz BOOK: Beginning PHP4/PHP 5 ISBN: 978-0-7645-4364-7; v5 ISBN: 978-0-7645-5783-5 2 August 31st, 2003 12:56 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.