|
Hi all,
Iam using the following code to send email attachments
<br />
HttpContext.Current.Response.Charset = ""<br />
Dim tw As New System.IO.StringWriter<br />
Dim hw As New System.Web.UI.HtmlTextWriter(tw)<br />
report.RenderControl(hw)<br />
'My.Computer.FileSystem.DeleteFile(HttpContext.Current.Server.MapPath("~\Attachments\" & ReportName))<br />
<br />
Dim attachment As String = HttpContext.Current.Server.MapPath("~\Attachments\" & ReportName)<br />
<br />
My.Computer.FileSystem.WriteAllText(attachment, tw.ToString, False)<br />
AppEmailService.SendMail(subject, body, attachment, receiver)<br />
tw.Close()<br />
hw.Close()<br />
tw = Nothing<br />
hw = Nothing
the first time any user sends an email, it is successfully sent. If i try to send the same attachment again, it is giving me an error that the attachment is being in use.
"The process cannot access the file 'c:\inetpub\wwwroot\ORM\Attachments\Number of operational Loss Events.xls' because it is being used by another process"
Any ideas
|
|
|
|
|
this is my stored procedure in oracle, am using oracle client,
cmd.parameter.add() to RETURN the value of the parameter but its not working.
PROCEDURE "SCOTT"."PROCEDURE2" (
"PARAM1" IN NUMBER, "PARAM2" out VARCHAR2) IS
varEname VARCHAR2(40):='xxx';
varComm REAL;
varSalary CONSTANT NUMBER:=1000;
comm_missing EXCEPTION;
BEGIN
SELECT ENAME,
COMM
INTO varEname,
varComm
FROM EMP
WHERE EMPNO = param1 ;---7369;
IF varComm IS NULL THEN
RAISE comm_missing;
else
dbms_output.put_line('Commision is ' || varcomm );
END IF;
param2:=varEname;
dbms_output.put_line(param2);
EXCEPTION WHEN comm_missing THEN
dbms_output.put_line('Commision is NULL');
WHEN no_data_found THEN
dbms_output.put_line('Employee Does not Exist');
END "PROCEDURE2";
I need to retrieve the value of param2 inside my Asp.net code.
Please help me with Ideas.
Salami
|
|
|
|
|
check out this link ..hope it will help u...
http://aspnet.4guysfromrolla.com/articles/062905-1.aspx
regards
Ramesh
|
|
|
|
|
How can I use a connection string stored in the web.config file to get a datatable from the sql server 2005 ?
thx in advance.
BiG RaLpH
|
|
|
|
|
Hi.
Your connection string of course might be different but here's what you do with that. Put the following inside <configuration></configuration> right after let's say </system.web> (Make sure it doesnt go inside system.web node)
<appSettings>
<add key="SQLConString" value="packet size=4096;data source=SERVER;persist security info=True;user id=USERUD;password=PASSWORD;initial catalog=DATABASE"/>
</appSettings>
In your code do the following to get connection:
Dim sConn As String<br />
sConn = ConfigurationSettings.AppSettings("SQLConString")<br />
Dim con As New System.Data.SqlClient.SqlConnection(sConn)<br />
con.Open()<br />
....<br />
....<br />
....<br />
con.Close()
That's it.
-- modified at 9:20 Wednesday 7th November, 2007
|
|
|
|
|
Thx
Now how can I get the table in that database lets name the table "Tabl1".
I want to copy it and put it in a instance of the table.
i.e.:
dim table as datatable
"table = Table1"
thx
BiG RaLpH
|
|
|
|
|
Use connection to connect to database. Create datagrid, dataset and dataadapter.
Fill your dataset using dataadapter and assing dataset to your datagrid.
NOTE: dg is the datagrid on your page. You can AutoGenerateColumns(True or False).
If you do just bind dataset to datagrid and that's it. If you want to play around you will have to built custom columns for your datagrid.
'Open connection<br />
con.Open()<br />
<br />
Dim strSQL As String = "SELECT * FROM Tabl1"<br />
<br />
'Create command and assign timeout value<br />
Dim cmdSelect As New System.Data.SqlClient.SqlCommand(strSQL, con)<br />
<br />
'Create data set<br />
Dim ds As New DataSet<br />
<br />
'Created adapter and fill dataset<br />
Dim da As New System.Data.SqlClient.SqlDataAdapter(cmdSelect)<br />
da.Fill(ds, "ANYTABLENAME")<br />
<br />
'Verify if data exists<br />
If ds.Tables(0).Rows.Count > 0 Then<br />
'Create dataview and assign sort by field and direction<br />
Dim dv As DataView = ds.Tables("ANYTABLENAME").DefaultView<br />
dg.DataSource = dv<br />
<br />
'Bind data to datagrid<br />
dg.DataBind()<br />
End If<br />
<br />
'Close connection<br />
con.Close()
|
|
|
|
|
thx alot but I'm having the error that con has not been initialized.
BiG RaLpH
|
|
|
|
|
Dim sConn As String
sConn = ConfigurationSettings.AppSettings("SQLConString")
Dim con As New System.Data.SqlClient.SqlConnection(sConn)
Dim selectCMD As SqlCommand = New SqlCommand("SELECT * FROM Customers", con)
selectCMD.CommandTimeout = 30
Dim custDA As SqlDataAdapter = New SqlDataAdapter
custDA.SelectCommand = selectCMD
con.Open()
Dim custDT As DataTable = New DataTable
custDA.Fill(custDT, "Customers")
con.Close()
Now u have customers table in custDT ..
Regards,
Ramesh.
|
|
|
|
|
thx alot but I'm having the error that con has not been initialized.
BiG RaLpH
|
|
|
|
|
are you running on a sql Server?
If so shouldn't you do any authentication? User Id=;Password=;
check out the connection string in web.config
|
|
|
|
|
No I don't have any ID or Password this is y I'm amazed.
is there anything else that might go wrong that may coz this error.
BiG RaLpH
|
|
|
|
|
how r u connecting to sqlserver?
windows authentication....
just paste the connection string and ur code..
i will let u know any prob's in that..
|
|
|
|
|
the connection string is:
<add name="NameofConnection" connectionString="Data Source=W2K3SERVER;Initial Catalog=DATABASE;Integrated Security=True" providerName="System.Data.SqlClient"/>
My code is the code u gave me:
Dim sConn As String
sConn = System.Configuration.ConfigurationManager.AppSettings("NameofConnection")
Dim con As New System.Data.SqlClient.SqlConnection
con.ConnectionString = sConn
Dim selectCMD As SqlCommand = New SqlCommand("SELECT * FROM Table$", con)
selectCMD.CommandTimeout = 30
Dim custDA As SqlDataAdapter = New SqlDataAdapter
custDA.SelectCommand = selectCMD
con.Open()
Dim custDT As DataTable = New DataTable
custDA.Fill(custDT)
con.Close()
the .fill doesn't take the 2 parameters I'm using asp.net 2.0 (maybe there is a difference)
BiG RaLpH
|
|
|
|
|
Hi.
I have a web page, which collects information about project (name, project date create, description, project date due, etc). One of the things I need to collect is the "project assigned to" information. For this purpose I need to build a table or any other structure that can support the following:
1. the table should have 5 rows as default
2. the table should have ability to add/remove rows if needed
3. the table will consist of 2 cell.
a. Role - dynamic drop-down (data will be populated from db)
b. Name - text field
4. adding/removing rows should not affect data entered in other fields. Basically if I filled all 5 rows and want to add sixth row my data will be there with new row added. The same goes for removing rows (I guess this is something had to do with State).
I've tried different things (datatable and datagrid) but couldn't complete all 4 point described above. Did anyone had experience with something like this or have any suggestions?
Thank you,
Alex.
|
|
|
|
|
alexfromto wrote: 3. the table will consist of 2 cell.
you mean, two columns?
I think that those facts are pretty okay with DataGrid. I have done something like that with Datagrid in ASP.NET 1.1...
alexfromto wrote: 1. the table should have 5 rows as default
you can bind with the empty dataset to your datagrid.
alexfromto wrote: 2. the table should have ability to add/remove rows if needed
For adding row, I used the footer template in Datagrid.
For removing row, I added the "Delete" link with command in grid template.
alexfromto wrote: a. Role - dynamic drop-down (data will be populated from db)
b. Name - text field
ItemTemplate is pretty okay for you. it allows you to add any web control (including dropdown ctl and textbox control) in Datagrid.
alexfromto wrote: 4. adding/removing rows should not affect data entered in other fields. Basically if I filled all 5 rows and want to add sixth row my data will be there with new row added. The same goes for removing rows
Yeah. It is very okay with Datagrid item template. but if you do some action, the postback will be occured.
|
|
|
|
|
Yes. I mean 2 columns.
1. I have no problem creating DataGrid. How can I assign empty DataSet to DataGrid. I've built a table (5 rows) with empty cell and added to my DataGrid. Is this the way of doing it?
2. Do you have anything code wise so I can see how add/remove works?
3. I did it and had no problem
4. didn't get exactly what you mean here. Will I lose data entered or datagrid will keep it?
Thanks a lot
|
|
|
|
|
OK. Firgure it out. Wow. Yeah.
|
|
|
|
|
Hello,
I'm gonna be working for the first time with eBay APIs and I've been doin a little research abt this. I've heard that there are some 'Test Servers' on which you can test the working of ur application that uses web services. I really dont know much abt it honestly. So I wanted to ask if we can actually test the eBay API functions offline?
Thanks in advance
Rocky
You can't climb up a ladder with your hands in your pockets.
|
|
|
|
|
well I got the answer now.
Its called the Sandbox Environment, which simulates the API Calls locally for the developers to test the working of their application
Rocky
You can't climb up a ladder with your hands in your pockets.
|
|
|
|
|
Hi guys I got a bit of a problem that has taken me days to try and sort out and I'm getting nowhere.
basically I have to servers that are setup in a DMZ, as a workgroup, one server is a Application Server and the other is a Database and File Server. I need to be able to be able to upload files from the application server the file server via a UNC path. but everything I have tried seems to fail.
I recieve errors along the lines of "can't find part of path", "incorrect user/password", etc.
I have tried a Myriad of approaches including creating a user account on both machines, and impersonating that account, to write, Created a Virtual Directory and used :
string SaveLocation =System.Web.Hosting.HostingEnvironment.MapPath ("~/webmedia/article/" + fn )
To get the UNC path, Stored the UNC path in the Web.config file, but nothing seems to work.
I haved scoured the net for any information, but seem to have got nowhere, I have found one or two articles but they basically tell me what I have tried. I was wondering if anybody knows of any other Tut's/atricles I could read.
I have included some of my code in the help somebody could spot an error
HttpPostedFile selectedPDF = ImageUploadFile.PostedFile;<br />
<br />
if ((selectedPDF != null) && (selectedPDF.ContentLength > 0) && selectedPDF.ContentType == "application/pdf")<br />
{<br />
try<br />
{<br />
string fn = System.IO.Path.GetFileName(selectedPDF.FileName);<br />
string dir = ConfigurationManager.AppSettings["docpath"].ToString();<br />
<br />
string SaveLocation = ConfigurationManager.AppSettings["devdocpath"].ToString() + fn;<br />
selectedPDF.SaveAs(SaveLocation);<br />
.....
-- modified at 8:47 Wednesday 7th November, 2007
I have tried doing a simple app here locally on my own network and haven't even tried using impersonation, but it just works
here is the sample code. I am completely baffled
try<br />
{<br />
HttpPostedFile theFile = FileUpload1.PostedFile;<br />
FileUpload1.SaveAs(@"\\Cyko\d\" + System.IO.Path.GetFileName(theFile.FileName).ToString());<br />
}
|
|
|
|
|
how should i use my code behind function thoug the javas script.currently what i am doing is , declaring the variable as public in the code behind , the on form load i am executing the fucntion and the function returns the value , and finally i fetch it form the source file using the following syntax,
<%=public var name%>
Soniagupta1@yahoo.co.in
Yahoo Messenger Id = soniagupta1
|
|
|
|
|
Sonia Gupta wrote: how should i use my code behind function thoug the javas script
What's a code behind function? Do you mean your ASPX cs or VB code? If so, you can't directly. One option is to use Ajax - and please, if you go this route, buy some books on it, try out the samples and watch some sample videos before you start posting questions on it.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
hi,
from the database i am getting a no like this( 2,3,6)...
i have a checkbox list and in the checkbox list i ahve to select the 2nd and 3rd and 6th checkboxes....
how can i do this in asp.net
|
|
|
|
|
Pretty easy, all you need to do is first split up the string of numbers:
string myNumberString = "2,3,6";<br />
string[] myNumbers = myNumberString.Split(',');
then just loop over them setting that item in the checkboixlist to Selected
int index;
for(string myNumber in myNumbers)
{
if(int.TryParse(myNumber,out index))
{
myCheckBoxList.Items[index].Selected = true;
}
}
|
|
|
|