|
You would do better by using a trusted connection and setting up in SQL Server the windows accounts that are permitted to access the database.
|
|
|
|
|
Hello All,
I want to connect to my oracle DB from my login control ,how can I do this???
Nishu
|
|
|
|
|
//I have a problem with saving data from datasetts back to database, please help me. Im using mysql connector but work with mysql amd mssql is very similar (i think )
//First i create a data adapter (reading data is ok):
public MySqlDataAdapter postsAdapter(int iddisscussion)
{
MySqlConnection conn = new MySqlConnection(this.connect);
MySqlDataAdapter da = new MySqlDataAdapter();
MySqlCommand cmd;
MySqlParameter parm;
cmd = new MySqlCommand("SELECT idpost, iddiscussion, idup, poster_name, poster_email, subject, message, date_create, CONCAT(date_create, ' - ', subject) AS posts_list FROM " + pfx + "module_discussion_posts WHERE iddiscussion='" + iddisscussion + "' ORDER BY date_create DESC LIMIT 30;", conn);
da.SelectCommand = cmd;
cmd = new MySqlCommand("UPDATE " + pfx + "module_discussion_posts SET poster_name=?name, poster_email=?mail, subject=?subject, message=?message WHERE idpost=?oldId;", conn);
//cmd.Parameters.Add("?oldId", MySqlDbType.Int16, 11, "idpost");
cmd.Parameters.Add("?name", MySqlDbType.VarChar, 100, "poster_name");
cmd.Parameters.Add("?mail", MySqlDbType.VarChar, 80, "poster_email");
cmd.Parameters.Add("?subject", MySqlDbType.VarChar, 255, "subject");
cmd.Parameters.Add("?message", MySqlDbType.VarString, 0, "message");
parm = cmd.Parameters.Add("?oldId", MySqlDbType.Int16, 11, "idpost");
parm.SourceVersion = DataRowVersion.Original;
da.UpdateCommand = cmd;
return da;
}
// Second ... in another function ...
classDiscussions cd = new classDiscussions();
postsDA = cd.postsAdapter(Convert.ToInt32(this.iddiscussion.Text)); // data adapter from previous step
postsCB = new MySqlCommandBuilder(postsDA); // command builder
postsDS = new DataSet(); // dataset
postsDA.Fill(postsDS, "module_discussion_posts"); // fill dataset
this.posts.DataSource = postsDS; // setting dataset for list view
this.posts.DisplayMember = "module_discussion_posts.subject";
this.idpost.DataBindings.Clear(); // setting dataset for text box
this.idpost.DataBindings.Add(new Binding("Text", postsDS, "module_discussion_posts.iddiscussion"));
// third ... when i change datas in data set i want to save this changes back to database ... but its nt working ... pleeeeeeeeeease help me
postsDA.UpdateCommand = postsCB.DataAdapter.UpdateCommand;
//DataSet changes = postsDS.GetChanges();
postsDA.Update(this.postsDS, "module_discussion_posts");
postsDS.AcceptChanges();
-----------------------------
Computer is my hell on earth
|
|
|
|
|
please help me ....
-----------------------------
Computer is my hell on earth
|
|
|
|
|
I don't use DataAdapters much, and never MySql, so I may be way off base:
In the first part you create a DataAdapter and then set its commands.
Unless you really need to customize the UpdateCommand you probably ought to use
MySqlDataAdapter da = new MySqlDataAdapter ( selectcommandtext ) ;
In the second part I see no need for the CommandBuilder.
I also tend not to use a DataSet to hold just one DataTable, but that's just me.
Then in the third part you should only need the
postsDA.Update(this.postsDS, "module_discussion_posts");
|
|
|
|
|
its not working, its same code what i have but im using another way to create data adapter
-----------------------------
Computer is my hell on earth
|
|
|
|
|
I have notice this http://www.mono-project.com/CSharp_Compiler since I'm on slow connection can't try it on my own for now, but I wonder if someone is using it do you like it how it work, are final results OK?
Does programs run fine under Linux compiled with it?
|
|
|
|
|
How to write hex, dword and binary values in the registry.
This code:
key.SetValue("SomeKey","Value");
is for inserting a string.
Help.
Vasildb
|
|
|
|
|
Dim regKey As RegistryKey
Dim ver As Decimal
regKey = Registry.LocalMachine.OpenSubKey("Software\MyApp", True)
regKey.SetValue("AppName", "MyRegApp")
Ref : http://72.14.253.104/search?q=cache:M_c-V-CC1xgJ:www.codeproject.com/vb/net/registry_with_vb.asp+add+value+in+registry+key+vb.net&hl=en&gl=in&ct=clnk&cd=3
Keep Smiling !!!
Parwej Ahamad
g_parwez@rediffmail.com
|
|
|
|
|
You can use
Encoding.[UTF7/UTF8/etc].GetByte(String param)
and viceversa
Encoding.[UTF7/UTF8/etc].GetString(byte[] b)
to convert method to/from byte to string and viceversa than save it in registry.
|
|
|
|
|
Hi all,
I'm trying to highlight spesific word inside a cell on any cell within a datagridviewcontrol, to do this i have write a special code inside OnCellPaint method
string v = e.FormattedValue.ToString().ToLower();
int idx = v.IndexOf(searchWord.ToLower());
if (idx != -1)
{
System.Drawing.Font ff = e.CellStyle.Font;
// get a length word before searchWord/highlightWord
int addx = e.Graphics.MeasureString(e.FormattedValue.ToString().Substring(0, idx), ff).ToSize().Width;
// get a length searchWord
int w = e.Graphics.MeasureString(e.FormattedValue.ToString().Substring(idx, searchWord.Length), ff).ToSize().Width;
// draw highlight background
Brush br2 = new SolidBrush(blockColor);
e.Graphics.FillRectangle(br2, new Rectangle(e.CellBounds.X + addx, e.CellBounds.Y + 1, w, e.CellBounds.Height - 3));
homever measurestring didn't return correct size from current cell text, therefore highlighted background didn't placed on right position. This code also doesn't work on cell with currency formatted cell because currency cell is rightalignment. My question is how do i get correct size in pixel from current cell text using measurestring ? Because measurestring combined with e.cellstyle.font didn't return correct size.
|
|
|
|
|
MSDN says: "The MeasureString method is designed for use with individual strings and includes a small amount of extra space before and after the string to allow for overhanging glyphs. Also, the DrawString method adjusts glyph points to optimize display quality and might display a string narrower than reported by MeasureString . To obtain metrics suitable for adjacent strings in layout (for example, when implementing formatted text), use the MeasureCharacterRanges method ". It might help ...
SkyWalker
|
|
|
|
|
Hi
I m developing a web portal in c# asp.net web application .i want to built an email client using a third party email server e.g, MDeamon.my email client will include the functionalty as
Making new account
sending e mail with attachments
receiving email with inbox maintaing facility. etc
but i have not any idea about it. Can any one guide us first of all about the email server that which server should b used 2ndly how it can be used n from where v can get help regading its builtin methods to b used in email client.
v want help in C# not in HTML codin
Thanx
EEmaan
|
|
|
|
|
Please don't cross post.
---
Year happy = new Year(2007);
|
|
|
|
|
hi all,
i want to validate a text box which is used to enter multiple email addresses. can anyone of u tell, is it possible to use regular expression validator? or have to use java script??
kindly give a solution for the above problem.
thanks in advance
Regards
Babu
|
|
|
|
|
To validate comma separated values you just have to use a repeating pattern.
For a simple example, to verify a string of comma separated characters "a,b,x,y,z", you can use a pattern like "[a-z](,[a-z])*". To use it with email addresses, just substitute the [a-z] set with the pattern for an email address.
---
Year happy = new Year(2007);
|
|
|
|
|
Hi,
The requirement is that the end user would upload an image to the application, the uploaded image should be modified with a watermark and then be saved in our application. Kindly guide!!!
Thanks!!
Gautham
|
|
|
|
|
I'd suggest reading my image processing articles for info on how to access the pixels of a bitmap, then work out what sort of watermark you want to add. Assuming you don't just want to add a bitmap in the corner or something simple.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
A method like this may do the job, if you just want to add text to the image: (you'll need to include the System.Drawing reference and namespace)
Bitmap AddWaterMark(Bitmap uploadedBitmap)
{
Bitmap newBitmap = new Bitmap(uploadedBitmap);
Graphics g = Graphics.FromImage(newBitmap);
g.RotateTransform(45); // Angle of text
g.DrawString("Watermark Text",
new Font("Arial", 12f),
new SolidBrush(Color.FromArgb(100, Color.Black)), // the 100 is for transparency (0 = invisible, 255 = opaque)
new Point(100,100));
return newBitmap;
}
|
|
|
|
|
Thanks Bob!!!
Tried the given code. now that we have the graphics object which is updated. How to apply this to my image, to what should i assign the returned bitmapfile? how to save my final image with the watermark?
Thank you
Gautham
|
|
|
|
|
Hi Bob!
Sorry for the other question! It worked thanks a lot.
The only thing i have to think about is to place the text at a specific location irrespective the size of the image.
Thank You.
Gautham
|
|
|
|
|
New and improved Method to help you place the text perfectly diagonal and centered. All you have to decide on is the font and transparency.
Bitmap AddWaterMark(Bitmap uploadedBitmap)
{
Bitmap newBitmap = new Bitmap(uploadedBitmap);
Graphics g = Graphics.FromImage(newBitmap);
// This StringFormat will position the text so that
// the Point in the DrawString() method below is in
// the centre of the string rather than top-left
StringFormat strFormat = new StringFormat();
strFormat.Alignment = StringAlignment.Center;
strFormat.LineAlignment = StringAlignment.Center;
// Here we use a bit of Trigonometry to calculate the angle
// so that we can draw the string perfectly diagonally based
// passed bitmap dimensions
double tangent = (double)newBitmap.Height / (double)newBitmap.Width;
double angle = Math.Atan(tangent) * (180 / Math.PI);
// Here we adjust the position so that we place the text half-way
// along the hypotenuse (diagonal line through bitmap)
double halfHyponenuse = Math.Sqrt((newBitmap.Width * newBitmap.Width) +
(newBitmap.Height * newBitmap.Height)) / 2;
g.RotateTransform((float)angle);
g.DrawString("Watermark Text",
new Font("Arial", 12f),
new SolidBrush(Color.FromArgb(200, Color.Black)),
new Point((int)halfHyponenuse, 0),
strFormat);
return newBitmap;
}
-- modified at 9:09 Tuesday 23rd January, 2007
|
|
|
|
|
Hi,
Can any one help me to build a listview control where i can add two check box in the last right column of listview.
|
|
|
|
|
Even though its possible, its not simple... Why dont you u use datagrid? Its easy to do that with datagrid....
|
|
|
|
|
Hi,
I am looking for some tutorial in c# object oriented programming.
Can anyone share some good links.
Have a good day
|
|
|
|
|