|
Hi! I am keep getting this error in my web application, here is what I am doing:
<pre> sqlDataSource sqlDataSource2 = new SqlDataSource();
sqlDataSource2.ID = "workoutScheduleDataSource";
Page.Controls.Add(sqlDataSource2);
sqlDataSource2.ConnectionString = WebConfigurationManager.ConnectionStrings["ClassScheduleConnString"].ConnectionString;
sqlDataSource2.SelectCommand = "SELECT Workout_Name, WorkoutType, MembersAttending, DateSelected, Explanation FROM WorkoutTable WHERE AddedBy = '" + user + "'";
gridviewWorkout.DataSource = sqlDataSource2;
gridviewWorkout.AutoGenerateSelectButton = true;
gridviewWorkout.DataBind();</pre>
when it gets to the last line gridviewWorkout.DataBind(), it gives me the error that: "A field or property with the name 'AddedBy' was not found on the selected data source." I am testing the query with SSMSE, at the same table, and it works just fine...but here I am getting error. Any help will be appreciated. Thx ahead, Laziale
|
|
|
|
|
In your binding in the markup, are you trying to bind a column called AddedBy, as it is not returned in your source.
|
|
|
|
|
here is what I have in my markup:
<pre> <asp:GridView ID="gridviewWorkout" runat="server" AutoGenerateColumns="false">
<Columns>
<asp:BoundField HeaderText="Workout Name" DataField="Workout_Name" />
<asp:BoundField HeaderText="Added By" DataField="AddedBy" />
<asp:BoundField HeaderText="Workout Type" DataField="WorkoutType" />
<asp:BoundField HeaderText="Members Attending" DataField="MembersAttending" />
<asp:BoundField HeaderText="Date" DataField="DateSelected" />
<asp:BoundField HeaderText="Explanation" DataField="Explanation" />
</Columns></pre>
within the DataField I have declared the columns as they are in my table in the database.
|
|
|
|
|
Yes, but your SQL statement does not actually return a column for the AddedBy, you just have it in your where clause.
|
|
|
|
|
I have this piece of code at another page within this project, and it works just fine:
<pre> SqlDataSource sqlDataSource1 = new SqlDataSource();
sqlDataSource1.ID = "trainingScheduledatasource";
Page.Controls.Add(sqlDataSource1);
sqlDataSource1.ConnectionString = WebConfigurationManager.ConnectionStrings["ClassScheduleConnString"].ConnectionString;
sqlDataSource1.SelectCommand = "SELECT Class_Name, ClassType, MembersAttending, Staff, DateSelected, Explanation FROM ClassSchedule WHERE AddedBy = '" + user + "'";
gridviewClass.DataSource = sqlDataSource1;
gridviewClass.AutoGenerateSelectButton = true;
gridviewClass.DataBind();</pre>
where is the difference? it looks same to me
|
|
|
|
|
That's very nice. You've said in your grid (in the markup), that you want to display data for a field called AddedBy.
When you bind the data, the grid goes and looks in your returned data for a field by that name. It's not there. Grid isn't happy and throws an error.
You need to put another field in your select statement for the first case, return the AddedBy field, or remove that column from the grid.
|
|
|
|
|
laziale wrote: WHERE AddedBy = '" + user + "'";
Error Says , AddedBy not found . Did you try with "Like " rather than "="
cheers,
Abhijit
|
|
|
|
|
no...it didn't help , thx anyway
|
|
|
|
|
Hi laziale,
The problem is with ur query bcoz u r applying a condition on AddedBy column but not selecting it from table its fine with the SSMSE,but since the column is getting bound in ur gridview ,thats why u r getting this error.
Just Replace Ur Query with
"SELECT Workout_Name, WorkoutType, MembersAttending, DateSelected, Explanation,AddedBy FROM WorkoutTable WHERE AddedBy = '" + user + "'";
Hope it will work........
|
|
|
|
|
thx for the reply, it worked for me. But I still don't know why is working on the different project within the same project when I am not selecting it the AddedBy column in the query, I am just using it in the WHERE condition. Thx and have a nice day, Laziale
|
|
|
|
|
Hi All
I have a RAR file uploaded on my site contains the SWF animations now i want to play those animation on my site. where
if user click on the Animation one link than 1.swf has to be played which is stored into that RAR file.
How could i achive the same. plz do answer with explanation
Regards
Yogesh Agarwal
|
|
|
|
|
you'll need to buy a library that supports RAR files, for a start. Then you'll need to save the file in your file system and write code to emit the right HTML to play the file.
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
I opened a new window on link button using javascript. Now i want to close the newly opened window and getback to the previous window on click event
|
|
|
|
|
Do you mean a popup window ? If so, just close it. If you mean you went forward a page, history.back() from memory does what you want. No, it's some sort of navigate method that you pass -1 to. Sorry, you'll have to google it.
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
Hi friends,
I have created voting system every user can vote not only registered users,so i want to add some security to it,i need some ideas on how to prevent multiuser voting.
I dont know exactly may be like checking cookies r session r something else.
|
|
|
|
|
The only way you can truely get it to be single user single vote is by making everyone register. Other than that you can do it by IP Address, but then only 1 person at a school can vote for example. There are other ways, but the best way is only registered users can vote. If you allow the unregistered to vote, you need to accept the fact that they can vote multiple times.
The best way to accelerate a Macintosh is at 9.8m/sec² - Marcus Dolengo
|
|
|
|
|
|
You're on the right track. Writing a cookie will help, the session is obviously useless, making me wonder if you understand how the cookie could help, or just threw some buzz words out there. You could write a cookie when someone votes, that uses an id to define the post that was voted on. Of course, users can delete the cookie, and you'd end up writing a lot of cookies, which is not ideal. So, once again, there's really no possible way to stop a person from voting, if they have not logged on. There's just no way to magically tell if the same person is voting again, or another person on the same machine, or the same person on another machine, etc.
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
Thanx Christian Graus,
It will bw usefull for me if u give me link that can guide me on how to write cookie.
|
|
|
|
|
here[^]. But, like I said, it won't actually work properly. It will stop only people who are not at all motivated to double vote on your site.
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
Thats k,no problem i goin to now something....
I will try it....
|
|
|
|
|
Hi friends,
I want to insert bulk data in my table. I am using the below query. But it giving exception. Could not Bulk Insert:File 'C:\ip-to-country.csv' does not exist.
BULK
INSERT tblAllCountryName
FROM 'C:\ip-to-country.csv'
WITH
(
FIELDTERMINATOR=',',
ROWTERMINATOR='\n'
)
GO
How to solve this proble. Could you please tell me? Hope your's reply soon.
Thanks & Regards
Every Successful Person Have A Painful Story
|
|
|
|
|
Guvera wrote: Subject: Could not Bulk Insert : Error Path does not exist.
Is this anything related to ASP.NET ?
cheers,
Abhijit
|
|
|
|
|
Hi dude,
Thanks for your reply. I got the solution. Just change data type for data variable.
Thanks & Regards
Every Successful Person Have A Painful Story
|
|
|
|
|
Does that file live on the server, or the computer on which you are viewing the page(I have to assume it is a page as you posted on the ASP.NET forum)?
If it doesn't live on the server, then that is why you are getting the error, the path does not exist. The query is being run on the server, not the machine viewing the page.
The best way to accelerate a Macintosh is at 9.8m/sec² - Marcus Dolengo
|
|
|
|