473,397 Members | 1,949 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

How can I do this with parameter?

2
I am new to ASP.NET C# / VS2003
here is my sql command

SELECT tblStudentCourse.CourseID, tblStudents.StudentID, tblStudents.FirstName, tblStudents.SurName, tblUsers.UserID, tblUsers.Username
FROM (tblStudents INNER JOIN (tblCourses INNER JOIN tblStudentCourse ON tblCourses.CourseID = tblStudentCourse.CourseID) ON tblStudents.StudentID = tblStudentCourse.StudentID) INNER JOIN tblUsers ON tblStudents.StudentID = tblUsers.StudentID
where tblUsers.Username = @username;

SO after login with the username how can I get the result?

It not work when I try this

private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here


String @username;
@username = User.Identity.Name.ToString();
Response.Write(@username);
@username.Equals(this.oleDbDataAdapter1.SelectComm and.Parameters["@username"].Value.ToString());

this.DataGrid1.DataBind();
}

Thank you
Nov 16 '06 #1
1 1011
bnchd
3
I am new to ASP.NET C# / VS2003
here is my sql command

SELECT tblStudentCourse.CourseID, tblStudents.StudentID, tblStudents.FirstName, tblStudents.SurName, tblUsers.UserID, tblUsers.Username
FROM (tblStudents INNER JOIN (tblCourses INNER JOIN tblStudentCourse ON tblCourses.CourseID = tblStudentCourse.CourseID) ON tblStudents.StudentID = tblStudentCourse.StudentID) INNER JOIN tblUsers ON tblStudents.StudentID = tblUsers.StudentID
where tblUsers.Username = @username;

SO after login with the username how can I get the result?

It not work when I try this

private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here


String @username;
@username = User.Identity.Name.ToString();
Response.Write(@username);
@username.Equals(this.oleDbDataAdapter1.SelectComm and.Parameters["@username"].Value.ToString());

this.DataGrid1.DataBind();
}

Thank you

hi yui


Well its not clear what u r trying to do at page load .
but better method is that u use a SqlCommand and datatable


string commandText = SELECT tblStudentCourse.CourseID, tblStudents.StudentID, tblStudents.FirstName, tblStudents.SurName, tblUsers.UserID, tblUsers.Username
FROM (tblStudents INNER JOIN (tblCourses INNER JOIN tblStudentCourse ON tblCourses.CourseID = tblStudentCourse.CourseID) ON tblStudents.StudentID = tblStudentCourse.StudentID) INNER JOIN tblUsers ON tblStudents.StudentID = tblUsers.StudentID
where tblUsers.Username = @username;

SqlCommand cmd = new SqlCommand(commandText,<connection string>)


cmd.CommandType = CommandType.Text;
SqlDataAdapter adapter = new SqlDataAdapter();
adapter.SelectCommand = cmd;
DataTable dt = new DataTable();
adapter.Fill(dt);
adapter.Dispose();


Now u use this datatable to bind ur datagrid
Nov 17 '06 #2

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

Similar topics

2
by: John A Grandy | last post by:
Is there something special in XML about the name "Parameter" ... I am not able to XPATH query for nodes named "Parameter" <Root> <Category CategoryID="1"> <Elements> <Element...
7
by: Steve | last post by:
I used System.Diagnostics.Process.Start(str) to launch application. str is based on the registry setting, in registry, it might be str = rundll32.exe...
1
by: | last post by:
Hi, I've defined an ObjectDataSource and a parameterized DataSet. I would like it if I could pass the parameter value that describes the query that creates the DataSet as part of a user control...
0
by: Aws | last post by:
My crazy GridView !! I am using Visual Studio 2005, I have a problem with my GridView. I have one access .mdb table and when I update a record on the table EVERYTHING is perfect. I made a Web...
3
by: Robert | last post by:
What is the best way to pass a parameter to an ObjectDataSource. I am able to add a new parameter to the SelectParameters, but I would like to just assign a value to an existing parmeter at...
2
by: DC | last post by:
The Code <%@ import namespace="System" %> <%@ import namespace="System.Web" %> <%@ import namespace="System.Web.UI" %> <%@ import namespace="System.Web.UI.HtmlControls" %> <%@ import...
0
by: DC | last post by:
The problem I'm using the .NET GridView and FormView objects for the first time and im getting the error "An OleDbParameter with ParameterName '@ID' is not contained by this...
1
by: yoursteveis | last post by:
Dear all, I have created a main report (for monthly purchase summary) and a sub report (for monthly sales summary). I have linked main report with a parameter query (i.e. purchasesummary1) and...
5
by: puzzlecracker | last post by:
C++ standard says the following: I am reading through c++ standard and have a difficulty understanding the difference between these two terms. Thanks, puzzlecracker
2
by: Patrick Dreyer | last post by:
Hi, I'm struggling getting a cmdlet with parameter sets working. I'd like to support three different "flavors" for calling my cmdlet Run-SSHCmd: 1) run-sshcmd Command ...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...
0
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...
0
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...
0
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,...

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.