|
How to upload file in asp.net 2.0 to server hard disk from client side and down load file
|
|
|
|
|
Drag nd Drop Html control input(file) nd in code behind write following code
string fn = System.IO.Path.GetFileName(YourfileName.PostedFile.FileName);
string SaveLocation = Server.MapPath("FolderName") + "\\" + fn;
YourfileName.PostedFile.SaveAs(SaveLocation);
Response.Write(fn + " Has been uploaded to " + SaveLocation);
Instead of "YourfileName" use de id of input(file) control nd FolderName is de name of de folder on server in which to upload de file.
i think it will solve ur problem.
|
|
|
|
|
You can use the file upload component use the and use the .SaveAs(filename) method to save at the server side.
Thanks,
|
|
|
|
|
in saving data in my module, instead of using connection wizard, i use this sql codes:
Dim str As String<br />
dbconnect = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Rara's project\grading.mdb")<br />
dbconnect.Open()<br />
str = "select count(*) from students where studname = '" & txtname.Text & "'"<br />
dbcommand = New OleDbCommand(str, dbconnect)<br />
If dbcommand.ExecuteScalar <> 0 Then<br />
MessageBox.Show("Already exists.", "Result")<br />
cleartxt()<br />
Else<br />
str = "Insert into students(studname, year, course) values ('" & txtname.Text & "', " & "'" & cmbyear.Text & "', " & "'" & cmbcourse.Text & "')"<br />
dbcommand = New OleDbCommand(str, dbconnect)<br />
dbcommand.ExecuteNonQuery()<br />
MessageBox.Show("Record Added.", "Result")<br />
dbconnect.Close()<br />
cleartxt()<br />
End If
but i have an error in the part there -"dbcommand.ExecuteNonQuery()"
a dialog box appear and it says:
An unhandled exception of type 'System.Data.OleDb.OleDbException' occurred in system.data.dll
i guess the error there is the combobox that i used? because when i try to erase the "cmbcourse.text" and "cmbyear.text", it runs..but when i put it, there's an error....
how can i fix it???
please, help me!!!
|
|
|
|
|
Is the year filed in your database a text field, or a nyumeric one? If the latter, you need to remove the apostrophes around it in your sql statement.
If any of your courses have apostrophes in them, this too will break the code - use the replace function to replace all occurrences of apostrophes with double-apostrophes.
|
|
|
|
|
all my database field are text....
the apostrophes that are you saying are in my codes? So i need to remove it?
This is my code before:
str = "Insert into students(studname, year, course) values ('" & txtname.Text & "', " & "'" & txtyear.Text & "', " & "'" & txtcourse.Text & "')"
how can i remove it?
Like this?
str = "Insert into students(studname, year, course) values ('" & txtname.Text & "', " & " " & txtyear.Text & ", " & " " & txtcourse.Text & ")"
but when i do it, it is still dont running?
Can u please write the codes for that, so i can know which one is to be removed?
|
|
|
|
|
No - your original SQL statement is correct in as far as it goes, but will crash if any of your text inputs include apostrophes. Because SQL uses apostrophes to mark the start and end of text fields, another one occuring within a field causes problems.
To get round this, SQL accepts two consecutive apostrophes as marking not the end of the text field but an apostrophy within it - thus if your txtcourse.text = "smith's" the SQL statemt would fail, "smith''s" would be accepted.
To take acount for this in all cases, simply use the replace method to replace all apostrpohes within text fields with double apostrophes - thus:
str = "Insert into students (studname, year, course) values ('" & txtname.Text.Replace("'", "''") & "', '" & txtyear.Text.Replace("'", "''") & "', '" & txtcourse.Text & "')"
cheers
Fred
|
|
|
|
|
Dear all,
i am using asp.net2.0 , C#
i want to know how to create itemtemplate at run time.
please help
thanks
imran khan
|
|
|
|
|
create class that implements interface System.Web.UI.ITemplate
class MyItemTemplate : ITemplate
{
public void InstantiateIn(Control container)
{
// add any controls you wish into container.Controls[] collection
}
}
TemplateField myTemplateField = new TemplateField();
myTemplateField.ItemTemplate = new MyItemTemplate();
myGridView.Columns.Add(myTemplateField);
hope that helps.
Pilo
|
|
|
|
|
Hello Everyone,
I've to run mp3 or .rm songs in my web page
how can it be possible ..............
Suggesttttttttttttttttttttt Me...................
|
|
|
|
|
> I've to run mp3 or .rm songs in my web page
1997 called, they want their HTML back.
I vaguely remember something about the embed tag. You might have to look at that if there isn't anything that ASP.NET itself provides for this purpose,
|
|
|
|
|
i have a checkboxlistitem.where let say A,B,C,D,E are the items in that control.
and below that 5textboxes are there named as textbox1,textbox2......textbox5.
initiallay all textboxes are disabled.now i want when ever i select A the corresponding checkbox should be enable i.e textbox2.
and likewise if i select B then textbox2, if Dthen textbox 4.likewise.
what will be the vb.net code for it.
|
|
|
|
|
you need to write code inside
protected void CheckBoxListmst_SelectedIndexChanged(object sender, EventArgs e)
{
if(checkbox1.selectedvalue == 'A')
{
textboxA.enabled = true
}
}
something like this.
hope this will resolve your issue.
imran khan
|
|
|
|
|
i had tried this but its returning one value means which is get selected first only that value its showing . as in the if statement if 1st condition is satisfied then it will come out side that block.
so if u have any solution then do reply me
|
|
|
|
|
hello frndz. thanks for ur reply n solution to my query.
here another small query for you.
i have a checkboxlistitem.where let say A,B,C,D,E are the items in that control.
i am able to store the mulitiple value of the checkbxlist item .(by taking a string and storing the multiple value by "," operator).
now my problem is that when i am retriving the value from the db ,am not able to retrive the value of the lsitboxitems.
(suppose in emp_id "1" i have stored the values of A,C,D from checkboxlist,when i retrive the record having emp id1. i want to retrive its value i.e A,C,D and the corresponding checkbox of the values to be checked in the front end.)
what will be code in vb.net
|
|
|
|
|
first u can splite the result row with 'A,C,D' with ",". now u have the array of the all checkbox which need to select. now with checkboxlist you can find the ur checkbox by text or value and give the property selected
Hardik Panchal
|
|
|
|
|
can u write the code for it. actully i have tried this logic but may be with wrong code. so asking you to write the code for it in vb.net
|
|
|
|
|
For Each dr As DataRow In checkboxlist.Items
if dr(columnname) = 'A' then
checkboxlist.Items.checked = true
end if
Next
Hardik Panchal
|
|
|
|
|
Here is the code you asked for...
Dim lstItem As New ListItem
Dim lstItems() As String = Value.Split(",") 'Value = "A,B,C"
For Each lstItem In chklstItem.Items
For I As Int16 = 0 To lstItems.Length - 1
If lstItems(I) = lstItem.Value Then
lstItem.Selected = True
End If
Next
Next
I suggest you to write a property procedure which will GET and SET the values of the CheckBoxList...
Regards John
|
|
|
|
|
Hi..
In my project I am using a gridview which contains two select buttons per row.How can i determine which select button was clicked.
Thanks in Advance
Mahesh.J
|
|
|
|
|
In your code on the postback
LinkButton lb = (LinkButton)sender;
//From here you can check the ID or command argument or whatever else
I didn't get any requirements for the signature
|
|
|
|
|
hi,
anyone out there know how can i display "interactive map" in my application.
exclude google map, yahoo map, virtual earth..because they dont provide
enough zoom level in my area.
i need to build an application that has map and user can zoom to street level,
find path, etc...
i think my only solution is to put my own map..but how can i apply the interactivity
to users...
any solution anyone??? please help...??? desperate!!
i need to finish it within 1month from now !!!
|
|
|
|
|
Have you looked at MapPoint[^]
only two letters away from being an asset
|
|
|
|
|
hi navaneeth,
Thanks for the links.It was really helpful.
Just one question though.
You were saying that i need to maintain a separate database and need to store the brand id rather than the url of the image.
Say if i have 1,00,0000 images and each image has more links ,
how can i maintain the same in SQL?
Also when i retrieve the links for each category, wont the process be slow? Is there any way where i can perform all operations on the backend (maybe a stored procedure) and retrieve only the result as a string in asp.net
Thanks in advance.
Regards
Anuradha
Thanks in advance.
Regards
Anuradha
|
|
|
|
|
anu81 wrote: hi navaneeth,
This is a common forum. please don't post a question asking to a particular member. May be some other member knows the solution much better than me, but they will hesitate to answer since the question was asked to a particular member. If you have any direct queries you can mail me on navaneethkn@hotmail.com
anu81 wrote: You were saying that i need to maintain a separate database and need to store the brand id rather than the url of the image.
Say if i have 1,00,0000 images and each image has more links ,
how can i maintain the same in SQL?
I am not getting you fully. Why I suggested you to store the ID instead of storing images is to reduce the storage space. If you can't maintain it in such a way what I suggested, you can store the URL.
anu81 wrote: Also when i retrieve the links for each category, wont the process be slow? Is there any way where i can perform all operations on the backend (maybe a stored procedure) and retrieve only the result as a string in asp.net
Yes, process will be slow on searching all these records. So you need to use some alternative solution. How about maintaining another table that won't repeat the image names but will contain all unique image names from the visited history table.
Assume in your visitor table, you are storing the image url. So each time user visits the same page also rows will increase. Searching inside this table would be a costly operation. So you can copy the unique image urls and the total count got for the particular image to the new table. Your new table would contain imageurl and total views.
On your page you can search in this second table which will be less cost. To improve performance use indexing for your table. This can boost your select query performance. Filling second table from history table can be scheduled using SQL Server jobs.
|
|
|
|