Click here to Skip to main content
15,892,059 members
Home / Discussions / C#
   

C#

 
GeneralRe: XML errors when reading in C# Pin
bigove21-Sep-06 0:33
bigove21-Sep-06 0:33 
GeneralRe: XML errors when reading in C# Pin
Christian Graus21-Sep-06 0:37
protectorChristian Graus21-Sep-06 0:37 
GeneralRe: XML errors when reading in C# Pin
bigove21-Sep-06 0:42
bigove21-Sep-06 0:42 
GeneralRe: XML errors when reading in C# Pin
bigove21-Sep-06 0:52
bigove21-Sep-06 0:52 
Questionprogress bar Pin
Parshant Verma20-Sep-06 21:53
Parshant Verma20-Sep-06 21:53 
AnswerRe: progress bar Pin
Christian Graus20-Sep-06 21:55
protectorChristian Graus20-Sep-06 21:55 
AnswerRe: progress bar Pin
Waqas Nasir20-Sep-06 22:06
Waqas Nasir20-Sep-06 22:06 
QuestiontoolStripProgressBar & SQL [modified] Pin
shopi3020-Sep-06 21:50
shopi3020-Sep-06 21:50 
Hello everybody.

Someone know how show on toolStripProgressBar the progress at retrive data from SQL Query?

Example:

SQL Structure:
CREATE TABLE [student](<br />
    [student_id] INT NOT NULL IDENTITY(1,1),<br />
    [student_name] VARCHAR(50) NOT NULL,<br />
    [student_lastname] VARCHAR(70) NOT NULL,<br />
    [student_age] TINYINT NOT NULL,<br />
    [student_since] SMALLDATETIME NOT NULL DEFAULT GETDATE(),<br />
    [student_grade] TINYINT NOT NULL,<br />
    [student_active] BIT NOT NULL DEFAULT 1,<br />
    PRIMARY KEY( [student_data_id] )<br />
)


CREATE TABLE [class](<br />
    [class_id] SMALLINT NOT NULL IDENTITY(1,1),<br />
    [class_name] VARCHAR(50) NOT NULL,<br />
    [class_acive] BIT NOT NULL DEFAULT 1,<br />
    PRIMARY KEY( [class_id] )<br />
)


CREATE TABLE [class_by_student](<br />
    [class_id] REFERENCES [class] ( [class_id] ),<br />
    [student_id] REFERENCES [student]( [student_id] ),<br />
    PRIMARY KEY( [class_id], [student_id] )<br />
)<br />


C# Code:
<br />
using System;<br />
using System.Data;<br />
using System.Data.SqlClient;<br />
using System.Windows.Forms;<br />
using System.Thread;<br />
<br />
public class Form1 : Form<br />
{<br />
    private System.ComponentModel.IContainer components = null;<br />
    private StatusStrip sb;<br />
    private ToolStripProgressBar pb;<br />
    DataGridView dg;<br />
    Thread Thread4LoadData;<br />
<br />
    public Form1()<br />
    {<br />
        this.makeForm();<br />
    }<br />
<br />
    public makeForm()<br />
    {<br />
        this.sb = new StatusStrip();<br />
        this.pb = new ToolStripProgressBar();<br />
        this.dg = new DataGridView();<br />
        ((System.ComponentModel.ISupportInitialize)(this.dg)).BeginInit();<br />
        this.sb.SuspendLayout();<br />
        this.SuspendLayout();<br />
<br />
        //status bar<br />
        this.sb.Items.Add(this.pb);<br />
        this.sb.Name = "sb";<br />
<br />
        //progress bar<br />
        this.pb.Name = "pb";<br />
        this.pb.Size = new System.Drawing.Size(100, 16);<br />
<br />
        //DataGridView<br />
        this.dg.Location = new System.Drawing.Point(12, 42);<br />
        this.dg.Name = "dg";<br />
        this.dg.Size = new System.Drawing.Size(464, 374);<br />
<br />
        //Form1<br />
        this.Controls.Add(this.sb);<br />
        this.dg.Add(this.dg);<br />
        ((System.ComponentModel.ISupportInitialize)(this.dg)).EndInit();<br />
        this.Name = "Form1";<br />
        this.Text = "Staudents";<br />
        this.Load += new System.EventHandler(this.Form1_Load);<br />
        this.sb.ResumeLayout();<br />
        this.sb.PerformLayout();<br />
        this.ResumeLayout(false);<br />
        this.PerformLayout();<br />
    }<br />
<br />
    private void Form1_Load()<br />
    {<br />
        Thread4LoadData = new Thread( new ThreadStart( this.LoadData ) );<br />
        Thread4LoadData.Start();<br />
    }<br />
<br />
    private void LoadData()<br />
    {<br />
        string connStr = "server=myserver.com.;database=school;uid=sa;password=666;Trusted_Connection=False;";<br />
        SqlConnection conn = new SqlConnection(connStr);<br />
        conn.open();<br />
<br />
        string SQL;<br />
        SQL="SELECT * " + <br />
            "FROM [class_by_student] AS [cs]" +<br />
            "JOIN [class] AS [c] ON [c].[class_id] = [cs].[class_id]" +<br />
            "JOIN [student] AS [s] ON [s].[student_id] = [cs].[student_id]" +<br />
            "WHERE [s].[student_active] = 1 " +<br />
            "AND [c].[class_active] = 1" +<br />
            "ORDER BY [S].[student_name]";<br />
<br />
        DataSet dts = new DataSet();<br />
<br />
        SqlDataAdapter da = new SqlDataAdapter( SQL, conn );<br />
        da.Fill(dts, "schools");<br />
        this.dg.DataSource = dts;<br />
        this.dg.DataMember = "schools";<br />
        conn.close();<br />
    }<br />
}<br />


I need show the progress when data is downloading because sometimes the time is longer.

SINCERELY.
ANTHONY ACUÑA

PREFERED PHRASE:
SOMEBODY TELL ME WHY IS MORE REAL WHEN I DREAM THAT I AM WAKE?

AnswerRe: toolStripProgressBar &amp; SQL Pin
Christian Graus20-Sep-06 21:57
protectorChristian Graus20-Sep-06 21:57 
Questionhow to check if a string is a letter or a number Pin
faladrim20-Sep-06 21:45
faladrim20-Sep-06 21:45 
AnswerRe: how to check if a string is a letter or a number Pin
Christian Graus20-Sep-06 21:54
protectorChristian Graus20-Sep-06 21:54 
AnswerRe: how to check if a string is a letter or a number Pin
Guffa20-Sep-06 21:54
Guffa20-Sep-06 21:54 
GeneralRe: how to check if a string is a letter or a number Pin
faladrim20-Sep-06 22:59
faladrim20-Sep-06 22:59 
AnswerRe: how to check if a string is a letter or a number Pin
Guffa21-Sep-06 6:22
Guffa21-Sep-06 6:22 
QuestionStopping &quot;Closing Form&quot; in MDI Child when background worker is busy Pin
Nadia Monalisa20-Sep-06 21:25
Nadia Monalisa20-Sep-06 21:25 
QuestionListView Binding Pin
aruna_koride20-Sep-06 21:18
aruna_koride20-Sep-06 21:18 
Questionhow to display checkbox in listbox Pin
Parshant Verma20-Sep-06 21:15
Parshant Verma20-Sep-06 21:15 
AnswerRe: how to display checkbox in listbox Pin
freshonlineMax20-Sep-06 23:05
freshonlineMax20-Sep-06 23:05 
GeneralRe: how to display checkbox in listbox Pin
CM Makwana18-Feb-09 4:56
CM Makwana18-Feb-09 4:56 
QuestionOracleClient Connection String Pin
M Riaz Bashir20-Sep-06 21:01
M Riaz Bashir20-Sep-06 21:01 
AnswerRe: OracleClient Connection String Pin
Robert Rohde20-Sep-06 21:02
Robert Rohde20-Sep-06 21:02 
Questionhi everybody! Pin
e-laj20-Sep-06 20:52
e-laj20-Sep-06 20:52 
AnswerRe: hi everybody! Pin
Christian Graus20-Sep-06 21:34
protectorChristian Graus20-Sep-06 21:34 
GeneralRe: hi everybody! Pin
Rob Manderson19-Jul-08 23:47
protectorRob Manderson19-Jul-08 23:47 
AnswerRe: hi everybody! Pin
Guffa20-Sep-06 21:50
Guffa20-Sep-06 21:50 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.