|
It is possible, but there's many problems that may arise from doing this. For instance, osql.exe is only installed on a machine with SQL Server or MSDE installed. In your case, this may not be a problem, but it's something you must consider. Also, the executed might not even be in the PATH environment variable, so simply calling it won't work.
See the article, See the MSDE Deployment Toolkit in Action[^] on MSDN for a discussion about different ways about using Installer classes, if not using the tookit itself.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Hi everyone,
I have been writing a new c# custom control and i was wondering when you specify properties, how do you change them to things like True/False, Text etc.
I was also wondering if it was possible to disable properties somehow.
I have this code for one property:
<br />
[Bindable(true), Category("Colours"),<br />
Description("Changes the colour on the left hand side of the button")]<br />
<br />
public Color LeftColour<br />
{<br />
get { return m_color1; }<br />
set { m_color1 = value; Invalidate(); }<br />
}<br />
Which would of course let you change a color, and add a description, but how could i go about changing the type to text or something, or disable it ?
Thanks for any replies
|
|
|
|
|
Have a look at TypeConvertor's.
There is a wealth of info in/on MSDN describing custom controls.
|
|
|
|
|
I want to read serial number of drive (flopy cd or spec drive)
i think there is a api for this but i dont know ,
please help me
Regards Amir jalaly
|
|
|
|
|
|
i want to connect tow computer with modem and send information throw tel line without internet .
may be i must intialize connect and something else...
please help me
Regards amir jalaly
|
|
|
|
|
how can connect tow computer with modem . i mean send information in tel line without internet.
i need intialize connection and send file .
Regards' Amir jalaly
|
|
|
|
|
Hey!
I have a little problem, in datagrids there are always a empty row at the bottom.. how can i get this to dissapear? i heard that it can be done by setting the whole datagrid to readonly.. but that doesnt work since i have a column that has to be writable.. i just don't want the user to be able to write a "new" row.. anyone that can help?
|
|
|
|
|
You have to set AllowNew to false on the underlying DataView:
CurrencyManager cm = (CurrencyManager)myGrid.BindingContext<br />
[myGrid.DataSource, myGrid.DataMember];<br />
((DataView)cm.List).AllowNew = false;
|
|
|
|
|
Does anyone know, or has anyone ever tried to change the color of the arrow button at the side of a listbox or combobox control? or is it possible?
Thanks,
Mausy
|
|
|
|
|
Hello!
I need some help here. I want to be able to alter components on a form from another form. I figure i should be using delegates in some way but i can't really get it to work.. can someone please write me a small example? something small like changing a label.text on form1 from a button on form2?
|
|
|
|
|
in Form2:
public event EventHandler ButtonClicked;
private void Button_Clicked(object sender, EvenArgs e)
{
if(this.ButtonClicked != null)
this.ButtonClicked(this, EventArgs.Empty);
}
in Form1:
subscribe to ButtonClicked - Event of Form2 somewhere before you show Form2, just like this:
Form2 form2 = new Form2();
form2.ButtonClicked += new EventHandler(this.ChangeLabel);
form2.Show();
private void ChangeLabel(object sender, EventArgs e)
{
this.label1.Text = "Button on Form2 has been clicked.";
}
|
|
|
|
|
ok here is my print page event
//files is a string[] which has my file name in it
private void PrintPage(object sender ,PrintPageEventArgs e)
{
System.IO.FileStream fs ;
for(int j=0;j!=files.Length;j++)
{
fs= new FileStream(files[j],FileMode.Open,FileAccess.Read);
Image newImage = Image.FromStream(fs);
e.Graphics.DrawImage(newImage, e.Graphics.VisibleClipBounds);
fs.Close();
e.HasMorePages=true;
}
e.HasMorePages=false;
}
but this only prints out the last file i send to it
how do i fix this to print out all of my files
chad
|
|
|
|
|
Because you're iterating through all your images in the handler that prints one page, simply drawing each image to the Graphics object such that the last one is the one that shows up.
You need to design your code so that each call to your PrintPage event handler uses the next file, perhaps by maintaining an index to which file you want to print and incrementing it after printing your file.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
I have a window form name Login and a database with a Table name Login it has two fleids usernm, pwd.
usernm is to hold user names and pwd is to hold password.
Ok on the form I have two text box name user_name and user_password. And two buttons. I want this to check the user name and pasword.
I have made a sqlConnection name sqlConn.
I have made a sqlCommand name sqlcommand1;
I have made a sqlDataReader name dataReader.
here is my part of my code. What am I doing wrong with my string?
void check_password()
{
string query = string.Format(S"SELECT * FROM BankLogin where usernm= '{0}' and pwd= '{1}'", user_name.Text, user_password);
sqlConn.Open();
sqlcommand(query, sqlConn);
slqcommand1.ExecuteReader();
}
Harrison Brock
|
|
|
|
|
How can we even know what's wrong if you don't tell us what exception you're getting?
I will say this, though: don't create SQL statements using string formatting anymore! That's an old hack that is riddled with encoding problems. What if the username and/or password contains a double or single quote? This forces you to have to encode the strings yourself.
Instead, use parameterized queries, which are much more elegant, powerful, and allow for easy batch updates. Use the appropriate DbParameter derivative class. So, if you're using System.Data.SqlClient.SqlCommand , then use the System.Data.SqlClient.SqlParameter . You declare the parameters using "@name" and then you can set their values at any time before executing the statement and can even receive output parameters (if the OLE DB driver supports it).
So, you're statement becomes this:
SqlConnection conn = new SqlConnection(
"Data Source=COMPUTERNAME; Initial Catalog=DBName; Integrated Security=SSPI");
SqlCommand cmd = conn.CreateCommand();
cmd.CommandText = "SELECT * FROM BankLogin WHERE usernm=@usernm AND pwd=@pwd";
SqlParameter usernm = cmd.Parameters.Add("@usernm", SqlDbType.NVarChar, 40);
SqlParameter pwd = cmd.Parameters.Add("@pwd", SqlDbType.NVarChar, 40);
SqlDataReader reader = null;
try
{
usernm.Value = "username";
pwd.Value = "password";
reader = cmd.ExecuteReader();
}
catch (Exception ex)
{
Console.Error.WriteLine("Error: {0}", ex.Message);
}
finally
{
if (reader != null) reader.Close();
conn.Close();
} You don't have to worry about encoding the text and you can simply change the values and run the query again if needs be.
See the documentation for the SqlDataReader in the .NET Framework SDK for more information and examples.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
G'Day Harrison
I cant help you with the question that you asked but I can tell you something that will help you down the track: I recently tried to do the same thing and store a users login information in a database. This is bad practice because the users information can be easily read from the database! You should use encrytion and decryption.
Jon
|
|
|
|
|
Hello.
Given an array of binary data stored in an ArrayList container, do you associate the container as a datasource in a Data Grid control?
private ArrayList xList = new ArrayList();
// Arbitrarily add 64 integers into container
for (int i = 0; i < 64; ++i)
this.xList.Add(i);
// Assuming Data Grid was created via wizard
thisTheDataGrid.DataSource = this.xList;
thisTheDataGrid.Refresh();
The example above compiles okay. However, nothing shows up in the data grid. All you would see is 64 empty rows and no columns.
Do you need to set a specific property to show arbitrary data in the grid?
Thanks,
Kuphryn
|
|
|
|
|
You can use any IList or IListSource implementation (ArrayList implements IList ). If you have any DataGridTableStyle s configured in the DataGrid.TableStyles property, you must set the DataGridTableStyle.MappingName to the type, i.e. "ArrayList", so that it is mapped correctly.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Okay. Thanks.
I tried inserting "ArrayList" as the mapping name for the tablestyle. That did not make a difference.
The problem is still that nothing shows up in the Data Grid. In fact, there are no grid line. All I see are row borders.
Kuphryn
|
|
|
|
|
If you are using table styles and they don't apply to the current data binding, that what you should expect to see. Instead of an ArrayList , use an int[] array and use "int[]" as the DataGridTableStyle.MappingName . See the documentation for DataGridTableStyle.MappingName in the .NET Framework SDK for more information.
Are you even using table styles? If so, maybe try not adding them and you should see something. Again, a data source can be anything that implements IList or IListSource . Some controls' DataSource properties will even except IEnumerable implementations as a last resort.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Hi,
I develop a control that derived from TextBox control. I want to give a Bitmap to it when it displayed on the VS.Net toolbox. and I also want if the bitmap file is not exist, the default bitmap should be the standard TextBox control's bitmap. how to write the "[ToolBitmap()]".
Thanks a lot!
Alan
|
|
|
|
|
The best way is to make sure it always exists. Embed the image as an embedded resource in your project (change the Build Action to "Embedded Resource" in the project after adding the image to your project if you haven't already).
Then, in the ToolboxBitmapAttribute , you have a couple options. If it uses the same namespace and name as a class and has the .bmp extension (so a Windows bitmap), then you can simply specify the type of the class that's named like it using [ToolboxBitmap(typeof(MyClass))] . If it simply shares the same namespace, you can use [ToolboxBitmap(typeof(MyClass), "SomeImage.bmp")] . If you want to worry about having to the deploy the image as well, you can just specify the name like [ToolboxBitmap("SomeImage.bmp")] . The former two ways are much better and will ensure that your image always exists.
BTW, the namespace of the image is obtained using the root namespace of your project (defaults to the project name) plus any folders it might be in within your project. These folders will also cause VS.NET to use the same scheme to create a namespace for your classes that you add to your project/folder, but moving that source file will not automatically change its namespace. It will for embedded resources, though.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
In Visual C++ 6.0 you used to be able to go to the next error or find in files tag by pressing F4. This no longer works in Visual Studio.Net 2003. Does anyone know the keyboard shortcut for "Go To Error/Tag" in Visual Studio.Net 2003?
<RANT>
Does anyone else find it frustrating that Microsoft changed most of the keyboard shortcuts between Visual C++ 6.0 and Visual Studio.Net 2003?
</RANT>
Sincerely,
-Ron
|
|
|
|
|
Try pressing F8, I think it work for errors as well as the mulit-file find.
Gary
|
|
|
|