|
Hey Experts
I have a littel problem maybe som of experts can help me:
I have this code to select somthing for sql database, now i need to send this query like email, how can i send the Dataset like email ?
The code:
int Customerid =(int)(dr["CustomerId"]);
string customer = dr["Customer"].ToString();
SqlCommand cmd2 = new SqlCommand("licensesexpireddato", con);
cmd2.CommandType = CommandType.StoredProcedure;
cmd2.Parameters.AddWithValue("@KundeID", Customerid);
DataSet ForDataset = new DataSet();
SqlDataAdapter da2 = new SqlDataAdapter(cmd2);
da2.Fill(ForDataset);
cmd2.ExecuteNonQuery();
I hope i can help me, sorry my english.
|
|
|
|
|
You can't send it directly as e-mail as the object would need to be marshalled across an application boundary.
One of the following is probably what you need:
1. Expose your method in a WCF/Web service
2. Google "Serialization", which allows you to write objects out as text.Dalek Dave: There are many words that some find offensive, Homosexuality, Alcoholism, Religion, Visual Basic, Manchester United, Butter.
Pete o'Hanlon: If it wasn't insulting tools, I'd say you were dumber than a bag of spanners.
|
|
|
|
|
A dataset is an XML document, so you could use an XSLT transform to convert your dataset XML to text or HTML, then send it to an email recipient.
|
|
|
|
|
I have a bytes array and I want to create a new video file, I need to know exactly what the fomat's structure should be and then add the data chunk.
|
|
|
|
|
yftah1989 wrote: I need to know exactly what the fomat's structure should be
That depends on the codec used to compress the movie. This CodeProject-article[^] might get you started I are Troll
|
|
|
|
|
I think you can use the DirectShow, and it can help you get the type of the video and decode the video.
Try this:
http://en.wikipedia.org/wiki/DirectShow
modified 27-May-14 4:48am.
|
|
|
|
|
Hi,
I'm wondering if there is a way to achieve this :
I know you can but some arguments to the compiler to condition compiling with #if #else #endif
But what if I would like to have in some cases :
using namespace1.subspace1; //in one case
using namespace2.subspace3; //in another case
and so on ... without knowing by advance the list of namespaces (in a code file used by several projects)
I wish I could write :
using #MYNAMESPACE;
telling the compiler MYNAMESPACE=namespace1.subspace1
Is there any syntax for this ?
Thanks
|
|
|
|
|
Do you mean using a namespace alias as shown here[^]?Me, I'm dishonest. And a dishonest man you can always trust to be dishonest. Honestly. It's the honest ones you want to watch out for...
|
|
|
|
|
|
Yes this is approximately what I need, with the "using project=namespace.project" statement beeing outside the code file, so I do NOT have to change the content of the code file in each project using it ...
|
|
|
|
|
This should be really simple, but im having one of those mornings...
Im trying to close my connection, but its staying open
if (Border.BLL.Inventory.SqlConnect.GetConnection().State == ConnectionState.Open)
{
Border.BLL.Inventory.SqlConnect.CloseConnection();
}
//BLL
public static SqlCeConnection CloseConnection()
{
return DAL.Helpers.SQLconnect.CloseConnection();
}
//DAL
public static SqlCeConnection GetConnection()
{
SqlCeConnection conn = new SqlCeConnection();
try
{
conn.ConnectionString = Helpers.ConnectionCommand.ConnectionString;
conn.Open();
return conn;
}
catch(Exception e)
{
if (conn.State == ConnectionState.Open)
{
conn.Close();
}
Border.Model.Helpers.FileWriter.Write(e.ToString(), true);
}
return conn;
}
public static SqlCeConnection CloseConnection()
{
try
{
if (GetConnection() != null)
{
if (GetConnection().State == ConnectionState.Open)
{
GetConnection().Close();
}
}
return GetConnection();
}
catch (Exception e)
{
if (GetConnection().State == ConnectionState.Open)
{
GetConnection().Close();
}
Border.Model.Helpers.FileWriter.Write(e.ToString(), true);
}
return GetConnection();
}
|
|
|
|
|
Please put your code in <pre> tags, it is currently difficult to read.
consider using the following snippet:
using(SqlCeConnection connection = GetConnection())
{
}
as this will close the connection automagically for you, even if the database call throws an exception.Dalek Dave: There are many words that some find offensive, Homosexuality, Alcoholism, Religion, Visual Basic, Manchester United, Butter.
Pete o'Hanlon: If it wasn't insulting tools, I'd say you were dumber than a bag of spanners.
|
|
|
|
|
Hi,
I went through your code, and got a point to tell you if that helps. I noticed that in catch block in DAL you are closing the connection only if the connection state is OPEN. I remember there is another option that you may also check before you are closing the connection and that is BROKEN. So what I am suggesting is ,
if ((GetConnection().State == ConnectionState.Open)||((GetConnection().State == ConnectionState.Broken))
{
GetConnection().Close();
}
or
if (GetConnection().State != ConnectionState.Closed)
{
GetConnection().Close();
}
Give a try and let me know.Thanks,
Arindam D Tewary
|
|
|
|
|
Arindam Tewary wrote: if ((GetConnection().State == ConnectionState.Open)||((GetConnection().State == ConnectionState.Broken))
This isn't a good idea since his code is returning a new connection object on every call to GetConnection. It's not returning the same connection object, but a new one every time. So, you're comparing the first connections .State to Open OR the second connection objects state to Broken. It's not doing what you think it's doing.
|
|
|
|
|
doh!
thanks that makes perfect sense.
|
|
|
|
|
I deduce inquiry data from data base in dataGridView (on image) I wish to deduce these data in Excel as on the image. How to me it to make?
http://www.cyberforum.ru/windows-forms/thread105166.html#post601894
|
|
|
|
|
I use one image as the background picture. But when open the form, it shows so slow.
How to solve it ?
|
|
|
|
|
What are the things you are doing when the form is loading? Is it possible to move some of that to another thread?
You can also use a splash screen and display the form only when all the operations are done.
|
|
|
|
|
Only initialize 20 controls, in which a circle is drawed.
I try to delete background image, the form shows more quickly.
So , it must the background image's problem.
I am trying your solution,
thanks very much.
|
|
|
|
|
I wonder if you are shrinking the image to fit, or should I say, .Net is shrinking it to fit.
Check the actual size of the image and resize it to no larger than your form.
You could also try some of the tricks from the html world, for example if you are aiming for a gradient fill, use a 1 pixel wide image and stretch it.
|
|
|
|
|
Thanks for your reply.
I donot shrink this image. but I only set the image as the background image of the form, perhaps this form's size is not equals to this image's size, when OnPaint it need use much time to let the image size to fix the form's size?
I put many control in the forms, such as panle. I set these control's backcolor as transparent.
Does the backcolor's transparent cost much time?
|
|
|
|
|
20 controls should not slow things drastically down. As the other reply mentions, check the image size and resize it to your needs.
The type of file also matters. A bitmap file will be of a way more size (Bytes) than a same sized (dimension) JPG or JPEG.
|
|
|
|
|
The image is about 30kB in JPEG format, I will try to minish its size.
|
|
|
|
|
|
You should read the sticky post "How to get an answer to your question".
In the Main method or in the main form's load event, check the processes running. If it contains your application, exit and display a message that application is already running.
|
|
|
|
|
Thanks big friends you have very much helped me.
|
|
|
|