2
Answers

Update List Items through Email directly

Arjit

Arjit

7y
215
1
Hello everyone,
 
I want to make some functionality where I am sending some mail to user and in that mail there would be a inline form which has buttons to perform some task. When user clicks on these buttons I need to update list items in my SharePoint List without open any page or link.
 
I researched for this and found it could be possible by infopath, Can anyone does this kind of functionality?
 
Please help...
Answers (2)
0
Amit Choudhary

Amit Choudhary

NA 27.7k 3m 14y
well param1 is an object of SqlParameter class that helps to map the .Net Type data to the Sql Types data.

Hope it make sense.
0
vishnuvardhan diyyala

vishnuvardhan diyyala

NA 38 90.5k 14y

  Dear amit,
        By your example i got my mystake. But im unable to resolve that. y because i m a beginer(student) in .net. so unable to catch u r solution.
SqlParameter param1  = new SqlParameter();
 param.ParameterName = "@NewDate";

and
SqlParameter param2  = new SqlParameter();
 param.ParameterName = "@OldDate";
what is param1,parameter name in second line of above two sentences given by u.My database table name is totallogins.
on that table
id--------Auto no
tokenno----text
userid-----number
fromdate----date/time    and
todate----date time.
Could you pleae explain me about parameter method
Thanks in advance.
0
Amit Choudhary

Amit Choudhary

NA 27.7k 3m 14y
Thanks for clarification suthish...
0
Suthish Nair

Suthish Nair

NA 31.7k 4.6m 14y

1. Passing datetime as a string value.

2. Due to that Datatype mismatch happening.

3. SQLParameter will take care of all the formats between SQL DB table and your commands.

4. Best way if your DB table datatype column is DateTime then,
SqlParameter param = cmd.Parameters.Add("@datetime", System.Data.SqlDbType.DateTime).Value = DateTime.Now;

5. Do not convert to string value, can use Convert.ToDateTime() method.
0
Amit Choudhary

Amit Choudhary

NA 27.7k 3m 14y
I have faced the same problem a long time ago.. when i was try to insert the date into database using DateTime.Now.

Suthish is right by using the Parametrized query your problem will be solve.
 Here is the sample:
string st6 = "update totallogins set To_date =@NewDate

where from_date=@OldDate;
 cmd.CommandText = st6;
 SqlParameter param1  = new SqlParameter();
 param.ParameterName = "@NewDate";
 param.Value         = DateTime.Now;

 SqlParameter param2  = new SqlParameter();
 param.ParameterName = "@OldDate";
 param.Value         = b;

 cmd.Parameters.Add(param1);
  cmd.Parameters.Add(param2);
 cmd.Connection = con;
 con.Open();
 cmd.ExecuteNonQuery();
 con.Close();


Now Suthish i have question here and need your input.. why DateTime Could'nt save directly using the command object ?? Why do we need to use parameter to save the Date using DateTime class.

Thanks.

0
Suthish Nair

Suthish Nair

NA 31.7k 4.6m 14y

This not a good way of coding.. Leads to SQL Injection, always use Parameterized Query.

This will solve your problem, give same datatype during creating parameters.

Parameterized Query and SQL Injection Attacks