|
as above, I'm importing function from unrar.dll but I'm stucked in converting this..... thanks
|
|
|
|
|
|
|
Hi,
How to use "Custom actions" to run a SQL script in a file named aa.sql?
Thanks a lot!!
Alan
|
|
|
|
|
I don't know if this is best way , if you want to create database and its data and objects in your user machine,attach your database files to your project and copy it to user machine , then use sp_attach_db and run it from your application with ADO.NET classes to attach them to your server.
Mazy
"I think that only daring speculation can lead us further and not accumulation of facts." - Albert Einstein
|
|
|
|
|
Another way which I found it now is run osql utility and pass file name to it. See SQLServer Online Book for in frmation about it.
Mazy
"I think that only daring speculation can lead us further and not accumulation of facts." - Albert Einstein
|
|
|
|
|
Mazy:
Thank you very much for your solution,
but is it possible that I can use the "Custom Action" to run the SQL Script when I create the setup project(just like run some Exe files). I got some information from an article and it said it is ok to do so. but I don't know how. would you please tell me how to do it.
Thanks a lot!!
Alan Shen
|
|
|
|
|
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
|
|
|
|