|
yes i know.
i tried to do it like this, but i have an error.
Dim cmd As New SqlCommand
cmd.Connection = mcon
cmd.CommandText = "insert into members(serial, name, familyname, address, phone, mobile, fax, email, website, space, timezone) values (@serial, @name, @familyname, @address, @phone, @mobile, @fax, @email, @website, @space, @timezone) ;"
cmd.Parameters.AddWithValue("@serial", txtserial.Text)
cmd.Parameters.AddWithValue("@name", txtname.Text)
cmd.Parameters.AddWithValue("@familyname", txtfamilyname.Text)
cmd.Parameters.AddWithValue("@address", txtaddress.Text)
cmd.Parameters.AddWithValue("@phone", txtphone.Text)
cmd.Parameters.AddWithValue("@mobile", txtmobile.Text)
cmd.Parameters.AddWithValue("@fax", txtfax.Text)
cmd.Parameters.AddWithValue("@email", txtemail.Text)
cmd.Parameters.AddWithValue("@website", txtwebsite.Text)
cmd.Parameters.AddWithValue("@space", txtspace.Text)
cmd.Parameters.AddWithValue("@timezone", cmbtimezone.Text)
cmd.ExecuteNonQuery()
fillgrid()
How am i going to set the identity to txtserial.text? in the parameters method?
|
|
|
|
|
Member 10506215 wrote: How am i going to set the identity to txtserial.text? You did not set it in the previous query where you concatenate strings. Why would you need to set it now?
The identity is generated by the database at the moment you perform the insert; you don't have to set it. You would like to fetch it - that's what the SELECT IDENT_CURRENT('members') would do.
Stop trying and start reading. If you continue using trial and error, you'll be building some things you're going to regret later.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Kindly help me by posting the code for uploading data from MySql Database into MSProject using C#.
Thanks and Regards
badarinarayan@live.com
|
|
|
|
|
|
Hello,
I want to read a packet from serial port,
I don't know the length of the packet,
so I have to wait a timeout for the first byte
and then I have to read all next bytes.
I supersed class
SerialPort
and I write the method
Receive
in ".NET Framework 4 Client Profile".
I try to use this code but
sometimes
Receive
works well, sometimes doesn't work
public class PortaCom : SerialPort
{
int timeout = 0;
public PortaCom(string portName, int baudRate, int timeout)
: base(portName, baudRate)
{
this.timeout = timeout;
base.Open();
}
public byte[] Receive()
{
List<Byte> ByteList = new List<Byte>();
DateTime Now = DateTime.Now;
base.ReadTimeout = 1;
int FirstByte = -1;
while (FirstByte == -1)
{
if (DateTime.Now - Now > TimeSpan.FromMilliseconds(timeout))
throw new TimeoutException();
try { FirstByte = base.ReadByte(); }
catch (TimeoutException) { }
}
int NextByte = FirstByte;
while (NextByte != -1)
{
try
{
Byte _NextByte = (Byte)NextByte;
ByteList.Add(_NextByte);
NextByte = base.ReadByte();
}
catch (TimeoutException)
{
return ByteList.ToArray();
}
}
return ByteList.ToArray();
}
}
Can someone help me ?
|
|
|
|
|
What does "doesn't work" mean? Did it throw an exception? Did it explode?
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
|
If "sometimes it works, and sometimes it doesn't", often the timeout value is set too low.
"1 ms" is very low; the lowest useable timeout I've used with my particular setup was 250ms; with other customers needing 2000ms+, depending on the environment.
Start with a higher timeout value; using one that works most, if not all the time; then lower it to just short of where issues set in.
|
|
|
|
|
I am Working on an ASP.Net website with c#.Net as Code Behind where I need to Call a phython script which does some business logic. Can anyone please tell me how to call a phython script from ASP.Net website.
|
|
|
|
|
Try the ASP.NET forum.
Veni, vidi, abiit domum
|
|
|
|
|
Process.Start() will help you.
|
|
|
|
|
I have to host this website on IIS server.. What else I have to do to run the website..
|
|
|
|
|
Well, having python installed would be a start.
|
|
|
|
|
|
Hi everybody
I´m trying to do my own Custom Control, and I followed this helpfull tutorial
Writing your Custom Control: step by step[^]
But I have a problem, I can´t see the properties that I have created.
This is my code
Imports System.Windows.Forms
Imports System.Drawing
Imports System.ComponentModel
Imports Microsoft.VisualBasic.PowerPacks
Public Class ClaseTarjeta
Inherits RectangleShape
Private Bit As Boolean
'<Browsable(True)>
<Description("Estado del Bit")>
<Category("BITS")>
Public Property EstadoBit() As Boolean
Get
Return Bit
End Get
Set(ByVal Value As Boolean)
Bit = Value
End Set
End Property
Sub New()
End Sub
And I have in the user control that
Imports ClassTarjeta
Public Class Tarjeta
Dim bit_0 As ClaseTarjeta
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
If bit_0.EstadoBit = False Then
rBit0.FillColor = Drawing.Color.Gray
Else
rBit0.FillColor = Drawing.Color.Green
End If
End Sub
Private Sub Tarjeta_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Timer1.Enabled = False
Timer1.Interval = 500
End Sub
End Class
any help will be gratefull, because I don´t know what I have made wrong
Sorry for my poor english
|
|
|
|
|
Why do you have two classes and what's with the timer? This stuff doesn't make a lot of sense as written.
|
|
|
|
|
You are right!!! Sorry. I´m writing again...
Edit:
Solved, I have made only one Class, and now works!!!
modified 8-Feb-14 10:34am.
|
|
|
|
|
Hello
I need a Help on toolstrip
I have to add 1000 button contol in toolstrip. the button are added successfully but if control (item) are over flow in toolstip then the some of the control are not visible. they get hide
So I request to give some help
Thanks
|
|
|
|
|
Adding 1000 buttons to a tool strip is just plain stupid. There is no good reason to do that. As a user, I wouldn't want to go through that list of buttons.
|
|
|
|
|
hi in web application I have saved one bitmap image to serverpath and once again if i try to save another image with the same name to the same server path i am getting follwing error
'System.Runtime.InteropServices.ExternalException' occurred in System.Drawing.dll but was not handled in user code
Additional information: A generic error occurred in GDI+.
and also if i try to delete that image file with the same path using below code
if (System.IO.File.Exists(serpath))
{
System.IO.File.Delete(serpath);
}
it is giving The process cannot access the file serpath because it is being used by another process.
How to resolve this.i need to overwrite the image with the same name and to the same location and also delete.
how to resolve this.
if anybody knows,Please Reply me. thanks in advance.
|
|
|
|
|
|
I have tried like this copying to new bitmap then disposing old bitmap and then saving new bitmap using below code
if (System.IO.File.Exists(serpath))
{
System.Drawing.Image myimage1;
myimage1 = System.Drawing.Image.FromFile(serpath);
System.Drawing.Bitmap source_bitmap = new System.Drawing.Bitmap(myimage1);
myimage1.Dispose();
int thumb_width = 400, thumb_height = 100;
System.Drawing.Bitmap thumb_bitmap = new System.Drawing.Bitmap(thumb_width, thumb_height);
System.Drawing.Graphics g = System.Drawing.Graphics.FromImage(thumb_bitmap);
g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;
g.FillRectangle(System.Drawing.Brushes.White, 0, 0, thumb_width, thumb_height);
g.DrawImage(source_bitmap, 0, 0, thumb_width, thumb_height);
g.Dispose();
System.Drawing.Imaging.ImageCodecInfo[] Info = System.Drawing.Imaging.ImageCodecInfo.GetImageEncoders();
System.Drawing.Imaging.EncoderParameters Params = new System.Drawing.Imaging.EncoderParameters(1);
Params.Param[0] = new System.Drawing.Imaging.EncoderParameter(System.Drawing.Imaging.Encoder.Quality, 100L);
thumb_bitmap.Save(serpath, Info[1], Params);
}
else
{
signatureImage.Save(serpath, ImageFormat.Jpeg);
}
but then also it is giving error 'System.Runtime.InteropServices.ExternalException' occurred in System.Drawing.dll but was not handled in user code Additional information: A generic error occurred in GDI+ and not able to delete that file also.
how to do this. Please reply me, thanks in advance.
|
|
|
|
|
I learned something new; the BitMap(Image img) constructor does all of that painting of the source Image to a new BitMap for you. Cool!
Now for your issue. Give this a try. I rewrote the logic to get the JPEG encoder assuming that is the one you wanted. If not, it is easy to change and understand now. There should really be some handling in there in the unlikely event that the encoder does not exist. But you can add that easily enough.
if (System.IO.File.Exists(serpath))
{
System.Drawing.Image myimage1 = System.Drawing.Image.FromFile(serpath);
int thumb_width = 400, thumb_height = 100;
using (System.Drawing.Bitmap thumb_bitmap = new System.Drawing.Bitmap(thumb_width, thumb_height))
{
using (System.Drawing.Graphics g = System.Drawing.Graphics.FromImage(thumb_bitmap))
{
g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;
g.Clear(Color.White);
g.DrawImage(myimage1, 0, 0, thumb_width, thumb_height);
}
myimage1.Dispose();
System.Drawing.Imaging.ImageCodecInfo jpeg = default(System.Drawing.Imaging.ImageCodecInfo);
jpeg = System.Drawing.Imaging.ImageCodecInfo.GetImageEncoders().
Where((System.Drawing.Imaging.ImageCodecInfo enc) =>
enc.FormatID == System.Drawing.Imaging.ImageFormat.Jpeg.Guid)
.FirstOrDefault();
System.Drawing.Imaging.EncoderParameters Params = new System.Drawing.Imaging.EncoderParameters(1);
Params.Param[0] = new System.Drawing.Imaging.EncoderParameter(System.Drawing.Imaging.Encoder.Quality, 100L);
thumb_bitmap.Save(serpath, jpeg, Params);
}
}
else
{
signatureImage.Save(serpath, System.Drawing.Imaging.ImageFormat.Jpeg);
}
}
|
|
|
|
|
Actually using this code the blank image is coming. Using my previous code only i am getting updated image to the same location with the same name. Only problem is after sending mail with this image iinked to the html and after html mail delivery, i am not able to again save new updated image with same name and to the same location.
How to resolve this. Please reply me. Thanks in advance.
|
|
|
|
|
hello
Please share us complete details i.e how you are displaying an images on site.
as this is due to image object is not getting null after rendring images and it is till in use at server.
|
|
|
|