|
Hi, I get the exeception Value of 'Byte' cannot be converted to '1-dimensional array of Byte' when I run the following code.
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs)
Dim connect As String = "Data Source=localhost\sqlexpress;Initial Catalog=pubs;Integrated Security=True"
Dim sqlconnect As New System.Data.SqlClient.SqlConnection(connect)
Dim sqlcommand As New System.Data.SqlClient.SqlCommand("select * from Doc")
sqlcommand.Connection = sqlconnect
Dim dr As System.Data.SqlClient.SqlDataReader
sqlconnect.Open()
dr = sqlcommand.ExecuteReader()
While dr.Read()
Dim filename As String = dr("Title").ToString()
Dim contentType As String = dr("DocType").ToString()
Response.Clear()
Response.ContentType = contentType
Response.AddHeader("Content-Disposition", "attachment;filename=" + filename)
Response.BinaryWrite(CByte(dr("ContentDoc")))
Response.[End]()
End While
sqlconnect.Close()
End Sub
The line that is causing that problem is Response.BinaryWrite(CByte(dr("ContentDoc"))). Please help me fix this problem, thank you in advance for your help.
|
|
|
|
|
Well, for some reason, you seem to want to give sompeone the opportunity to download a file that's one byte in length. This is a mystery. Howevr, as you're converting dr("ContentDoc") to a single byte value, BinaryWrite is unable to accept that. Most people want to use BinaryWrite to write a file, which will be an array of bytes.
You should not use things like CByte, they are nasty VB6 rubbish only kept in VB.NET because of the fear of change in some VB6 users. Use the .NET stuff instead.
In this instance, I suspect the issue is that you want to convert to a byte array, instead of a byte.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Hello,
VS 2005
I have created a deployment web setup project for my web service.
It installs ok, but the customer want to install all the files in a specified location on their computer.
For example it currently defaults to inetpub\wwwroot\myWebService.
I am also using IIS 5.1
Many thanks for any suggestions,
Steve
-- modified at 18:43 Wednesday 8th August, 2007
|
|
|
|
|
Here's my situation... I have an ASP.NET 2.0 (VB.NET) page with a link button.
When a user clicks the button I need it to execute the code behind code for
the link button on click event. At the end of the code behind code for the
link button click event, I use JavaScript to popup another browser window
(using window.open). This all works fine.
The issue comes in when the user closes the popup and continues to work with
the site and they click the back button. If they click the back button to
the correct place, the popup window appears again, which I don't want. I
only want to popup to appear if the user clicks the link button on the page
in question, not by using the browser back button.
So, would anyone know how to prevent the popup window from "popping up" when
the user uses the browser back button?
it is not hitting the server when the browser back button is clicked(it is coming from local cache) .. Please help.
Thanks
Mohamed
|
|
|
|
|
Make your button actually link to the page you want to show, in a new window.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
I couldnt understand you. I was asking about IE browser back button.
|
|
|
|
|
If, instead of using a click event to generate your popup, your link just brought up a popup window, a new aspx file which was self contained, then there would be no browse history on the main page which is what's causing the current problem
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
I have a big treeview,And i need to print with all the nodes open. But
After printing the webpage i have seen that some nodes are missing at end of every page, because of lenght of the paper. I would like to know the proper way to
print huge treeview .
|
|
|
|
|
Hi
I have 2 textboxes .in first i m saving start date & in second i m saving end date.
if in first textbox i have 01/08/07 value & in 2nd textbox i have 31/08/07 .I weekly dates between these.
Can anyone help for this i want code for this in c# language syntax.
Thanks
CARECAREER
|
|
|
|
|
do you want to find how many weeks are between two dates or do you want to calculate something else bwtween two dates?
I Love SQL
|
|
|
|
|
i want to calculate weekly dates & want to save these dates in databse.
i have one dropdown in this values r daily,weekly,halfyearly,yearly.if i select weekly option &
2 textboxes r there,in 1st textbox 01/08/2007
2nd textbox 31/08/2007 values r there
then i want to show on weekly basis all dates between ist aug. to 31st aug.
Plz help me i need code in c# for this.
Thanks for replaying.
Care Career
|
|
|
|
|
Use the AddDays method on the DateTime class.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
I have one table
CREATE TABLE #T1(id int,Name varchar(10))
insert into #T1 (id,Name) values (1,'Haris')
insert into #T1 (id,Name) values (2,'Arshad')
CREATE TABLE #T2(id int,Reason varchar(5))
insert into #T2 (id,Reason) values (1,'X')
insert into #T2 (id,Reason) values (2,'Y')
insert into #T2 (id,Reason) values (1,'Z')
insert into #T2 (id,Reason) values (1,'X')
Now i need output like
Id Name Reason1 Reason2 Reason3 ......ReasonN
1 Haris X Z X
2 Arshad Y NULL NULL
Amit
|
|
|
|
|
I'm not sure that is possible. The best I can think of is to join to make the output like this:
Haris X
Haris Z
Haris X
Arshad Y
Once you get your data into a DataTable, you can manipulate it so that when it displays in a DataGrid it looks like the output you want. The problem is, there is no way to how many Reasons there are for each Name. So there is no way to make an output table that has an undetermined number of columns.
|
|
|
|
|
No looking for SQL Solution. I posted here becuase not got much reply from SQL forum....Thanks any way!!
|
|
|
|
|
Hi u have to make use of function returning table with in sql server where you have to pass the id.
Hello Forum
Always be in touch to help about the topic ASP.NET
|
|
|
|
|
Hi There
Do u know about DataRelation?
U can do it using datarelation
follow step
select all rows of table one and bind dataset ie. ds1
select all rows of table two with relation of table one like T1.Id=T2.Id and bind dataset ie. ds2
Now use datarelation
ie.
DataRelation dr = new DataRelation("new_relation", ds1.Tables[0].Columns[0], ds2.Tables[0].Columns[0]);<br />
ds1.Relations.Add(dr);
Make sure both ds have same column[0]
Best Regard
Pathan
---------------------------------------------------
|
|
|
|
|
Hello,
VS 2005
I have created a web setup using deployment project for installing a web service. The setup requires that the user enters the server settings. i.e. server, user id, database, and password.
I have used the interface which has the 4 text boxes. However, there is a security risk as the text box which the user will enter the password into is always in clear text. Is there a way in which you can have the text boxes on the user interface to hide what the user is entering.
Many thanks for any suggestions,
Steve
|
|
|
|
|
Okay, here's my situation...
I have three CheckBoxList.
#1 is a list of four states. When a state is checked off, a sql query to retrieve a list of cities is generated in the control's SelectedIndexChanged method that is assigned to a SqlDataSource control's SelectCommand property.
So far so good.
However, control #2 is supposed to generate a query to fill a third CheckBoxList of stores in each city based on the cities the user checks. What happens is control #1's SelectedIndexChanged method fires on the post back when an item is checked in control #2. I tried handling this by checking the query generated by control #1 against the query in the SqlDataSource bound to control #2, however the datasource resets back to its original query created at design time. The EnableViewState property is set to true so I can't figure out why this is happening. I was also thinking that I could check the "object sender" parameter passed to the SelectedIndexChanged method of control #1 but that seems to indicate that control #1 is what is causing the post back rather than control #2.
Another weird (to my Windows Forms based mind) is that when an item is selected in control #1, control #2's SelectedIndexChanged method isn't fired.
Both control #1 and control #2 are set to AutoPostBack and are identical except for formatting stuff and the fact that they are bound to different SqlDataSources.
control #3 doesn't post back, however just for the heck of it I set AutoPostBack to true. When an item is selected in control #3, control #1's SelectedIndexChanged method fires but again control #2's doesn't. Again, this is really weird because for the most part the controls are identical.
Help, my brain is melting! :v)
EDIT: I don't know if it makes a difference but control #1's values are hard coded so it isn't bound to a SqlDataSource
-- modified at 12:29 Wednesday 8th August, 2007
|
|
|
|
|
Hi all,
How can I refer to my HTML controls declared within <asp:content> tag in javascript?
document.frmMain.txtName does not work.
Any highlights!!
|
|
|
|
|
Does document.getElementsByTagName["txtName"] return as object?
|
|
|
|
|
Yes, document.getElementByID("txtName") also returns the object.
I have my controls declared in <asp:content> tag. Does it have anything to do with that? I remove <asp:content> and put controls in body tag document.frmMain.txtName works.
|
|
|
|
|
Hello, I want to transfer data, which is selected from a checkbox, to the other gridview which is in other web page. Can u help me???
Thanks...
Tahsin
|
|
|
|
|
To my best knowledge, nobody here is known to be a fortuneteller. Maybe if you provide a more detailed explanation of the problem, we might be able to help you. Where and what is the data source? what other gridview? where is the checkbox? etc...
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning."
--Rich Cook
|
|
|
|
|
My project is an e-commerce project. My gridview (id: grid1) is in the sepet.aspx web page and in every row of that gridview there is a checkbox. When I select some of that checkboxes, and clicked a next page button, I want to see that datas which are selected from grid1 in kayit.aspx web page in a new gridview (id=grid2).
I search some sites but I didn't find the exact solution.
Thanks...
|
|
|
|