Hi Freinds,
I make the application upload the file and download from database on Gridview its working fine but when i tried to delete the file using rowdeleting in gridview its showing error like
"Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index"
Loading

Rocky RockyRank #7,391 · 242 reputationPosted Aug 29, 2013, 9:56 PM EDT
I Atttached mY Gridview Row Deleting let me know
Sanjeeb LenkaRank #301 · 8.3K reputationPosted Aug 29, 2013, 10:04 PM EDT
plz share your grid aspx design code.
Rocky RockyRank #7,391 · 242 reputationPosted Aug 29, 2013, 10:07 PM EDT
Oops I miss the DatakeyNames in My GridView so Only so Its that Error message, When I tried to upload .jpg format
String or binary data would be truncated.
The statement has been terminated.
these error ll be come i added My entire code Let me know
Sanjeeb LenkaRank #301 · 8.3K reputationPosted Aug 29, 2013, 10:08 PM EDT
thats why i am asking for your grid code.
happy coding.
Rocky RockyRank #7,391 · 242 reputationPosted Aug 29, 2013, 10:14 PM EDT
its not accepting Pdf Files also..... wat was the problem here
Sanjeeb LenkaRank #301 · 8.3K reputationPosted Aug 29, 2013, 10:16 PM EDT
plz share your full code. means on upload it not accepting pdf file.
Rocky RockyRank #7,391 · 242 reputationPosted Aug 29, 2013, 10:24 PM EDT
i attached My entire code for Upload .lete me back why its not accepting pdf and .jpg files
Sanjeeb LenkaRank #301 · 8.3K reputationPosted Aug 29, 2013, 10:44 PM EDT
your code looks error free. my be this error coming from file upload control. file upload control allows maximum file size is 4MB for that reason if we upload file size larger than 4MB we will get error.
so put this line in your web.config within <system.web>
<httpRuntime executionTimeout="9999" maxRequestLength="2097151"/>
check and reply. if get any error msg plz post that msg
Rocky RockyRank #7,391 · 242 reputationPosted Aug 29, 2013, 10:55 PM EDT
After adding The Line also Its Giving same error Message
Sanjeeb LenkaRank #301 · 8.3K reputationPosted Aug 29, 2013, 11:00 PM EDT
what error msg you are getting plz share.
Rocky RockyRank #7,391 · 242 reputationPosted Aug 29, 2013, 11:02 PM EDT
I thnk
cmd.Parameters.AddWithValue("@Data", bytes);
in Upload control
these line is the problem its accepting size only bytes format.
if the size is kb,mb means wont accepted it and giving that error.
String or binary data would be truncated.
The statement has been terminated.
Sanjeeb LenkaRank #301 · 8.3K reputationPosted Aug 29, 2013, 11:05 PM EDT
what is the datatype of Data in sql server.
and one question why you are storing total file to database as it will waste database space and memory.
Rocky RockyRank #7,391 · 242 reputationPosted Aug 29, 2013, 11:27 PM EDT
Data =varbinary(3000)
i making the travel claim like the details
departuredate=(jquerydatepicker)
From = textBox
To =TextBox
Lodge=textbox
foodBill=textbox
Daily Claim=textbox
Bill references=textbox Upload(button)
Add(After press entire details Shwn On GridView)
That purpose only i m asking these
Sanjeeb LenkaRank #301 · 8.3K reputationPosted Aug 29, 2013, 11:37 PM EDT
change it to varbinary(MAX) and check once.
Rocky RockyRank #7,391 · 242 reputationPosted Aug 30, 2013, 1:04 AM EDT
Its accepting with in 7 kb files oly . i checked on net varbinary allows up to 2GB
protected void Upload(object sender, EventArgs e)
{
string filename = Path.GetFileName(FileUpload1.PostedFile.FileName);
string contentType = FileUpload1.PostedFile.ContentType;
Stream fs = FileUpload1.PostedFile.InputStream;
BinaryReader br = new BinaryReader(fs);
byte[] bytes = br.ReadBytes((Int32)fs.Length);///// i thnk may be here problem
conn.Open();
string query = "insert into tblFiles values (@Name, @ContentType, @Data)";
SqlCommand cmd = new SqlCommand(query, conn);
cmd.Parameters.AddWithValue("@Name", filename);
cmd.Parameters.AddWithValue("@ContentType", contentType);
cmd.Parameters.AddWithValue("@Data", bytes);
cmd.ExecuteNonQuery();
conn.Close();
BindData();
Response.Redirect(Request.Url.AbsoluteUri);
}
how to do it?
Sanjeeb LenkaRank #301 · 8.3K reputationPosted Aug 30, 2013, 1:24 AM EDT
check the attached sample it worked for me. just change the connection string in web.config and make data column to varbinary(MAX).
Rocky RockyRank #7,391 · 242 reputationPosted Aug 30, 2013, 1:33 AM EDT
varbinary(max) ll work on mssql2000, i ve that batabase only
Sanjeeb LenkaRank #301 · 8.3K reputationPosted Aug 30, 2013, 1:43 AM EDT
i afraid it will not support.
from my experience don't store the files in to database. store it in folder in your project and sve the path in database.
Rocky RockyRank #7,391 · 242 reputationPosted Aug 30, 2013, 1:52 AM EDT
Oh Thanks You Friend in web application requirement is
create table travel_claim
(
request_id int identity ,
Deaprturedate datetime,
From_place varchar(20),
to_place varchar(20),
Lodge varchar(20),
Food Varchar(20),
Dailyclaim varchar(20)
)
My aspx page:
departuredate=(jquerydatepicker)
from =textbox
to =textbox
Lodge = textbox
Food = textbox
dailyclaim = textbox
ADD(after the button entire details ll display on gridview below )
if i possible make a Upload content in Folder along with gridview?
in that gridview row can be deleted depends on the request_id as the same i can able delete the uploaded content alond with that id?
kindly do the need full?
Sanjeeb LenkaRank #301 · 8.3K reputationPosted Aug 30, 2013, 2:25 AM EDT
check once using varbinary(8000)