I got like seven errors...They are saying Invalid token '(' in class
and my '=' sign is flagging an error too..... any help down to earth VB programmer trying to live in a C# world......![]()
class
getdata{
FbConnection connect =
new FbConnection("User=SYSDBA;Password=masterkey;Database=localhost:C:\\APPOINTMENTSPRO.GDB"); string str = "SELECT last_name,first_name,middle_name,address_1, address_2,city,state,zip_code,phone_1,phone_2,birth_date,client_id_1,sex,client_id_2 FROM CLIENTS WHERE record_id = '" + client_id + "'";FbCommand cmd =
new FbCommand(str, connect);FbDataReader fbread =
new FbDataReader();connect.Open();
fbread = cmd.ExecuteReader();
if(fbread.read());{
txt.Text = "Connected";
}
else
{
txt.text = "Not connected";
}
};

what am i missing
Ron Rice
Here is the entire application...I know C# is more sensitive than a new born baby.....But i need to dive right in though.....What seems to be causing me errors...Is my code even structured right or do i need to move it before the windows generated code
using
System;using
System.Drawing;using
System.Collections;using
System.ComponentModel;using
System.Windows.Forms;using
FirebirdSql.Data.Firebird;using
System.Xml;namespace
XMLReader{
/// <summary> /// Summary description for Form1. /// </summary> public class Form1 : System.Windows.Forms.Form{
private System.Windows.Forms.Button btn; private System.Windows.Forms.TextBox txt; /// <summary> /// Required designer variable. /// </summary> private System.ComponentModel.Container components = null; public Form1(){
// // Required for Windows Form Designer support //InitializeComponent();
// // TODO: Add any constructor code after InitializeComponent call //}
/// <summary> /// Clean up any resources being used. /// </summary> protected override void Dispose( bool disposing ){
if( disposing ){
if (components != null){
components.Dispose();
}
}
base.Dispose( disposing );}
#region
Windows Form Designer generated code /// <summary> /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// </summary> private void InitializeComponent(){
this.btn = new System.Windows.Forms.Button(); this.txt = new System.Windows.Forms.TextBox(); this.SuspendLayout(); // // btn // this.btn.Location = new System.Drawing.Point(48, 216); this.btn.Name = "btn"; this.btn.TabIndex = 0; this.btn.Text = "Read Data"; this.btn.Click += new System.EventHandler(this.btn_Click); // // txt // this.txt.Location = new System.Drawing.Point(64, 24); this.txt.Name = "txt"; this.txt.TabIndex = 1; this.txt.Text = ""; // // Form1 // this.AutoScaleBaseSize = new System.Drawing.Size(5, 13); this.ClientSize = new System.Drawing.Size(568, 266); this.Controls.Add(this.txt); this.Controls.Add(this.btn); this.Name = "Form1"; this.Text = "Form1"; this.ResumeLayout(false);}
#endregion
/// <summary> /// The main entry point for the application. /// </summary>[STAThread]
static void Main(){
Application.Run(
new Form1());}
private void btn_Click(object sender, System.EventArgs e){
}
}
}
class
getdata{
FbConnection connect =
new FbConnection("User=SYSDBA;Password=masterkey;Database=localhost:C:\\APPOINTMENTSPRO.GDB"); string str = "SELECT last_name,first_name,middle_name,address_1, address_2,city,state,zip_code,phone_1,phone_2,birth_date,client_id_1,sex,client_id_2 FROM CLIENTS WHERE record_id = '" + client_id + "'";FbCommand cmd =
new FbCommand(str, connect);FbDataReader fbread =
new FbDataReader();connect.Open();
fbread = cmd.ExecuteReader();
if(fbread.read()){
txt.Text = "Connected";
}
else
{
txt.text = "Not connected";
}
};
Michael Sun
What instantly hit my eye is the semicolon at the end of this line:
if(fbread.read()); -- that seems to be pretty wrong there ;)
Also if the string is broken over several lines (cant tell from the post here) put an "@" sign in front of it.
Aj - Malta
You don't need a semicolon except at the end of a command, so the one at the very end outside the brace should go. I didn't see where you instantiated and used your class "getdata".
Also, the string you're building can be done like this:
string str = "SELECT last_name,first_name,middle_name,address_1, address_2,city,state,zip_code,phone_1,phone_2,birth_date,client_id_1,sex,client_id_2 FROM CLIENTS WHERE record_id = " + client_id.ToString();
I don't know if firebird requires the final double quote mark be included in the string. If it does, then add this before the semicolon
+ "\""