I did put valid values in the actual code I used, just did not want to post it here.
Have used a correct smtp server, username, password - sure of that
I did put valid values in the actual code I used, just did not want to post it here.
Have used a correct smtp server, username, password - sure of that
If I try port 25, I get this message-
System.Web.HttpException: The message could not be sent to the SMTP server. The transport error code was 0x80040217. The server response was not available
---> System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.Runtime.InteropServices.COMException (0x80040211): The message could not be sent to the SMTP server. The transport error code was 0x80040217. The server response was not available
--- End of inner exception stack trace ---
at System.RuntimeType.InvokeDispMethod(String name, BindingFlags invokeAttr, Object target, Object[] args, Boolean[] byrefModifiers, Int32 culture, String[] namedParameters)
at System.RuntimeType.InvokeMember(String name, BindingFlags bindingFlags, Binder binder, Object target, Object[] providedArgs, ParameterModifier[] modifiers, CultureInfo culture, String[] namedParams)
at System.Web.Mail.SmtpMail.LateBoundAccessHelper.CallMethod(Object obj, String methodName, Object[] args)
--- End of inner exception stack trace ---
at System.Web.Mail.SmtpMail.LateBoundAccessHelper.CallMethod(Object obj, String methodName, Object[] args)
at System.Web.Mail.SmtpMail.CdoSysHelper.Send(MailMessage message)
at System.Web.Mail.SmtpMail.Send(MailMessage message)
at MyMailer.Form1.Button1_Click(Object sender, EventArgs e) in C:\Users\tuse\AppData\Local\Temporary Projects\MyMailer\Form1.vb:line 32
Hi!
This is the code I have for sending mail-
Imports System.Web.Mail
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim Mailmsg As New System.Web.Mail.MailMessage()
SmtpMail.SmtpServer = "mysmtpserver"
Mailmsg.To = "recepient@domain.com"
Mailmsg.From = "\" & "foo" & "\ <" & "bar@domain.com" & ">"
Mailmsg.Subject = "Sending a test mail"
'Mail Body
Mailmsg.Body = "This is a test message"
Mailmsg.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1") 'basic authentication
Mailmsg.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", "myusername") 'set your username here
Mailmsg.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", "mypassword") 'set your password here
Mailmsg.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpserverport", "26") 'Put port number here
Try
SmtpMail.Send(Mailmsg)
Catch ex As Exception
'MsgBox(ex.ToString)
Me.TextBox1.Text = ex.ToString
End Try
End Sub
End Class
The error message I get is-
System.Web.HttpException: The transport failed to connect to the server.
---> System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.Runtime.InteropServices.COMException (0x80040213): The transport failed to connect to the server.
--- End of inner exception stack trace ---
at System.RuntimeType.InvokeDispMethod(String name, BindingFlags invokeAttr, Object target, Object[] args, Boolean[] byrefModifiers, Int32 culture, String[] namedParameters)
at System.RuntimeType.InvokeMember(String name, BindingFlags bindingFlags, Binder binder, Object target, Object[] providedArgs, ParameterModifier[] modifiers, CultureInfo culture, String[] namedParams)
at System.Web.Mail.SmtpMail.LateBoundAccessHelper.CallMethod(Object obj, String methodName, Object[] args)
--- End of inner exception stack trace ---
at System.Web.Mail.SmtpMail.LateBoundAccessHelper.CallMethod(Object obj, String methodName, Object[] args)
at System.Web.Mail.SmtpMail.CdoSysHelper.Send(MailMessage message)
at System.Web.Mail.SmtpMail.Send(MailMessage message)
at MyMailer.Form1.Button1_Click(Object sender, EventArgs e) in …
Worked like a charm, thanks for your reply!
Hi!
I am using the following code for a file upload-
<?php
if(isset($_POST['b1']))
{
if($_FILES['uploadedfile']['name'] !="")
{
$target_path = "/home/infotech/myhomepage/uploads/";
$target_path = $target_path . basename( $_FILES['uploadedfile']['name']);
echo("Temporary Location is: ".$_FILES['uploadedfile']['tmp_name']."<br />");
echo("Target Path is: ".$target_path."<br />");
if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) {
echo "The file ". basename( $_FILES['uploadedfile']['name']).
" has been uploaded";
}
else{
echo "There was an error uploading the file, please try again!";
}
}
else
{
die("No file specified");
}
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>File Upload</title>
</head>
<body>
<form enctype="multipart/form-data" action="<?php echo($_SERVER['PHP_SELF']);?>" method="POST">
<input type="hidden" name="MAX_FILE_SIZE" value="100000" />
Choose a file to upload: <input name="uploadedfile" type="file" /><br />
<input type="submit" name="b1" value="Upload File" />
</form>
</form>
</body>
</html>
While it works fine on my localhost, when I upload it to the server, I get-
Temporary Location is: /tmp/phpw1v73L
Target Path is: /home/infotech/myhomepage/uploads/a.txt
Warning: move_uploaded_file(/home/infotech/myhomepage/uploads/a.txt) [function.move-uploaded-file]: failed to open stream: Permission denied in /home/infotech/myhomepage/upload.php on line 15
Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move '/tmp/phpw1v73L' to '/home/infotech/myhomepage/uploads/a.txt' in /home/infotech/myhomepage/upload.php on line 15
There was an error uploading the file, please try again!
-----------
Is it due to permissions?
Because I am able to do mv /tmp/foo /home/infotech/myhomepage/uploads/
Any ideas?
Thanks
Hi!
I have the following code-
Imports System.Data.OleDb
Public Class Form1
Dim x As String = """"
Dim cs As String = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=c:\sbi\mm.xls;Extended Properties=" & x & "Excel 12.0 Xml;HDR=YES" & x & ";"
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim cn As New OleDb.OleDbConnection(cs)
Try
cn.Open()
Catch ex As Exception
MsgBox(ex.Message)
End Try
Dim cmd As New OleDbCommand("Select * from [sheet1$]", cn)
Dim dr As OleDbDataReader
dr = cmd.ExecuteReader
While dr.Read
Dim email As String = dr(1).ToString
Try
If email = "" Then
Dim name As String = dr(0).ToString
Dim cmd2 As New OleDbCommand("Delete from [sheet1$] where name='" & name & "'", cn)
Try
cmd2.ExecuteNonQuery()
'MsgBox("means")
Catch ex As Exception
MsgBox(ex.Message)
End Try
Else
End If
Catch ex As Exception
MsgBox(ex.ToString)
End Try
End While
MsgBox("Finally Done")
End Sub
End Class
I am trying to delete rows but I get the error-
Deleting data in a linked table is not supported by this ISAM
Anybody know how to get deletion to work in an excel sheet?
Hi!
In the following code-
<?php
header('Cache-Control:no-cache');
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<form id="form1" name="form1" method="post" action="<?php echo($_SERVER['PHP_SELF']);?>">
<p>
<label>Name:
<input type="text" name="txt" id="txt" value="<?php $_POST['txt'];?>" />
</label></p>
<p>
<input type="submit" name="b1" id="b1" value="Submit" />
</p>
</form>
<hr />
<?php
//form handler
if(isset($_POST['b1']))
{
echo($_POST['txt']);
}
else
{
echo("Enter a value");
}
?>
</body>
</html>
in this form, i am not able to understand why we have to use the value attribute for the textfield-
<input type="text" name="txt" id="txt" value="<?php $_POST['txt'];?>" />
don't we know that the $_POST variable refers to the value of the textfield? so why set the value attribute again?
Hi!
Can anybody please explain this-
<?php
$num=5;
echo($num.++$num);
echo("<br />".$num);
?>
prints:
66
6
while
<?php
$num=5;
echo($num++.++$num);
echo("<br />".$num);
?>
prints:
57
7
how exactly is the parsing done?
Hi!
I am working on a data mining project which involves playing around with email ids.
The problem is that the email ids are scattered over different machines on the network.
ie. There are different windows machines, each with a copy of outlook maintaining an individual address book.
Is there any way of integrating all these email ids into a single machine?
PS- I posted the same thread in another forum but I guess this place is more appropriate
Hi!
I am working on a data mining project which involves playing around with email ids.
The problem is that the email ids are scattered over different machines on the network.
ie. There are different windows machines, each with a copy of outlook maintaining an individual address book.
Is there any way of integrating all these email ids into a single machine?
Are you sure you are giving 6 parameters?
Could you paste your SQL Command text again? It appears broken in your previous post.
It can be done using a javascript, just google it and you will get it.
However, you must hope javascript is enabled on your client's browser else it will not work.
Do you know the SQL command to achieve the same?
If so, use a DataReader-
'We have a Data Reader to read the values returned by the SQL Command Execution
'cmd is your SQL command
' I am using ODBC for DB Connectivity
Dim dr As Odbc.OdbcDataReader
dr = cmd.ExecuteReader
If dr.HasRows = True Then
'If SQL command returns rows, , then we show the next form which contains the application, in my case its Form1
'Remember to close the login form in the form closing event of Form1, and hide this form in load of form1
Form1.Show()
Hi!
I am doing a project which tries to simulate a DBMS.
The records for a relation(table) are saved in a file on disk.
What I wish to do is -
Specify the block to which each record be written / Save the content block wise
Reason for doing this- I will use a data structure such a B+ Tree that holds the pointers to the blocks, by the means of which I can load a required block (and hence a record) into memory as requested by the user.
The file attribute field has the value 'A'
I got it.
It is Request.QueryString("qs-name")
For some reason it was not working the first time I tried it.
The website that I created enables users to signup. When they register an account, a mail is sent to them.
In the mail, I wish to send them a link upon clicking of which enables them to login.
How can I do this?
-----
I was thinking on the following lines-
Upon user registration, generate a random query string and send it in the mail. In the users table keep a boolean variable depending upon whether the user has clicked or not (matching the querystring). How can I code the login page so as to 'read' the querystring in the browser?
Anybody tried it with the ODBC Driver?
Well I have found a temporary work around for this. Since it was on the desktop, I created a new user and that desktop icon is gone.
I did reboot. The file still shows.
I did try that. In the directory listing (dir /x), it shows the filename (again size 0) but when i do del <filename> it says "Could not find the file"
Hi!
There is a file on my desktop of size 0 bytes.
When I try to delete it, it says "Could not find this item"
What is the problem? This is really irritating me. Any help would be highly appreciated
Hi all!
I am trying to connect to a remote MySQL database in a VB.NET application. This database is located on my LAN at the address 192.168.1.2. I am using MySQL Connector/ODBC 3.51 (MyODBC 3.51) for the connection.
The connection string that I am using is the following-
Driver={MySQL ODBC 3.51 Driver};Server=192.168.1.2;Database=mydb;User=root; Password=;Option=3;
The error message that i get is not too intuitive - SystemEventArgs
Has anybody connected to a remote MySQL database in VB.NET?
Hi all!
I am trying to connect to a remote MySQL database. This database is located on my LAN at the address 192.168.1.2. I am using MySQL Connector/ODBC 3.51 (MyODBC 3.51) for the connection.
The connection string that I am using is the following-
Driver={MySQL ODBC 3.51 Driver};Server=192.168.1.2;Database=mydb;User=root; Password=;Option=3;
The error message that I get is not too intuitive - SystemEventArgs
Has anybody connected to a remote MySQL database in VB.NET?
Maybe this thread should be moved to the databases forum?
Hi all!
I've always used MySQL with my VB.NET applications and I am not too good with MS Office either.
The situation I have now is that in a Word Document, there is a table from which I am interested in extracting one column and adding it as a column of a MySQL table in a database.
Any ideas?
Here is a much simpler code to generate random passwords. The code is in VB.NET
Public Class Form1
Public Function GenerateRandomPassword(ByVal length As Integer) As String
Dim strGuid As String = System.Guid.NewGuid().ToString()
strGuid = strGuid.Replace("-", String.Empty)
Return strGuid.Substring(0, length)
End Function
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim s As String
s = GenerateRandomPassword(8) 'Pass length as arguement
Me.TextBox1.Text = s
End Sub
End Class
hi david,
I want to customize the login form.
Look at an ASCII value table. You will get your answer.
Passing variables between pages can be done using Query Strings.
Response.Redirect("somepage.aspx?name=" & Me.TextBox1.Text)
The value of the user input in the TextBox1 of the page can be retrieved in the page you redirect to using-
Request.QueryString("name")
Hi all!
Is there any way in which I can customize the look of the CPanel webmail so as to have custom webmail login with say the company logo and other things on the page?
I'm doing a program on the addition of 2 Sparse Matrices. This is what I have coded-
import java.io.*;
class Sparse
{
int r,c,m[][],s[][],count,rt;
static int res[][];
public Sparse()
{
count=0;
rt=1;
}
//Take the matrix
public void read() throws Throwable
{
BufferedReader buff=new BufferedReader(new InputStreamReader(System.in));
System.out.print("Enter the number of rows: ");
r=Integer.parseInt(buff.readLine());
System.out.print("Enter the number of columns: ");
c=Integer.parseInt(buff.readLine());
m=new int[r][c];
for(int i=0;i<r;i++)
{
for(int j=0;j<c;j++)
{
System.out.print("Enter the element m[" + i +"]["+ j + "]: ");
m[i][j]=Integer.parseInt(buff.readLine());
if(m[i][j] !=0)
count++;
}
}
}
public void display() throws Throwable
{
System.out.println("The matrix is as follows: ");
for(int i=0;i<r;i++)
{
for(int j=0;j<c;j++)
{
System.out.print(m[i][j]+" ");
}
System.out.println();
}
}
public void displaysparse() throws Throwable
{
System.out.println("The sparse matrix is as follows: ");
for(int i=0;i<rt;i++)
{
for(int j=0;j<3;j++)
{
System.out.print(s[i][j]+" ");
}
System.out.println();
}
}
//Create the sparse
public void create()
{
s=new int[count+1][3];
s[0][0]=r;
s[0][1]=c;
s[0][2]=count;
for(int i=0;i<r;i++)
{
for(int j=0;j<c;j++)
{
if (m[i][j]!=0)
{
s[rt][0]=i;
s[rt][1]=j;
s[rt][2]=m[i][j];
rt++;
}
}
}
}
public static void add(Sparse a,Sparse b) throws Throwable
{
int temp_count=0;
if (a.r== b.r && a.c==b.c)
{
for(int i=1;i<a.rt;i++)
{
//Getting a row of s[i][j] belonging to 'a'
for(int j=1;j<b.rt;j++)
{
if(a.s[i][0]==b.s[j][0] && a.s[i][1]==b.s[j][1])
temp_count++;
}
}
//System.out.println("Common Elements: "+temp_count);
res=new int[a.count+b.count-temp_count+1][3];
res[0][0]=a.r;
res[0][1]=a.c;
res[0][2]=a.count+b.count-temp_count;
int x=1;
boolean flag;
for(int i=1;i<a.rt;i++)
{
flag=false;
//Getting a row of s[i][j] belonging to 'a'
for(int j=1;j<b.rt;j++)
{
if(a.s[i][0]==b.s[j][0] && a.s[i][1]==b.s[j][1])
{
res[x][0]=a.s[i][0];
res[x][1]=a.s[i][1];
res[x][2]=a.s[i][2]+b.s[j][2];
x++;
flag=true;
}
}
if(flag==false)
{
//this element of 'a' does not find a …
Umm... I think you should maintain a database of 'suggests' for showing them in the 2nd TextBox
As @bhi said, enable the autopostback property for the 1st textbox and do this-
"Select * from <table> where <field> like" & me.textbox1.text & "%"
This sql is for the 'suggests'. If you need some other field, just modify your sql statement.
Bind the result of this query to your multi-line 2nd textbox.
You can do this in AJAX too.
umm.. what prasu says is correct.
Its just that sometimes you may have to do a lot of comparisons.
Try this-
Just generate 16 x 40 numbers random numbers using the code. If you want it in the range as said, find the remainder of the generated random numbers on division by 10. Then split this one dimensional array into the matrix you need.
------
Hopefully you will get as you need.
But by no means is this the best way to go. There might (must) be a better way.
------
Are you using this for an online test application?
Can you tell me the range in which you need these integers?
I have something in mind which depends upon this.
tuse,
thanks for your reply. Yes that is a good idea, but if i fill the first line with 16 integers (aided by an array) I would want the next group of 16 to be unique as a group. So if I generate 1000 of such group of 16 integers no group would apear twice. I hope the challenge is clearer.Thanks
Do you mean the uniqueness of the numbers should be restricted to a group of 16 or do you want 16 x 40 unique numbers
--------------------
Yeah I got what you are trying to say.
Hi jamello!
Its made in Visual Studio 2008 using .NET Framework 3.5
ps- You need to have AJAX in order to get it working in VS 2005
I think he means that the column (i.e. field names) names must be sorted. Not the records
Use the Random Class.
Dim arbit As New Random
Randomize()
X: For i = 0 To a.GetUpperBound(0)
t = arbit.Next(1, 10)
' Generate between the numbers 1 and 10
If Array.IndexOf(a, t) = -1 Then
a(i) = t
Else
GoTo X
End If
Next
Here I am filling an array with random numbers. Note that I have used the goto statement so ensure that unique numbers are inserted into the array. (Avoiding Duplicates)
Here is the link for an Online Examination Project that I made- http://dotnet.tekyt.info/?p=34
Its free :)
hi pranav
could you please post the code you wrote?
Do you really want your application to do some 'work' ? If so, you can play with loops.
If not, you can use a timer control and code for an event after a defined number of ticks.
Here is the code. You need 2 TextBoxes, 1 Button and 1 ErrorProvider Control on your Login Form. I've used a MySQL database, you may use whatever suits you.
Public Class Login
Dim cn As New Odbc.OdbcConnection("Driver={MySQL ODBC 3.51 Driver};Server=localhost;Database=mydrupaldb; User=root;Password=;")
Private Sub login_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
cn.Close()
End Sub
Private Sub login_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
cn.Open()
Me.Button1.Enabled = False
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
'Define the SQL Command to retrieve records from the database
Dim cmd As New Odbc.OdbcCommand("select * from users where name=? and pass=?", cn)
cmd.Parameters.Add("@name", Odbc.OdbcType.VarChar, 60)
cmd.Parameters("@name").Value = Me.TextBox1.Text
cmd.Parameters.Add("@pass", Odbc.OdbcType.VarChar, 32)
cmd.Parameters("@pass").Value = Me.TextBox2.Text
'We have a Data Reader to read the values returned by the SQL Command Execution
Dim dr As Odbc.OdbcDataReader
dr = cmd.ExecuteReader
'Check if username and password exist.
If dr.HasRows = True Then
'If exists, then we show the next form which contains the application, in my case its Form1
Form1.Show()
Else
' Incorrect Login Details Supplied
Me.ErrorProvider1.SetError(Me.Button1, "Incorrect Login...Try again")
Me.TextBox1.Clear()
Me.TextBox2.Clear()
Me.Button1.Enabled = False
End If
End Sub
Private Sub TextBox2_LostFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles TextBox2.LostFocus
Me.Button1.Enabled = True
Me.ErrorProvider1.Clear()
End Sub
If you have stored your passwords in the database in MD5 encryption (which is generally preferable), you can find the code for that here- http://dotnet.tekyt.info/?p=24
Use another SQL statement. Construct it like this-
Dim strSQL2 As String = "SELECT product_id FROM product where product_name=" & Me.cmbDropDown.SelectedItem
hi greeny,
could you please enable debugging in your web.config and tell me where exactly you are getting the error?
Just take a look at the sample code given here- http://dotnet.tekyt.info/?p=31
I have connected to a MySQL database using a ODBC Connector.
Read this post for clarity and the download source- http://dotnet.tekyt.info/?p=9
Its just that the code is in VB.NET. I guess you can still figure out the logic
I have made a similar project. You might want to see the code-
http://dotnet.tekyt.info/?p=34
In case you have any doubts about the code, do ask here.