|
see Colin Angus Mackay,
i wrote the code like
---
dim Conn as New connect ' the file named connect.vb
dim dr as sqldatareader
dim query as string
query="select * from enquiry"
' Error occur in below sentence
dr=Conn.adpter(query) ' it call adpter(string)
if dr.Read then
end if
---
The code written in adpter()
Public Function adpter(ByVal pstr As String) As SqlDataReader
dim s as sqlDataReader
dim conn as new sqlconnection
dim cmd as sqlcommand
conn.open()
cmd=New sqlcommand(pstr,conn)
s=cmd.executereader()
return s
end function
---
This function works properly 100% with other web forms..
but in this form i got the error...
so help me..
Dipan Patel.
|
|
|
|
|
dipanmaster4u wrote: This function works properly 100% with other web forms..
Either this statement is false, or the code you posted is not the code you are using. The code you have posted cannot work as it would throw an exception about a lack of connection string.
"On two occasions, I have been asked [by members of Parliament], 'Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out?' I am not able to rightly apprehend the kind of confusion of ideas that could provoke such a question."
--Charles Babbage (1791-1871)
My: Website | Blog
|
|
|
|
|
hello sir,
i already this function in 20 webforms...
and works successfully...
but in one form it not worked..
so there is not way to say that this code is wrong...
Dipan Patel.
|
|
|
|
|
dipanmaster4u wrote: so there is not way to say that this code is wrong...
Then you did not post the actual code you are using because there is no connection string and without a connection string you cannot access any database.
You need to post the actual code that you are using otherwise it does not help me to help you!
"On two occasions, I have been asked [by members of Parliament], 'Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out?' I am not able to rightly apprehend the kind of confusion of ideas that could provoke such a question."
--Charles Babbage (1791-1871)
My: Website | Blog
|
|
|
|
|
--
this is code for connect.vb
Imports System.Data.SqlClient
Public Class connect
Dim str As String
Dim conn As New SqlConnection
Public ds As DataSet
Dim cmd As SqlCommand
Public Sub setconnection()
str = ConfigurationSettings.AppSettings("connstr")
conn.ConnectionString = str
End Sub
Public Function adpter(ByVal pstr As String) As SqlDataReader
Dim s As SqlDataReader
conn.Open()
cmd = New SqlCommand(pstr, conn)
'cmd.CommandTimeout = 15
s = cmd.ExecuteReader()
Return s
End Function
end class
-----
In my "fees.aspx" form
Imports System.Data.SqlClient
Public Class RegularFees
Inherits System.Web.UI.Page
Dim Conn As New connect
Private Sub SAVE_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SAVE.Click
Dim dr As SqlDataReader
Dim query as String
query = "Select * from ENQUIRY where enquiryformno=2"
dr = Conn.adpter(query)
If dr.Read Then
txtPayment.text=dr(0)
End If
End Sub
End class
--------
so u better try it...
Dipan Patel.
|
|
|
|
|
A number of possibilities.
1. The table is large and it takes the SQL Server a long time to filter on enquiryformno . Indexing that column might help speed things up.
2. You don't seem to close the SqlDataReader . It is possible that the SQL Server has locks on objects and it is waiting for those locks to be released. So, once you've used your Data Reader remember to Close it.
3. You SELECT * yet only get the first column of the first row. You would be better using SELECT justOneColumnName with ExecuteScalar rather than use a SqlDataReader . This would automatically solve 2 also.
"On two occasions, I have been asked [by members of Parliament], 'Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out?' I am not able to rightly apprehend the kind of confusion of ideas that could provoke such a question."
--Charles Babbage (1791-1871)
My: Website | Blog
|
|
|
|
|
sir i write the conn.close()
in " if dr.read then ...after the dr(0).
so not worry about the connection close..
and writing the executescalar in this..
it also gives the same error...
i take also only one column name....
Dipan Patel.
|
|
|
|
|
I don't see where the connection or Data Reader are being closed.
"On two occasions, I have been asked [by members of Parliament], 'Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out?' I am not able to rightly apprehend the kind of confusion of ideas that could provoke such a question."
--Charles Babbage (1791-1871)
My: Website | Blog
|
|
|
|
|
To add. If you dont call dispose on the connection object, It will not pool the connection and will eventually cause timeouts. Thats because they are never really sent back to the pool without calling dispose.
1 line of code equals many bugs. So don't write any!!
|
|
|
|
|
Hi,
I Have a dropdownlist and I want to get the value of this dropdownlist into a textbox using javascript.I have the code but it is giving me error.
Can u send me the script or this and the procedure how to implement in .net
Regards,
Uma
|
|
|
|
|
Dear,
I think the below function will solve the problem.
try it. all the best.
<br />
function getValue()<br />
{<br />
var index, text, value;<br />
index = document.getElementById("dropdownlistID").selectedIndex;<br />
text = document.getElementById("dropdownlistID").options[index].text;<br />
value = document.getElementById("dropdownlistID").options[index].value;<br />
document.getElementById("TextBoxID").value = value;<br />
}<br />
|
|
|
|
|
Hi there,
can you post ur code here??? and wat the error you faced???
<< >>
|
|
|
|
|
How to access usercontrol's Server side objects from the aspx codebehind that has teh usercontrol
Ramya
|
|
|
|
|
i didn't understand your question, server side of every server control is accesible from codebehind
sameer sood
|
|
|
|
|
I am having a usercontrol say address.ascx with a TextBox named txtStreet
Using the address.ascx Usercontrol in Register.aspx page Now my question is how to access the object "txtStreet" in Register.aspx Codebehind file
I think my question is clear now.
Ramya
-- modified at 0:50 Thursday 11th May, 2006
|
|
|
|
|
u can create properties for ur controls and eccess text property of that control, i mean that the place where u hv designed control control.ascx there make a public property
ex
public string Addresstext
{
get
{ return control.text;
}
set
{
control.text = value;
}
}
or if u wan't the whole control than you have to make attributes public which is not safe
there's another solution
use
System.Web.UI.Control.FindControl(string controlname)
USe Msdn to knw about it
it finds a control in a control nd returns it scanning by name
i hope ur querry has been answered
sameer sood
|
|
|
|
|
How can I display an image in the image box from a database (SQL Server2000) ?
Platform : VS.net2005( C# & ASP.net )
Data type in server: Image
Arpita
|
|
|
|
|
Well Hello Every One.
I am facing a problem on posting a client path eg:"c:/Name.doc"
using the javascript.
strFileName ="c:/Name.doc"
strScript = "javascript:void (window.open('" + strFileName + "','DocumentPreview'))"
But this give me a Access denied.As an error.
what is the best possible way to open the client path on browser.
Plz help me out by providing solution.
Thanks in advance.
Tirthesh Jain
|
|
|
|
|
As far as I am aware, standard javascript is not allowed access to a hard drive file system. To access a hard drives file system you will need to either use ActiveX objects or VB Script objects such as
for Javascripted ActiveX objects ...
function ShowFileInfo(filespec)
{
var fso, f, s;
fso = new ActiveXObject("Scripting.FileSystemObject");
f = fso.GetFile(filespec);
s = f.DateCreated;
return(s);
}
for VB Script ...
Function ShowDateCreated(filespec)
Dim fso, f
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.GetFile(filespec)
ShowDateCreated = f.DateCreated
End Function
But please note the security implecations of using above in a web page. Data above taken from MS JScript run-time reference and MS VB Scripting Edition Reference.
modified 1-Aug-19 21:02pm.
|
|
|
|
|
Thank's Abbottra for sending me your response.
I think it may solve the problem.If it is not than i get back to you for further help.
Thank's once again.
Tirthesh Jain
|
|
|
|
|
you should use the HtmlInputFile. I think in VS2005 is called HtmlUploadFIle.
Have them pick the file. You do not have access to the clients folders. And most people don't let ActiveX dll's run on thier machine
1 line of code equals many bugs. So don't write any!!
|
|
|
|
|
Thank's Ista for sending me reply.
Tirthesh jain
|
|
|
|
|
Hi,
I am developing web based application in asp.net.Actually I need the best solution or any idea of my problem.
I maintain user login time; log out time and how many times WebPages hit by particular user. Let us assume user hits result.aspx page 20 times, so I have to store 20 in the database. There are several pages in my application. I have done like this for each page when post back property is false then I update or insert in the database. But .each time I hit the database when page first time loads which effects on performance.. If any body have some idea or developed such type of application. Please help me.
Regards,
rajesh
|
|
|
|
|
for this u can use a session variable to store the number of times it was hit and after a certain number it can br reset to append the database value,also if u ask abt crashes then u can store in cookies as well as the Profile object can be useful(though it itself requires a database hit)
sameer sood
|
|
|
|
|
Thanks sameer,
I will try to use profile object.do let me know , profile object is available in asp.net v1.1 or not?
Again Thanks for help.
rajesh
|
|
|
|