|
Hi,
On the key press event write the following code:
this.InvokeOnClick(button1, e);
|
|
|
|
|
hello,
I am trying to insert data into a database.My code gives no error.
But the values are not inserted into database.
Please help...can anyone send a sample code
|
|
|
|
|
Could u show ur code?
Is there any error in database connection?
|
|
|
|
|
Your question is not explaining anything about what you did. Have you put breakpoints and stepped into the code ?
|
|
|
|
|
No..Please tell how to go about
|
|
|
|
|
are you trying to insert data from textBox or other controls?
are you using Oracle or SQl ?...plz. give some details....
|
|
|
|
|
I am trying to insert from textbox.I am using SQL
|
|
|
|
|
use a breakpoint to see if the text box value is parsed properly in the query. also, check the single and double quotes. they need to be in a proper sequence for the value to be fetched.
|
|
|
|
|
using System.Data.SqlClient;
using System.Data.OleDb;
code for connecting to SQL database:-
try
{
SqlConnection mc = new SqlConnection(Persist Security Info=False;User ID=sa;Initial Catalog=DataBase_Name;Data Source= SQL_Server_Name");
SqlDataAdapter da =new SqlDataAdapter("Select * from Table_name", mc);
DataSet ds =new DataSet();
da.Fill(ds,"Table_name");
MessageBox.Show("Connection Successfull");
}
catch(Exception ex)
{MessageBox.Show(ex.Message);
}
code for inserting data from textBox:-
try{
SqlCommand insertCmd=new SqlCommand("insert into Table_Name(Column_Name)values(@Variable_name)",Connection_Name);
insertCmd.Parameters.Add("@Variable_Name",SqlDbType.Nchar,10);
insertCmd.Parameters["@Variable_Name"].Value=textBox1.Text;
insertCmd.ExecuteNonQuery();
MessageBox.Show("Records inserted successfully");
}
catch(Exception ex)
{MessageBox.Show(ex.Message);}
|
|
|
|
|
hello,
in .net it is possible to set the opacity of an window.form, but thats for the whole window, how can i make it, that i have only a part of the window transulent? for example only a rectangle from:
X=0
Y=0
W=this.Width
H=50
is something like that possible?
|
|
|
|
|
Hi,
You can use the form property "Transparencykey".
How to use?
1) Set the Transparencykey value to a color, for e.g. Red.
2) Add a panel control and set his color to Red.
3) Run the application.
Note: All controls that will have the same color as you specify in the Transparencykey will be
Transparent.
|
|
|
|
|
i have a C# windows application in which i have a button PRINT .On clicking the button, data from textboxes is taken and inserted into particular cells of an MS Excel sheet. I have a textbox BILL NO. and i want that every time i click the PRINT button the value in BILL NO.textbox should be incremented so that it can be inserted into a particular cell of MS Excel sheet.
for e.g. if i have entered 0 in the BILL NO. textbox,everytime i click the PRINT button the text in the textbox should be incremented to 1,2,3....and so on. i have tried a few options ...but whenever i run the application the count starts from 0......PLZ. HElp
|
|
|
|
|
Hello,
If I understand correctly, you want that each time application is started, the value in the TextBox
should be incremented for the last value that was used.
Well if thats the case then you will have to store the value each time the application is closed and
then read it back again into the text box and increment the value.
I hope this helps.
Allen Smith
ComponentOne LLC
www.componentone.com
|
|
|
|
|
|
thanks for the reply Allen ...that's exactly what i wanted....i am new to .net programming so could you please give me a hint as to how i can store the value each time the application is closed and then read it back again into the text box and increment the value.
|
|
|
|
|
It all depends on what yuo have available. It really ought to be stored in a single location accessable to ANY user to avoid duplication.
Bob
Ashfield Consultants Ltd
|
|
|
|
|
thanks for the reply Ashfield...but i am new to C# programming...could you please give me a hint as to how to do it?
|
|
|
|
|
As I said, it all depends on what you have available. For example, it could be stored in a database table (along with all the other details), or it could be something as simple as a file located on a network share. Without knowing your system I really cannot say.
Bob
Ashfield Consultants Ltd
|
|
|
|
|
Thanks Ashfield. What i want is that on clicking a button PRINT the data in the BILL NO. textbox should be incremented and entered into a particular field of a database. I know how to enter the data from the textbox to the database . But the problem is that if i have entered 0 in the BILL NO. textbox and click the PRINT button, 1 is entered into the database field but when i close the application and run it again, the increment again starts from 0. I want that if the value in the textbox was 1 when the application was last run...it should be incremented to 2 when i run the application this time . i think i have made myself clear...but if u need any more background plz let me know...thanks for giving me the time
|
|
|
|
|
Well, if you enter the Bill No in a database, at the start of the program select the maximum bill no from the database and use that as your starting number rather than zero, and do not let the user enter it manually.
Hope this helps, its fairly normal practice.
Bob
Ashfield Consultants Ltd
|
|
|
|
|
Hi all,
I want to add a ListBox into a tab page at run time, not design time. Can someone give me a clue.
Thanks
I appreciate your help all the time...
CodingLover
|
|
|
|
|
this is something i made a few days ago...
private void tabControl1_SelectedIndexChanged(object sender, EventArgs e)
{
RefreshList();
switch (tabControl1.SelectedIndex)
{
case 0:
tabPage1.Controls.Add(groupBox2);
tabPage1.Controls.Add(groupBox1);
break;
case 1:
tabPage2.Controls.Add(groupBox2);
tabPage2.Controls.Add(groupBox1);
break;
case 2:
tabPage3.Controls.Add(groupBox2);
tabPage3.Controls.Add(groupBox1);
break;
default:
break;
}
}
|
|
|
|
|
Mainly what I want to do is this.
In my tab control added three tabs. Initially added ListBox to the first tab. Next time, if the tab page 1 have a list box I want to add to the next tab page.
I appreciate your help all the time...
CodingLover
|
|
|
|
|
Michael gave you the answers, use selected tab to identify the page, check if the control has been added to the pages control collection if it is missing then add it to the collection. All the commands are in Michaels example, you can't expect someone to write it to match your somewhat twisted logic.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
I'm not expecting any code pal. I just wonder how to find a page has a control or not. In other words, how to find something is contain in a specific tab page.
I appreciate your help all the time...
CodingLover
|
|
|
|