|
Right, thanks.
It is a server side decision, not a client's browser then.
I must remember to change the priorities, just in case a surreptitious .html gets in there.
---------------------------------
I will never again mention that I was the poster of the One Millionth Lounge Post, nor that it was complete drivel. Dalek Dave
CCC Link[ ^]
English League Tables - Live
|
|
|
|
|
That's correct. Remember that the browser has no knowledge of what the server can serve up to it.
|
|
|
|
|
|
dynamically creating aspx pages using xslt and xml
|
|
|
|
|
OK. What is the question?
Failure is not an option; it's the default selection.
|
|
|
|
|
Hi, i am currently doing a project on web service for wine. i have the wine table with wineName and wineType. Also i have the search function implemented in the webservice coding as well as a separate webform to call the function of the search function.
I have the following code for performing search in the search service:
<WebMethod()> _
Public Function Search(ByVal searchName As String) As System.Data.DataSet
Dim connectionString As String = ConfigurationManager.ConnectionStrings("ConnectionString").ConnectionString
Dim con As New SqlConnection(connectionString)
Dim selectSql As String = "SELECT * From Wine WHERE WineType='" & searchName + "'"
Dim selectAdapter As New Data.SqlClient.SqlDataAdapter(selectSql, con)
Dim ds As New Data.DataSet
con.Open()
selectAdapter.Fill(ds, "Wine")
con.Close()
Return ds
End Function
As for the webform, it's just a simple page with textbox labeled as searchName, a button and a gridView1 tied to ObjectDataSource.
This is the coding i have for webform:
Partial Class Search
Inherits System.Web.UI.Page
Dim searching As searchwine.Service = New searchwine.Service
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
If searchName.Text = "" Then
lblDisplayError.Text = "Can't search empty field!"
Else
Dim ds As DataSet = searching.Search(searchName.Text)
GridView1.DataSource = ds.Tables(0)
GridView1.DataBind()
GridView1.Visible = True
lblDisplayError.Visible = False
End If
End Sub
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
lblDisplayError.Text = ""
GridView1.Visible = False
End Sub
End Class
Everything seems fine but i have the following error when i want to do a search:
System.NullReferenceException: Object reference not set to an instance of an object.
at Service.Search(String searchName)
Can anyone help me out please? thank you very much
|
|
|
|
|
So what happens when you step through and debug it?
There are only 10 types of people in the world, those who understand binary and those who don't.
|
|
|
|
|
the error occurs at the following line of code:
Dim ds As DataSet = searching.Search(searchName.Text)
Is there any way that i can improve this line?
|
|
|
|
|
You are getting a null reference error. But you already have an if statement checking searchName.Text so it isn't searchName which means either searching is null or the error is actually occuring inside the searching.Search method.
I believe your error is actually happening within Search so try stepping into that function as you debug.
There are only 10 types of people in the world, those who understand binary and those who don't.
|
|
|
|
|
thanks ryan.
for my search service i have the following code
<WebMethod()> _
Public Function Search(ByVal searchName As String) As System.Data.DataSet
Dim connectionString As String = ConfigurationManager.ConnectionStrings("ConnectionString").ConnectionString
Dim MyConnection As New SqlConnection(connectionString)
Dim MyCommand As New SqlCommand()
MyCommand.Connection = MyConnection
MyCommand.CommandType = Data.CommandType.Text
MyCommand.CommandType = "SELECT * From Book WHERE WineType like @prmSearchName"
MyCommand.Parameters.AddWithValue("prmSearchName", "'%" & searchName & "%'")
MyCommand.Connection = MyConnection
Dim selectAdapter As New Data.SqlClient.SqlDataAdapter
Dim ds As New Data.DataSet
MyConnection.Open()
selectAdapter.Fill(ds, "Wine")
MyConnection.Close()
Return ds
End Function
does the code looks good to you?
|
|
|
|
|
Ya, I didn't notice anything wrong which is why I suggest you step into the web service, if you can. Is the web service in a different project? If so, put try catch around your code in the service (which you really should have anyway ) and hopefully you can see a stack trace of which line exactly is causing the issue.
There are only 10 types of people in the world, those who understand binary and those who don't.
|
|
|
|
|
thanks ryan for your replies. yes the web service is a different project. i did the web referencing and stuffs required to be brought in accordingly. but still the error exists.
|
|
|
|
|
So, when you debug is searching null? If not, the error is happening inside the webmethod so you need a way to debug that. For example, add a try catch and write to a log.
There are only 10 types of people in the world, those who understand binary and those who don't.
|
|
|
|
|
Suppose This Query
SELECT * From Wine WHERE WineType='ABC'
Return No Table
Then How Can You Set the Datasource Of Gridview1 to ds.tables[0]
GridView1.DataSource = ds.Tables(0)
Hope U Understand this.
|
|
|
|
|
hi.i want to read byte of save picture and show in fileUpload control.the below code dont work.please quidance me
while (dr.Read())
{
picture_fileUpload = (byte[])dr["picture"];
}
|
|
|
|
|
You can't assign a value to an upload control. What are you trying to accomplish?
Failure is not an option; it's the default selection.
|
|
|
|
|
this is edit page and i want that fileupload kept last image value and if we select new image then change its value
|
|
|
|
|
So display the existing image and check the FileUpload.HasFile property. If true then the user has selected a new file to be uploaded. Why make it more difficult?
Failure is not an option; it's the default selection.
|
|
|
|
|
but how to set the value to file upload control during postback ?
|
|
|
|
|
You DON'T set it. How many times do you need to be told this?
Failure is not an option; it's the default selection.
|
|
|
|
|
|
this is edit page and i want that fileupload kept last image value and if we select new image then change its value
|
|
|
|
|
OK - lets do it one step at a time.
Have you managed to save the uploaded image to wherever you want?
Shreekar
|
|
|
|
|
Have you even read this thread? The first post shows the OP is obtaining the image from a database. The question isn't about uploading an image.
Failure is not an option; it's the default selection.
|
|
|
|
|
Did you read the question?
Failure is not an option; it's the default selection.
|
|
|
|