Hello there, I am new here, and Thank you for taking the time to read this and hopefully I can get helped :) ... I will cross my fingers.
Please CLICK HERE to see what I have planned. then you will be able to understand the question. =D ... I want to make it simple to understand, don't want to make any body think toomuch. I feel bad.
I want to execute the QUERY below, by clicking on button1, and displaying result on Result Window. (I havent found out which result window would be more propper... DataGrid?)
-------------
USE [account];
GO
select * from user_profile where login_flag = 1100
----- OR -----
USE [cash];
UPDATE user_cash
SET amount=0
WHERE amount=294765
-------------
I want to, for example, click on BUTTON1 and execute the above query, and then show the results of the query in the RESULT window...
This is what is going on:
I have a SQL 2000 database, and I want that software to be able to:
Connect to my database thru IP, execute ANY queries and display results in RESULT WINDOW.
... I don't know, If i learn that, I think that would make me understand everything else easyer. I have no idea what I am doing, all I know how to do is ,
Click on NEW,PROJECT,C++ Form Application. ><'' ... I wasnt able to go farther.
Loading
enamur rashidPosted Nov 9, 2009, 6:46 AM
private void button1_Click(object sender, EventArgs e)
{
string connect = "write your database connection string here";
SqlConnection scn = new SqlConnection(connect);
SqlCommand sqlCmd = new SqlCommand("select * from user_profile where login_flag = 1100", scn);
sqlCmd.CommandType = System.Data.CommandType.Text;
sqlCmd.Connection.Open();
SqlDataAdapter sqlDA = new SqlDataAdapter(sqlCmd);
DataSet DS=new DataSet();
sqlDA.Fill(DS);
sqlCmd.Connection.Close();
//Data grid view to display the result
dataGridView1.DataSource = DS;
}
jingePosted Sep 27, 2009, 10:03 PM
Here's a related thread which contains C# code on how to call store procedure in the database.