|
Hello friends! Please I need your help over this issue. I have asp.net application using sql as backend. In my database, I have two fields(authorName and txtbkTitle) In this application, authors can insert as many textbooks as they want into the database provided the authors name remains unchanged (i.e if John Kyle is an author, all the textbooks he will save, will have John Kyle as their author's name). I know how to search the database for a specific textbook but this is not the way I want it. What I want is that, when the author enter his/her name, all textbooks written by that author should be displayed and bind to datalist control leaving the other authors textbooks behind. Sample codes, links will be welcome. Thanks in advance!!!
|
|
|
|
|
You need to decide when you are going to start looking for the books, after the first character, after 2 or 3 characters or when the user presses the search button.
The search requires a round trip to the database and the volume returned will cause a delay, depends on your database size.
Your query would probably look something like
Select ID,Title,FirstName, Surname from vwBookAuthor where Surname like 'K%' or FirstName like 'K%'
Once you have that from the database you simply filter it in your codebehind or pass the list to the client and filter it based on further input. If the latency on 1 character is too big then wait for 2 or 3 characters to begin the search.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Thanks Mycroft, your reply was helpful. But it only retrieved one record, and I suggest that if I can bind the results found to a datalist, then everything will display. This is what I have tried so far:
Dim cn As new SqlDatasource
Sub Connect()
Try
If cn.State = Data.ConnectionState.Open Then cn.Close()
cn.ConnectionString =ConfigurationManager.ConnectionStrings("infoConnectionString").ConnectionString
cn.Open()
Catch ex As Exception
End Try
End Sub
Protected Sub btnlogin_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnlogin.Click
Connect()
Dim cmd As New SqlCommand
cmd.Connection = cn
cmd.CommandText = "select * from Bkstbl where Author like txtauthor.Text and Password=@Password
cmd.Parameters.AddWithValue("@author", txtauthor.Text)
cmd.Parameters.AddWithValue("@Password",txtpassword.Text)
Dim dr As SqlDataReader = cmd.ExecuteReader cmd.Parameters.Clear()
If dr.HasRows = True Then
'the aim of this code is to display only the textbooks written by the author
Datalist1.DataSource=dr("Txtbooks")
Datalist1.DataBind
dr.Close()
Else
dr.Close()
Msgbox("Invalid author name or password")
End If
End If
when I clicked on the search button, an error will show. This is the error that shown: InvalidOperationException unhandled user code.
For futher explanation, what I want is; taking for example John has 10 textbooks and James has 6 textbooks stored in database, when John wants to retrieve his textbooks from database, only his textbooks should display on the datalist excluding James textbooks(note: all textbooks saved by John, will have the same author name). Sorry if the request is too big, but please help me out, I am stuck...
|
|
|
|
|
Your question indicates a complete lack of knowledge of SQL. I suggest you get a book on SQL or at least some tutorials and work through them to get a basic grounding on the subject otherwise you are going to spend all your time on forums asking simple questions that a little learning will solve for you.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Yes Mycoft, you were right. I don't have to ask questions on forum all the time. But guess what, I congratulate you for saying something that got me thinking and now, I'm proud to generate my own six lines of code to search and display all records of a specific query. Guess what again, this time, I did it on my own without any search or reading of books. Once again, thanks alot!!! But one more thing and I hope you will tell me this time because I have tried but couldn't figure it out. My connection string is Data source=Emmanuel\Okugbe;Initial Catalog=info; user ID=sa; Password=pwd"
when I copied this application to another system, there was build error. Now the question is, how can I modify my web.config and my datasource(connection string) so that it can run in all systems without making any changes in that system? Please help!!!
|
|
|
|
|
Yeap, I got it. Thanks Holmes
|
|
|
|
|
For instance for a HTML control:
<img id="img1" src="Images/.../1.jpg" alt="Tile #1" />
How to catch up the img1 in C# code (e.g. img1.src = "xxx";)? Thanks if you can provide your hint.
|
|
|
|
|
|
I want to catch up the control in C# (e.g. image1.src = "xxxx";). Thanks.
|
|
|
|
|
Member 10447319 wrote: I want to catch up the control in C# (e.g. image1.src = "xxxx";). That link also with C# code, Re-check.
|
|
|
|
|
thatraja wrote: Re-check
Now there is a major assumption!
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
|
|
You need to put runat="server" on the tag if you want to access it in C#.
There are only 10 types of people in the world, those who understand binary and those who don't.
|
|
|
|
|
1,add
runat="server" to your img tag, this let your C# code can access your tag;
2,in your C# code, use
this.img1.src to access the img source attr.
this method can using in all html tags
|
|
|
|
|
hi i am intresting web devlopment but i confused which programming is better?
plz replay
my prefrce is 1. php
2. asp.net
|
|
|
|
|
You should have searched Google first. Check this
PHP vs ASP.net Comparison[^]
Besides it's better to choose based on your interest & past experience(For example, If you're VB6 or Classic ASP guy then go with ASP.NET.)
|
|
|
|
|
And what answer do you really expect asking such question on asp.net forum?
--
"My software never has bugs. It just develops random features."
|
|
|
|
|
I have not used PHP but to get your answer you should research samples of both kinds and see what syntax you feel comfortable with. Perhaps search job possibilities. I believe, but could be wrong, that ASP.Net will provide better job opportunities, at least for now.
I would recommend doing both. Get a job doing one and then do hobby work using the other.
There are only 10 types of people in the world, those who understand binary and those who don't.
|
|
|
|
|
I write in both PHP and asp.net now.
I took on a PHP project after not writing a line of PHP code in 6 years.
I like asp.net better, more control over what you can do. Teaches you better discipline and practices in writing good solid valid code. Working with strings is easier, because you can read files in one format, and convert it to another. I think good ASP.Net Programmers are better in the long run than PHP script writers.
So funny, I'm writing PHP right now at the moment. Picking PHP back up was pretty easy. PHP is a lot different, You write code to get data, manipulate data and test against operators, and then literally echo or spit out HTML.
In my opinion,
one of the pros to PHP is that there are more PHP jobs out there in my area to make money from than ASP.Net jobs. Nobody uses ASP.net where I live. The PHP jobs are very easy, because so many PHP people in my area think there really good, but lack the discipline or knowledge of how to encode and decode strings. Don't know what UTF-8 is, Unicode versus char character sets and so forth, The list goes on and on.
Seems like you can do things faster in PHP because it's so forgiving. But don't get stuck in the MySQL world or LAMP environment.
I really don't have a suggestion for you at the moment, and I'm not really that partial to one or the other anymore, 4 years ago yes I was to asp.net.
I think learning C++ actually made me a better programer for both PHP and ASP.Net. Regardless of which one you choose, it will take some time to really get good at it!
[update]
I agree with Ryan, the post above, and learn both at the same time. This way you can take advantage of more jobs that come up in your area. I think taking a side road by learning c++ and writing a Win32 app will propel you forward faster towards PHP and Asp.Net. It will teach you that you have to measure the size of everything, and to not waste resources like memory. Once you see how hard c++ is, writing the others will be easy.
modified 8-Dec-13 0:34am.
|
|
|
|
|
See the code below: I want to substitute some HTML code by a HTML / asp control, e.g.
<a class="thumb" name="1" href="Images/MapGallery/Large/Metro Service Area Dispatcher Calls Map_L.jpg"
title="Metro Service Area Dispatcher Calls Map" >
How to do it? Thanks.
|
|
|
|
|
Not clear, explain clearly with an example.
|
|
|
|
|
ASP:Hyperlink is the asp version of an a tag.
There are only 10 types of people in the world, those who understand binary and those who don't.
|
|
|
|
|
Dear all,
I am writing to seek help in writing a linq 'Where' clause to get results between two dates. I am using the following method below, which is currently showing an empty string.
[HttpGet]
public IEnumerable<database_WICs> GetDate(DateTime? start, DateTime? end)
{
var data = from c in db.database_WICs
where c.UploadDate == start &&
c.UploadDate == end
select c;
return data.ToList();
}
http://localhost:45361/api/data?start=25/11/2013&end=28/11/2013
Any help would be very much appreciated.
Many thanks
|
|
|
|
|
try this
[HttpGet]
public IEnumerable<database_WICs> GetDate(DateTime? start, DateTime? end)
{
var data = from c in db.database_WICs
where c.UploadDate == (start==null? c.UploadDate : start) &&
c.UploadDate == (end=null? c.UploadDate : end)
select c;
return data.ToList();
}
|
|
|
|