Autor Beitrag
Epikur
Hält's aus hier
Beiträge: 3



BeitragVerfasst: Di 22.12.09 23:49 
Hallo zusammen

erhalte bei Debugen keinen Fehler
daten werden ganz normal ausgelesen .

Nur meine Datenbank verbindung wird igrenwie ignoriert
kann mit einer weiterhelfen




ausblenden volle Höhe C#-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
117:
118:
119:
120:
121:
122:
123:
// Print the fill information to the screen.
            fillTextBox.Text += (string)fillData.GetValue(0) + ",  ";
            fillTextBox.Text += (string)fillData.GetValue(1) + ",  ";
            fillTextBox.Text += Convert.ToString(fillData.GetValue(2)) + ",  ";
            fillTextBox.Text += (string)fillData.GetValue(3) + ",  ";
            fillTextBox.Text += (string)fillData.GetValue(4) + ",  ";
            fillTextBox.Text += (string)fillData.GetValue(5) + "\r\n";

            string contract = (string)fillData.GetValue(0);
            double price = Convert.ToDouble(fillData.GetValue(1));
            int qty = Convert.ToInt32(fillData.GetValue(2));
            string BuySell = (string)fillData.GetValue(3);
            int OrderNo = Convert.ToInt32(fillData.GetValue(4));
            string Exchange = (string)fillData.GetValue(5);


            //Anderungen von Andre

            string Server = @"localhost";
            string Username = "RTG1";
            string Password = "yaqwsx";
            string Database = "test2";

            string ConnectionString = "Data Source=" + Server + ";";
            ConnectionString += "User ID=" + Username + ";";
            ConnectionString += "Password=" + Password + ";";
            ConnectionString += "Initial Catalog=" + Database;

            SqlConnection con = new SqlConnection(ConnectionString);
            SqlCommand cmd = new SqlCommand("insert into dbo.fills (contract, price, qty, BuySell, OrderNo, Exchange ) VALUES ('" + contract + "', " + price + ", " + qty + ", '" + BuySell + "', " + OrderNo + ", '" + Exchange + "')", con);

            con.Open();
            SqlDataReader dr = cmd.ExecuteReader();

            while (dr.Read())
            {
                al.Add(dr);
            }

            con.Close();
            con.Dispose();


            //al = Con2db("insert into dbo.testfill (contract, price, qty, BuySell, OrderNo, Exchange ) VALUES ('" +contract +"', "+ price +", "+ qty +", '"+ BuySell+ "', "+ OrderNo +", '"+ Exchange +"'");

            Application.DoEvents();
        }


        public ArrayList Con2db(string sql_statement)
        {
            ArrayList al = new ArrayList();

            #region Building the connection string
            string Server = @"localhost";
            string Username = "RTG1";
            string Password = "yaqwsx";
            string Database = "test2";

            string ConnectionString = "Data Source=" + Server + ";";
            ConnectionString += "User ID=" + Username + ";";
            ConnectionString += "Password=" + Password + ";";
            ConnectionString += "Initial Catalog=" + Database;
            #endregion

            SqlConnection con = new SqlConnection(ConnectionString);
            SqlCommand cmd = new SqlCommand(sql_statement, con);

            con.Open();
            SqlDataReader dr = cmd.ExecuteReader();

            while (dr.Read())
            {
                al.Add(dr);
            }

            con.Close();
            con.Dispose();

            return al;
        }

        /// <summary>
        /// This function is called when a set of fills
        /// is about to be sent.  
        /// </summary>
        private void m_TTOrderSet_OnOrderFillBlockStart()
        {
            // Update the text box.
            fillTextBox.Text += "FillBlockStart\r\n";

            Application.DoEvents();
        }

        /// <summary>
        /// This function is called when a set of fills
        /// has been sent. 
        /// </summary>
        private void m_TTOrderSet_OnOrderFillBlockEnd()
        {
            // Update the text box.
            fillTextBox.Text += "FillBlockEnd\r\n";

            Application.DoEvents();
        }

        /// <summary>
        /// Display the About dialog box.
        /// </summary>
        /// <param name="sender">Object which fires the method</param>
        /// <param name="e">Event arguments of the callback</param>
        private void AboutMenuItem_Click(object sender, System.EventArgs e)
        {
            About aboutForm = new About();
            aboutForm.ShowDialog(this);
        }

        private void Form1_Load(object sender, EventArgs e)
        {

        }
    }
}


Moderiert von user profile iconKha: C#-Tags hinzugefügt
Kha
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 3803
Erhaltene Danke: 176

Arch Linux
Python, C, C++ (vim)
BeitragVerfasst: Mi 23.12.09 00:45 
user profile iconEpikur hat folgendes geschrieben Zum zitierten Posting springen:
Nur meine Datenbank verbindung wird igrenwie ignoriert
Heißt im Klartext? Was wo funktioniert nicht?

_________________
>λ=
Epikur Threadstarter
Hält's aus hier
Beiträge: 3



BeitragVerfasst: Mi 23.12.09 01:29 
in meine Daten bank sollte diese Daten implemtiert werden


Window Forms im Debug modus

Contract, Price, Qty, BuySell, OrderNo, Exchange

FillBlockStart
FillBlockEnd
FillBlockStart
FGBL MAR10, 122.36, 1, B, 1767285, TTSIM-D
FDAX MAR10, 5960.0, 1, B, 1771996, TTSIM-D
FDAX MAR10, 5962.0, 1, S, 1772307, TTSIM-D



Hier sollte die werte reingelesen werden
SQLDaten bank

contract price qty BuySell OrderNo Exchange

NULL NULL NULL NULL NULL Null


contract nvarchar(50) Checked
price float Checked
qty int Checked
BuySell nvarchar(50) Checked
OrderNo varchar(50) Checked
Exchange nvarchar(50) Checked
Unchecked
JüTho
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2021
Erhaltene Danke: 6

Win XP Prof
C# 2.0 (#D für NET 2.0, dazu Firebird); früher Delphi 5 und Delphi 2005 Pro
BeitragVerfasst: Mi 23.12.09 10:15 
Hä? Dein Code geht durcheinander wie Kraut und Rüben. Wozu ist FillData da? Wo und wie wird es deklariert? Innerhalb welcher Methode steckt der erste Teil mit der SqlConnection? Wozu gibt es hier zwei verschiedene Methoden mit SqlConnection? Hat das aboutForm irgendeine Bedeutung für das Problem? Was sollen die Angaben im zweiten Beitrag bedeuten? Der letzte Teil ist wohl die Tabellenstruktur, aber das andere?

Vorschlag: Reduziere das Ganze auf eine Methode (den ConnectionString darfst du fest als quasi-Konstante im Formular definieren und überall darauf zugreifen) und mach erstmal einen einfachen SELECT-Befehl, damit du siehst, ob die Verbindung steht und funktioniert.

Dann geht es schrittweise weiter. Beim jedem SQL-Befehl solltest du unbedingt mit Parametern arbeiten, Begründung und Erläuterung siehe [Artikelserie] Parameter von SQL Befehlen . (Das wird hier wohl nicht der Grund für Probleme sein, es führt aber mit Sicherheit eher früher als später zu neuen Schwierigkeiten.)

Gruß Jürgen