|
Without digging too much into your code, i assume this is the problem:
The code you use - working or not - retrieves the actual image file from the
database, not the url. You try to write this image to response stream on
page load - working or not. This is totally ok, you have to do the following:
- Build a Page or Httphandler which writes the image to response stream
similar to what you did in your code-snippet
- In ANOTHER page, you set the imageurl of your image to this previously implemented "image-page" or handler.
This way, you get the desired effect. If i understood you correctly.
|
|
|
|
|
Hi,
I am trying to retrieve specific records from a table by specifying the parameter value at run time but the following error keeps occuring when i pass in a value of the correct data type.
System.Data.OleDb.OleDbException: No value given for one or more required parameters.
at System.Data.OleDb.OleDbCommand.ExecuteCommandTextErrorHandling(OleDbHResult hr)
at System.Data.OleDb.OleDbCommand.ExecuteCommandTextForSingleResult(tagDBPARAMS dbParams, Object& executeResult)
at System.Data.OleDb.OleDbCommand.ExecuteCommandText(Object& executeResult)
at System.Data.OleDb.OleDbCommand.ExecuteCommand(CommandBehavior behavior, Object& executeResult)
at System.Data.OleDb.OleDbCommand.ExecuteReaderInternal(CommandBehavior behavior, String method)
at System.Data.OleDb.OleDbCommand.ExecuteReader(CommandBehavior behavior)
at System.Data.OleDb.OleDbCommand.System.Data.IDbCommand.ExecuteReader(CommandBehavior behavior)
at System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset, DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)
at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)
at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, String srcTable)
at Service.RetrieveComments(Int32 ThreadID)
As you can tell from the error message I am using Microsoft Access database provider.
The data type for ThreadID is 'Number' and the field size is set to 'long integer'. The field does exist in the table. In my code I even tried changing datatype from 'int' to 'uint64' but that didnt solve the problem.
Here is the code I had developed.
<br />
[WebMethod]<br />
public DataSet RetrieveComments(int ThreadID)<br />
{<br />
<br />
String queryString = "SELECT * FROM [Comments] WHERE" + "([ThreadID]=@ThreadID)";<br />
DataSet dataSet = new DataSet();<br />
String connString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|/MyDatabase.mdb;Persist Security Info=True";<br />
OleDbConnection dbConn = new OleDbConnection(connString);<br />
OleDbDataAdapter dbAdapter = new OleDbDataAdapter(queryString, dbConn);<br />
dbConn.Open()<br />
dbAdapter.Fill(dataSet, "Comments");<br />
dbConn.Close();<br />
return dataSet;<br />
}<br />
Is there anything wrong with the above code?
I have tried the above SQL query in MS Access and it runs fine providing I remove the quotes and the "+" operator.
I would much appreciate if anybody could assist me please?
Thanks in advance.
|
|
|
|
|
The problem is because you are not setting the parameter value. Also, you need to use the ? and not a named parameter @ThreadID in the query.
public DataSet RetrieveComments(int threadID)
{
String connString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|/MyDatabase.mdb;Persist Security Info=True";
OleDbConnection dbConn = new OleDbConnection(connString);
String queryString = "SELECT * FROM [Comments] WHERE [ThreadID] = ?";
OleDbCommand oleDbCommand = new OleDbCommand(queryString, dbConn);
oleDbCommand.Parameters.Add("@threadID", OleDbType.Integer, 10).Value = threadID;
OleDbDataAdapter dbAdapter = new OleDbDataAdapter();
dbAdapter.SelectCommand = oleDbCommand;
dbConn.Open();
DataSet dataSet = new DataSet();
dbAdapter.Fill(dataSet, "Comments");
dbConn.Close();
return dataSet;
}
Make sure the parameters and syntax are okay. Also use the using statement to make sure your objects get disposed properly.
|
|
|
|
|
String queryString = "SELECT * FROM [Comments] WHERE [ThreadID]=" + ThreadID;
Can this work?
|
|
|
|
|
|
I have a master content web page application. I was told that I can set the style in the code behind by using the following:
if (Request.Browser.Version == "8.0")
Page.StyleSheetTheme = "Theme";
I have put this code in both the onLoad and the onInit in the content page and every time I run it I get the following error:
'The StyleSheetTheme property cannot be set, please override the property instead.'
Can anyone help.
Thanks,
Steve Holdorf
|
|
|
|
|
|
Hi Guys,
I want to implement following architecture and want to check with you if it generally makes sense, what you think about it and whether I could do it in a better way.
There is a gaming server which can provide information on the fly using a C++ plugin. I'd like to use this information, process it and display on web so people can look and see what's happening in the game without having the actual game. So I decided to open a TCP/IP connection between the gaming server and a web server (which will be sitting on a web hosting site, haven't decided which one yet). My worry is whether I'll be able to use the web server as a TCP/IP communication server, so the game plugin can connect to my web server listening for incomming connections on a background thread and receive the information.
Facts:
Gaming server running C++ game and a TCP/IP client sending data potentionally every second
Web Server (ASP.NET + Silverlight 4) running a TCP/IP server on a background thread listening for game server(s - will be potentionally more) and waiting for data.
I know it's a very trick question, but do you think that this architecture makes sense? Do you think I'll be able to connect to my webserver using TCP/IP from outside? Or would a different protocol by better? (sending data using http, but I'd like to avoid that as I think it would be slower and I would not be able to talk back to the gaming server if I needed).
Regards,
Stevo
zilo
|
|
|
|
|
You will have to first make sure that the hosting site you are using allows TCP/IP communications, most probably only allow HTTP outbound only.
My suggestion is (and not the only suggestion), if this is possible with the plugin you mentioned, have the plugin write to a database all the results you are wanting to see. Create a web service that will be used by the web page to query the database for the updated data. You can have the plugin update the database as much as you want and query the database as much as you want. So the performance will be there like any other web site.
If you can connect via TCP/IP to the host and from the game server, you could use Remoting and create an http/tcp channel to do this as well.
Hope this helps a little. There are more ways to do this, but only have time to post this suggestion.
|
|
|
|
|
|
hello
i am new to this and i am doing my assignment with vs2003. I need to create simple one page web project in vs2003 with one datagrid so I connect to northwind database in server ex. in vs 2003 and then drag a datagrid and then genereate dataset and configure dataset with database
but when i run the project it gives me error
Server Error in '/WebApplication3' Application.
--------------------------------------------------------------------------------
The SELECT permission was denied on the object 'Employees', database 'Northwind', schema 'dbo'.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Data.SqlClient.SqlException: The SELECT permission was denied on the object 'Employees', database 'Northwind', schema 'dbo'.
Source Error:
Line 192: Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Line 193: 'Put user code to initialize the page here
Line 194: SqlDataAdapter1.Fill(DataSet11)
Line 195:
Line 196: End Sub
Source File: c:\inetpub\wwwroot\WebApplication3\WebForm1.aspx.vb Line: 194
Stack Trace:
[SqlException: The SELECT permission was denied on the object 'Employees', database 'Northwind', schema 'dbo'.]
System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream)
System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior)
System.Data.SqlClient.SqlCommand.System.Data.IDbCommand.ExecuteReader(CommandBehavior behavior)
System.Data.Common.DbDataAdapter.FillFromCommand(Object data, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)
System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)
System.Data.Common.DbDataAdapter.Fill(DataSet dataSet)
WebApplication3.WebForm1.Page_Load(Object sender, EventArgs e) in c:\inetpub\wwwroot\WebApplication3\WebForm1.aspx.vb:194
System.Web.UI.Control.OnLoad(EventArgs e)
System.Web.UI.Control.LoadRecursive()
System.Web.UI.Page.ProcessRequestMain()
--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:1.1.4322.2443; ASP.NET Version:1.1.4322.2443
waiting for your kind help
|
|
|
|
|
The error message says it all, the credentials you are using don't have SELECT access to the table. Use different credentials or add the rights to the user in Sql Server
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
hello sir
thanks for your rep.
as you mentioned but i dont know how to do it so could you please tell me how to do it
waiting for your kind help
thanks
|
|
|
|
|
Don't know how to do what? Use a different connection string? Change permissions in SQL Server? If it's the former, then you need more help than just that. If the latter, then contact the SQL admin.
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
hello sir
yes it's done now thanks for your kind help
thanks again
|
|
|
|
|
Dear Freinds,
I have taken C1Toolbar on my master page, on click event of this toolbar, i try to generate excel from a grid on my content page.
There is one Filter button on Content page, for grid filtering.
When i click on Master page toolbar to generate excel report, and excel is re-directed on content page by "Response.Redirect("Excel");" statement.
After this process, whenever i click on Filter button on content page, master page toolbar event is called and the excel report is generated again. I dont know what is going wrong?
However, when i remove the "Response.Redirect("Excel");" statement the system works absolutely normal.
I dont know what is wrong? Please help.
I am exposing Master Page controls as public property and registering/calling its event on content pages.
Your expert opinion required.
Regards
|
|
|
|
|
Soulds like you are not checking IsPostBack
public void page_Load(...)
{
if(!IsPostBack)
{
Redirect...
}
}
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
My web form contains a popupextender when the popup is opened,after closing the popup the events outside the popoup like button click and dropdownselectedindex changed were not firing for the first time,second time the events are firing. Can anybody suggest me a sloution.....
|
|
|
|
|
hai,
Please make sure that you have included the
if(!IsPostBack)
{}
in the page load..
|
|
|
|
|
Recently One of my friend asked me to do a website for selling his audios/videos something education tutorials. I'm working in ASP.NET/SQL. So i was suggested him by creating shopping cart with online payment gateway.
But he told me an issue about shipping. He can possible maximum with in country, otherwise it will be critical because Some of CDs are in less price comparing the shipping price so some body don't want to that. He suggested me Online download if possible. After payment he can download the file with password access which works only once.
But i suspect it will not work out perfectly. I need to block the users who don't have access & how to determine the user downloaded the file or not, because i'll expire the password once he clicked the download link. So please suggest me, what to do for this. Any links also fine for me.
Thanks in advance.
|
|
|
|
|
I beleive, one thing you can do.. once the payment gets suceeded, you can show him a link to download the product and also you can send a mail with the link, and this will be only when after the payment.Now when the user clicks on the link , save in db that this product got downloaded corresponding to this payment.
So you can have some ID mapping to transaction and the product, you can send it in querystring of the link also if you have some login mechanism then you can save it also with the transaction and with the downloading user for cross verification.
So when user clicks on the link, check the db if its already downloaded or not if yes show the message else let the user download and update the DB as downloaded
|
|
|
|
|
Hi,
Iam developing a intranet site and want to track the users, iam using session for this purpose, Iam using windows authentication mode so there is no login form here..
when a user clicks the url for the first time a new session is created and at that time Iam adding a entry in a table(say :Users) with username and logintime and sessionid etc.,
Below is the logic Iam using in form_load event of Default.aspx
If session("user") is nothing then
---create new session (at this point Iam adding a entry in table(users))
Else
--- use the same session and continue the work.
End if
When i check the users in the table some entries are created with same userid and same sessinids with different login time, how this is possible...
I just want to know who is logged in and what time...
could someone explain, why this is happening..
Regards
Imtiaz A.K
|
|
|
|
|
If your using InProc session state then the session may be dropped due to memory pressure and then recreated when the user next requests a page. ASP.Net will use a valid session id from cookie if the client provides one.
This could also happen if the web application is running with more than one process (web garden/web farm).
To avoid it, use an external session state server (such as SqlServer or State Server).
|
|
|
|
|
This could also happen if the web application is running with more than one process (web garden/web farm).
what does this mean could you please elaborate the solution...
Thanks...
Imtiaz A.K
|
|
|
|
|
It means that of your using inproc session state the session data is stored per process. Having more than one asp.net worker process will cause this type of session duplication.
When you have two or more worker processes on a single server its called a web garden. If you have more than one server its a web farm.
|
|
|
|