Click here to Skip to main content
15,888,579 members
Home / Discussions / Database
   

Database

 
AnswerRe: how to remove all sql server componet ? Pin
EliottA27-May-09 6:07
EliottA27-May-09 6:07 
AnswerRe: how to remove all sql server componet ? Pin
EliottA27-May-09 7:30
EliottA27-May-09 7:30 
GeneralRe: how to remove all sql server componet ? Pin
xingselex29-May-09 6:34
xingselex29-May-09 6:34 
GeneralRe: how to remove all sql server componet ? Pin
Henry Minute29-May-09 6:51
Henry Minute29-May-09 6:51 
GeneralRe: how to remove all sql server componet ? Pin
xingselex30-May-09 5:45
xingselex30-May-09 5:45 
Question"Unable to access first record" Pin
S.M.kanerkar27-May-09 2:02
S.M.kanerkar27-May-09 2:02 
GeneralRe: "Unable to access first record" Pin
Kschuler27-May-09 10:45
Kschuler27-May-09 10:45 
QuestionExecuteQuery and ExecuteReader Pin
yueru26-May-09 16:22
yueru26-May-09 16:22 
I don't know why when I use select with ExecuteQuery my result will have repeated the lastes line.
And my friend adviced me that I should use ExecuteReader now it's work
What's the different ???

here is my code !!


public void Add()
        {
            if (File.Exists("" + info + ".db"))
            {
                sql_con = new SQLiteConnection("Data Source= " + info + ".db;Version=3;New=False;Compress=True;");
                sql_con.Open();
                sql_cmd = sql_con.CreateCommand();
                sql_cmd.CommandText = "drop table par ;";
                sql_cmd.ExecuteNonQuery();
            }
            else
            {
                sql_con = new SQLiteConnection("Data Source= " + info + ".db;Version=3;New=True;Compress=True;");
                sql_con.Open();
                sql_cmd = sql_con.CreateCommand();
            }
            sql_cmd.CommandText = "create table par (Date nvarchar(20), Time nvarchar(10), Linein NVARCHAR(20), Lineout NVARCHAR(20), Number NVARCHAR(20), Status nvarchar(10),Duration int(20), Cost nvarchar(20), Detail nvarchar(10), Network nvarchar(10));";
            sql_cmd.ExecuteNonQuery();
            StreamReader reader = new StreamReader(inputfilename);
            string line = reader.ReadLine();
            while (line != null)
            {
                string NNDuration = line.Replace("'", "''");
                string Date = line.Substring(12, 8);
                if (line[11] == '=')
                {
                    string Time = line.Substring(21, 5);
                    string Linein = line.Substring(27, 10);
                    string Lineout = line.Substring(38, 1);
                    if (string.Compare(Lineout, "0") >= 0 && string.Compare(Lineout, "9") <= 0)
                    {
                        string Number = line.Substring(40, 20);
                        string Status = line.Substring(61, 3);
                        string NDuration = NNDuration.Substring(65, 10);
                        string b = NDuration.Substring(2, 2);
                        string c = NDuration.Substring(6, 2);
                        int y = Convert.ToInt32(b);
                        int l = Convert.ToInt32(c);
                        int Duration = y + l;
                        string OCost = line.Substring(73, 5);
                        string Cost = OCost.Trim();
                        string Detail = line.Substring(79, 3);
                        string Network = line.Substring(82, 8);
                        sql_cmd.CommandText = "insert into par values('" + Date + "','" + Time + "','" + Linein + "','" + Lineout + "','" + Number + "','" + Status + "','" + Duration + "','" + Cost + "','" + Detail + "','" + Network + "');";
                        sql_cmd.ExecuteNonQuery();
                      
                        textBox14.Text = textBox14.Text + "\r\n" + Date + " ";
                    }
                    else
                    {
                        textBox5.Text = textBox5.Text + "\r\n" + line;
                    }
                }
                else
                {
                    textBox5.Text = textBox5.Text + "\r\n" + line;
                }
               line = reader.ReadLine();
            }
           
        }
private void LoadData()
        {
            string CommandText = "select * from par "; //กำหนดชุดคำสั่ง
            sql_cmd.ExecuteReader();
            DB = new SQLiteDataAdapter(CommandText, sql_con); //ใช้ตัวจัดการข้อมูลช่วยนำข้อมูลออกมา
            DS.Reset(); //หา dataset มีข้อมูลอยู่ก็ให้ reset ก่อนทุกครั้ง
            DB.Fill(DS); //นำข้อมูลจากการใช้ตัวจัดการข้อมูลดึงข้อมูลได้มา นำไปใส่ใน Dataset
            DT = DS.Tables[0]; //ดึงข้อมูลเป็นตารางออกมาใส่ไว้ใน datatable
            dataGridView1.DataSource = DT; //นำข้อมูล datatable เข้าไปใส่ให้กับ dataGridViews
            sql_con.Close();
          
        }

AnswerRe: ExecuteQuery and ExecuteReader Pin
Satish Pai27-May-09 20:33
Satish Pai27-May-09 20:33 
AnswerRe: ExecuteQuery and ExecuteReader Pin
saanj28-May-09 3:08
saanj28-May-09 3:08 
Questionwhy i cannot login to my sql server 2005? Pin
xingselex26-May-09 5:37
xingselex26-May-09 5:37 
AnswerRe: why i cannot login to my sql server 2005? Pin
Eddy Vluggen26-May-09 6:19
professionalEddy Vluggen26-May-09 6:19 
QuestionWrapping VOIP traffic Pin
B060611526-May-09 0:42
B060611526-May-09 0:42 
AnswerRe: Wrapping VOIP traffic Pin
Eddy Vluggen26-May-09 20:51
professionalEddy Vluggen26-May-09 20:51 
Questionimporting data from access table in a sql server table Pin
laziale25-May-09 23:25
laziale25-May-09 23:25 
AnswerRe: importing data from access table in a sql server table Pin
Giorgi Dalakishvili25-May-09 23:57
mentorGiorgi Dalakishvili25-May-09 23:57 
Questioninsert into multiple server table in one transaction Pin
Abdul Rahman Hamidy25-May-09 17:52
Abdul Rahman Hamidy25-May-09 17:52 
AnswerRe: insert into multiple server table in one transaction Pin
ScottM126-May-09 3:11
ScottM126-May-09 3:11 
GeneralRe: insert into multiple server table in one transaction Pin
Abdul Rahman Hamidy26-May-09 19:57
Abdul Rahman Hamidy26-May-09 19:57 
AnswerRe: insert into multiple server table in one transaction Pin
Eddy Vluggen26-May-09 20:47
professionalEddy Vluggen26-May-09 20:47 
Questionhow to connect from Ms.Access to Sql server ? Pin
xingselex25-May-09 4:45
xingselex25-May-09 4:45 
AnswerRe: how to connect from Ms.Access to Sql server ? Pin
Eddy Vluggen25-May-09 6:41
professionalEddy Vluggen25-May-09 6:41 
QuestionAssigning values in an array... Pin
new_phoenix25-May-09 3:55
new_phoenix25-May-09 3:55 
AnswerRe: Assigning values in an array... Pin
riced25-May-09 7:03
riced25-May-09 7:03 
QuestionArticle Status Pin
specialdreamsin25-May-09 2:27
specialdreamsin25-May-09 2:27 

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.