Cannot find out missing brace error }

T

Toren Valone

Was editing code, am getting the following errors
} expected
Type or namespace definition, or end-of-file expected
Eyes crossed cannot find code below!

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Net;
using System.Net.Sockets;
using System.IO;
using System.Xml;
using System.Xml.XPath;


namespace File_Generation_System
{

public partial class transfer : Form
{
public string nextLine;
public string cardNumber;
public string licenseNumber;
public string oLicenseNumber = null;
public StreamReader sr;
public XmlDataDocument doc;
public string oldplate;
public XmlElement newVrRecord;
public XmlElement newInquiryData;

public transfer()
{
InitializeComponent();
}

private void exitTransferScreenToolStripMenuItem_Click(object
sender, EventArgs e)
{
this.Close();
}

private void transfer_Load(object sender, EventArgs e)
{
//TcpClient tcpclient = new TcpClient("mvs.teale.ca.gov",
Int32.Parse("21"));
//NetworkStream ns = tcpclient.GetStream();
//FileStream fs = File.Open("form1.cs", FileMode.Open);

//int data = fs.ReadByte();
//while (data != -1)
//{
// ns.WriteByte((byte)data);
// data = fs.ReadByte();
//}
//fs.Close();
//ns.Close();
//tcpclient.Close();
}

private void vRInquiriesToolStripMenuItem1_Click(object sender,
EventArgs e)
{

//Create Dataset
DataSet ds = new DataSet();

//Read XML document into dataset
ds.ReadXml("vrdatabase.xml");

foreach (DataColumn col in ds.Tables["inquiry_data"].Columns)
{
MessageBox.Show("columnname=" + col.ColumnName );
}

//This allows for editing
ds.EnforceConstraints = false;

//Create new XML document
doc = new XmlDataDocument(ds);

//Create a nodelist with just Licenses
XmlNodeList nodeLst =
doc.SelectNodes("//vrdatabase/vr_record/inquiry_data/license_number");

//Create new vr_record tag
//newVrRecord = doc.CreateElement("vr_record");

//Create inquiry_data child element
// XmlElement newInquiryData = doc.CreateElement("inquiry_data");
//newVrRecord.AppendChild(newInquiryData);

int nodeTotal = nodeLst.Count;

MessageBox.Show("node total=" + nodeTotal);


//Create Strean reader eventually point to real file
FileStream fileStream = new
FileStream("vrinqout.txt",FileMode.Open,FileAccess.Read);
sr = new StreamReader(fileStream);



//Declare a counter
int totalRecords = 0;

//create the declaration if not created do this on first run or
whenever file
// does not exist
//XmlDeclaration xmldecl = doc.CreateXmlDeclaration("1.0", null,
null);



while ((nextLine = sr.ReadLine()) != null)
{

cardNumber = nextLine.Substring(nextLine.Length - 1, 1);
licenseNumber = nextLine.Substring(0, 7);


if (cardNumber == "1")
{
newVrRecord = doc.CreateElement("vr_record");
newInquiryData = doc.CreateElement("inquiry_data");
newVrRecord.AppendChild(newInquiryData);

XmlElement newLicenseNumber =
doc.CreateElement("license_number");
newLicenseNumber.InnerText = nextLine.Substring(0,7);
newInquiryData.AppendChild(newLicenseNumber);

//Insert call to section to walk thru loaded dataset
to see if
//license number exists.

//updateXmlDatabase(newLicenseNumber.ToString());

}
if (cardNumber == "2")
{

XmlElement regExpireDate =
doc.CreateElement("reg_expire_date");
regExpireDate.InnerText = nextLine.Substring(8, 6);
newInquiryData.AppendChild(regExpireDate);

XmlElement yearModel =
doc.CreateElement("year_model");
yearModel.InnerText = nextLine.Substring(15, 2);
newInquiryData.AppendChild(yearModel);

XmlElement make = doc.CreateElement("make");
make.InnerText = nextLine.Substring(18, 5);
newInquiryData.AppendChild(make);

XmlElement vin = doc.CreateElement("vin");
vin.InnerText = nextLine.Substring(24, 30);
newInquiryData.AppendChild(vin);

XmlElement roCity = doc.CreateElement("ro_city");
roCity.InnerText = nextLine.Substring(55, 13);
newInquiryData.AppendChild(roCity);

XmlElement roZip = doc.CreateElement("ro_zip");
roZip.InnerText = nextLine.Substring(69, 5);
newInquiryData.AppendChild(roZip);

XmlElement roCountyCode =
doc.CreateElement("ro_county_code");
roCountyCode.InnerText = nextLine.Substring(75, 2);
newInquiryData.AppendChild(roCountyCode);
}
if (cardNumber == "3")
{
XmlElement paperIssueDate =
doc.CreateElement("paper_issue_date");
paperIssueDate.InnerText = nextLine.Substring(8, 6);
newInquiryData.AppendChild(paperIssueDate);

XmlElement roNameAndAddressSourceIndicator =
doc.CreateElement("ro_nameaddress_source_indicator");
roNameAndAddressSourceIndicator.InnerText =
nextLine.Substring(14, 1);

newInquiryData.AppendChild(roNameAndAddressSourceIndicator);

XmlElement roName = doc.CreateElement("ro_name");
roName.InnerText = nextLine.Substring(15, 30);
newInquiryData.AppendChild(roName);

XmlElement roNameOrAddress =
doc.CreateElement("ro_name_or_address");
roNameOrAddress.InnerText = nextLine.Substring(46,
30);
newInquiryData.AppendChild(roNameOrAddress);
}
if (cardNumber == "4")
{
XmlElement additionalRoNameOrAddress =
doc.CreateElement("additional_ro_name_or_address");
additionalRoNameOrAddress.InnerText =
nextLine.Substring(8, 30);
newInquiryData.AppendChild(additionalRoNameOrAddress);

XmlElement additionalRoAddress =
doc.CreateElement("additional_ro_address");
additionalRoAddress.InnerText =
nextLine.Substring(31, 30);
newInquiryData.AppendChild(additionalRoAddress);

}
if (cardNumber == "5")
{
XmlElement recordConditionCode =
doc.CreateElement("record_condition_code");
recordConditionCode.InnerText =
nextLine.Substring(8, 2);
newInquiryData.AppendChild(recordConditionCode);

XmlElement recordConditionCodeDate =
doc.CreateElement("record_condition_code_date");
recordConditionCodeDate.InnerText =
nextLine.Substring(11, 6);
newInquiryData.AppendChild(recordConditionCodeDate);

XmlElement recordRemarks =
doc.CreateElement("record_remarks");
recordRemarks.InnerText = nextLine.Substring(18, 30);
newInquiryData.AppendChild(recordRemarks);
}

if (cardNumber == "6")
{
XmlElement errorCode =
doc.CreateElement("error_code");
errorCode.InnerText = nextLine.Substring(8, 2);
newInquiryData.AppendChild(errorCode);

XmlElement errorMessage =
doc.CreateElement("error_message");
errorMessage.InnerText = nextLine.Substring(13, 45);
newInquiryData.AppendChild(errorMessage);

XmlElement errorDate =
doc.CreateElement("error_date");
errorDate.InnerText = nextLine.Substring(59, 6);
newInquiryData.AppendChild(errorDate);
}
if (cardNumber == "7")
{
XmlElement nrlDate = doc.CreateElement("nrl_date");
nrlDate.InnerText = nextLine.Substring(13, 45);
newInquiryData.AppendChild(nrlDate);

XmlElement nrlTransferDate =
doc.CreateElement("nrl_transfer_date");
nrlTransferDate.InnerText = nextLine.Substring(13,
45);
newInquiryData.AppendChild(nrlTransferDate);

XmlElement nrlNameOrMessage =
doc.CreateElement("nrl_name_or_message");
nrlNameOrMessage.InnerText = nextLine.Substring(13,
45);
newInquiryData.AppendChild(nrlNameOrMessage);

XmlElement nrlRecordId =
doc.CreateElement("nrl_record_Id");
nrlRecordId.InnerText = nextLine.Substring(13, 45);
newInquiryData.AppendChild(nrlRecordId);

}
if (cardNumber == "8")
{
XmlElement nrlDate = doc.CreateElement("nrl_date");
nrlDate.InnerText = nextLine.Substring(13, 45);
newInquiryData.AppendChild(nrlDate);

XmlElement nrlTransferDate =
doc.CreateElement("nrl_transfer_date");
nrlTransferDate.InnerText = nextLine.Substring(13,
45);
newInquiryData.AppendChild(nrlTransferDate);

XmlElement nrlNameOrMessage =
doc.CreateElement("nrl_name_or_message");
nrlNameOrMessage.InnerText = nextLine.Substring(13,
45);
newInquiryData.AppendChild(nrlNameOrMessage);

XmlElement nrlRecordId =
doc.CreateElement("nrl_record_Id");
nrlRecordId.InnerText = nextLine.Substring(13, 45);
newInquiryData.AppendChild(nrlRecordId);

}



if (oldplate != licenseNumber)
{


XmlElement newCitationNumber =
doc.CreateElement("citation_number");
newCitationNumber.InnerText = null;
newInquiryData.AppendChild(newCitationNumber);

doc.DocumentElement.AppendChild(newVrRecord);

writeOutXml();
}
//when the old plate != new plate write out XML

oldplate = licenseSwitch(licenseNumber);


} //ends while

private string licenseSwitch(string newplate)
{

oldplate = newplate;

return oldplate;
}
private void writeOutXml()
{

XmlTextWriter tr = new XmlTextWriter("vrdatabase.xml", null);
tr.Formatting = Formatting.Indented;
doc.WriteContentTo(tr);
tr.Close();
}

}//ends tool strip

} //ends public partial class
} //ends namespace
 
R

Roger Frost

1. This really doesn't answer your question
2. I hate to state the obvious.
3. If I don't ask, someone else will...

Does the error not include the offending line number(s)?

I completely understand how it is to go "cross-eyed" staring at the same
code for a period of time

....I dropped it in visual c# express but the text wrapping made it even
harder to understand...but sometimes the "outlining" in visual C# can help
track down missing braces and such




Toren Valone said:
Was editing code, am getting the following errors
} expected
Type or namespace definition, or end-of-file expected
Eyes crossed cannot find code below!

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Net;
using System.Net.Sockets;
using System.IO;
using System.Xml;
using System.Xml.XPath;


namespace File_Generation_System
{

public partial class transfer : Form
{
public string nextLine;
public string cardNumber;
public string licenseNumber;
public string oLicenseNumber = null;
public StreamReader sr;
public XmlDataDocument doc;
public string oldplate;
public XmlElement newVrRecord;
public XmlElement newInquiryData;

public transfer()
{
InitializeComponent();
}

private void exitTransferScreenToolStripMenuItem_Click(object
sender, EventArgs e)
{
this.Close();
}

private void transfer_Load(object sender, EventArgs e)
{
//TcpClient tcpclient = new TcpClient("mvs.teale.ca.gov",
Int32.Parse("21"));
//NetworkStream ns = tcpclient.GetStream();
//FileStream fs = File.Open("form1.cs", FileMode.Open);

//int data = fs.ReadByte();
//while (data != -1)
//{
// ns.WriteByte((byte)data);
// data = fs.ReadByte();
//}
//fs.Close();
//ns.Close();
//tcpclient.Close();
}

private void vRInquiriesToolStripMenuItem1_Click(object sender,
EventArgs e)
{

//Create Dataset
DataSet ds = new DataSet();

//Read XML document into dataset
ds.ReadXml("vrdatabase.xml");

foreach (DataColumn col in ds.Tables["inquiry_data"].Columns)
{
MessageBox.Show("columnname=" + col.ColumnName );
}

//This allows for editing
ds.EnforceConstraints = false;

//Create new XML document
doc = new XmlDataDocument(ds);

//Create a nodelist with just Licenses
XmlNodeList nodeLst =
doc.SelectNodes("//vrdatabase/vr_record/inquiry_data/license_number");

//Create new vr_record tag
//newVrRecord = doc.CreateElement("vr_record");

//Create inquiry_data child element
// XmlElement newInquiryData =
doc.CreateElement("inquiry_data");
//newVrRecord.AppendChild(newInquiryData);

int nodeTotal = nodeLst.Count;

MessageBox.Show("node total=" + nodeTotal);


//Create Strean reader eventually point to real file
FileStream fileStream = new
FileStream("vrinqout.txt",FileMode.Open,FileAccess.Read);
sr = new StreamReader(fileStream);



//Declare a counter
int totalRecords = 0;

//create the declaration if not created do this on first run or
whenever file
// does not exist
//XmlDeclaration xmldecl = doc.CreateXmlDeclaration("1.0",
null,
null);



while ((nextLine = sr.ReadLine()) != null)
{

cardNumber = nextLine.Substring(nextLine.Length - 1, 1);
licenseNumber = nextLine.Substring(0, 7);


if (cardNumber == "1")
{
newVrRecord = doc.CreateElement("vr_record");
newInquiryData = doc.CreateElement("inquiry_data");
newVrRecord.AppendChild(newInquiryData);

XmlElement newLicenseNumber =
doc.CreateElement("license_number");
newLicenseNumber.InnerText =
nextLine.Substring(0,7);
newInquiryData.AppendChild(newLicenseNumber);

//Insert call to section to walk thru loaded
dataset
to see if
//license number exists.

//updateXmlDatabase(newLicenseNumber.ToString());

}
if (cardNumber == "2")
{

XmlElement regExpireDate =
doc.CreateElement("reg_expire_date");
regExpireDate.InnerText = nextLine.Substring(8, 6);
newInquiryData.AppendChild(regExpireDate);

XmlElement yearModel =
doc.CreateElement("year_model");
yearModel.InnerText = nextLine.Substring(15, 2);
newInquiryData.AppendChild(yearModel);

XmlElement make = doc.CreateElement("make");
make.InnerText = nextLine.Substring(18, 5);
newInquiryData.AppendChild(make);

XmlElement vin = doc.CreateElement("vin");
vin.InnerText = nextLine.Substring(24, 30);
newInquiryData.AppendChild(vin);

XmlElement roCity = doc.CreateElement("ro_city");
roCity.InnerText = nextLine.Substring(55, 13);
newInquiryData.AppendChild(roCity);

XmlElement roZip = doc.CreateElement("ro_zip");
roZip.InnerText = nextLine.Substring(69, 5);
newInquiryData.AppendChild(roZip);

XmlElement roCountyCode =
doc.CreateElement("ro_county_code");
roCountyCode.InnerText = nextLine.Substring(75, 2);
newInquiryData.AppendChild(roCountyCode);
}
if (cardNumber == "3")
{
XmlElement paperIssueDate =
doc.CreateElement("paper_issue_date");
paperIssueDate.InnerText = nextLine.Substring(8,
6);
newInquiryData.AppendChild(paperIssueDate);

XmlElement roNameAndAddressSourceIndicator =
doc.CreateElement("ro_nameaddress_source_indicator");
roNameAndAddressSourceIndicator.InnerText =
nextLine.Substring(14, 1);

newInquiryData.AppendChild(roNameAndAddressSourceIndicator);

XmlElement roName = doc.CreateElement("ro_name");
roName.InnerText = nextLine.Substring(15, 30);
newInquiryData.AppendChild(roName);

XmlElement roNameOrAddress =
doc.CreateElement("ro_name_or_address");
roNameOrAddress.InnerText = nextLine.Substring(46,
30);
newInquiryData.AppendChild(roNameOrAddress);
}
if (cardNumber == "4")
{
XmlElement additionalRoNameOrAddress =
doc.CreateElement("additional_ro_name_or_address");
additionalRoNameOrAddress.InnerText =
nextLine.Substring(8, 30);

newInquiryData.AppendChild(additionalRoNameOrAddress);

XmlElement additionalRoAddress =
doc.CreateElement("additional_ro_address");
additionalRoAddress.InnerText =
nextLine.Substring(31, 30);
newInquiryData.AppendChild(additionalRoAddress);

}
if (cardNumber == "5")
{
XmlElement recordConditionCode =
doc.CreateElement("record_condition_code");
recordConditionCode.InnerText =
nextLine.Substring(8, 2);
newInquiryData.AppendChild(recordConditionCode);

XmlElement recordConditionCodeDate =
doc.CreateElement("record_condition_code_date");
recordConditionCodeDate.InnerText =
nextLine.Substring(11, 6);

newInquiryData.AppendChild(recordConditionCodeDate);

XmlElement recordRemarks =
doc.CreateElement("record_remarks");
recordRemarks.InnerText = nextLine.Substring(18,
30);
newInquiryData.AppendChild(recordRemarks);
}

if (cardNumber == "6")
{
XmlElement errorCode =
doc.CreateElement("error_code");
errorCode.InnerText = nextLine.Substring(8, 2);
newInquiryData.AppendChild(errorCode);

XmlElement errorMessage =
doc.CreateElement("error_message");
errorMessage.InnerText = nextLine.Substring(13,
45);
newInquiryData.AppendChild(errorMessage);

XmlElement errorDate =
doc.CreateElement("error_date");
errorDate.InnerText = nextLine.Substring(59, 6);
newInquiryData.AppendChild(errorDate);
}
if (cardNumber == "7")
{
XmlElement nrlDate = doc.CreateElement("nrl_date");
nrlDate.InnerText = nextLine.Substring(13, 45);
newInquiryData.AppendChild(nrlDate);

XmlElement nrlTransferDate =
doc.CreateElement("nrl_transfer_date");
nrlTransferDate.InnerText = nextLine.Substring(13,
45);
newInquiryData.AppendChild(nrlTransferDate);

XmlElement nrlNameOrMessage =
doc.CreateElement("nrl_name_or_message");
nrlNameOrMessage.InnerText = nextLine.Substring(13,
45);
newInquiryData.AppendChild(nrlNameOrMessage);

XmlElement nrlRecordId =
doc.CreateElement("nrl_record_Id");
nrlRecordId.InnerText = nextLine.Substring(13, 45);
newInquiryData.AppendChild(nrlRecordId);

}
if (cardNumber == "8")
{
XmlElement nrlDate = doc.CreateElement("nrl_date");
nrlDate.InnerText = nextLine.Substring(13, 45);
newInquiryData.AppendChild(nrlDate);

XmlElement nrlTransferDate =
doc.CreateElement("nrl_transfer_date");
nrlTransferDate.InnerText = nextLine.Substring(13,
45);
newInquiryData.AppendChild(nrlTransferDate);

XmlElement nrlNameOrMessage =
doc.CreateElement("nrl_name_or_message");
nrlNameOrMessage.InnerText = nextLine.Substring(13,
45);
newInquiryData.AppendChild(nrlNameOrMessage);

XmlElement nrlRecordId =
doc.CreateElement("nrl_record_Id");
nrlRecordId.InnerText = nextLine.Substring(13, 45);
newInquiryData.AppendChild(nrlRecordId);

}



if (oldplate != licenseNumber)
{


XmlElement newCitationNumber =
doc.CreateElement("citation_number");
newCitationNumber.InnerText = null;
newInquiryData.AppendChild(newCitationNumber);

doc.DocumentElement.AppendChild(newVrRecord);

writeOutXml();
}
//when the old plate != new plate write out XML

oldplate = licenseSwitch(licenseNumber);


} //ends while

private string licenseSwitch(string newplate)
{

oldplate = newplate;

return oldplate;
}
private void writeOutXml()
{

XmlTextWriter tr = new XmlTextWriter("vrdatabase.xml", null);
tr.Formatting = Formatting.Indented;
doc.WriteContentTo(tr);
tr.Close();
}

}//ends tool strip

} //ends public partial class
} //ends namespace
 
C

Caio Proiete [MCT]

Hello Toren,

This was probably a simply copy-paste mistake.

The methods "licenseSwitch" and "writeOutXml" are placed *inside* the method
"vRInquiriesToolStripMenuItem1_Click"

Try to move them *below* the "}//ends tool strip", and it should be fine :)

Cheers,

Caio Proiete
www.caioproiete.com

Was editing code, am getting the following errors
} expected
Type or namespace definition, or end-of-file expected
Eyes crossed cannot find code below!
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Net;
using System.Net.Sockets;
using System.IO;
using System.Xml;
using System.Xml.XPath;
namespace File_Generation_System
{
public partial class transfer : Form
{
public string nextLine;
public string cardNumber;
public string licenseNumber;
public string oLicenseNumber = null;
public StreamReader sr;
public XmlDataDocument doc;
public string oldplate;
public XmlElement newVrRecord;
public XmlElement newInquiryData;
public transfer()
{
InitializeComponent();
}
private void exitTransferScreenToolStripMenuItem_Click(object
sender, EventArgs e)
{
this.Close();
}
private void transfer_Load(object sender, EventArgs e)
{
//TcpClient tcpclient = new TcpClient("mvs.teale.ca.gov",
Int32.Parse("21"));
//NetworkStream ns = tcpclient.GetStream();
//FileStream fs = File.Open("form1.cs", FileMode.Open);
//int data = fs.ReadByte();
//while (data != -1)
//{
// ns.WriteByte((byte)data);
// data = fs.ReadByte();
//}
//fs.Close();
//ns.Close();
//tcpclient.Close();
}
private void vRInquiriesToolStripMenuItem1_Click(object
sender,
EventArgs e)
{
//Create Dataset
DataSet ds = new DataSet();
//Read XML document into dataset
ds.ReadXml("vrdatabase.xml");
foreach (DataColumn col in
ds.Tables["inquiry_data"].Columns)
{
MessageBox.Show("columnname=" + col.ColumnName );
}
//This allows for editing
ds.EnforceConstraints = false;
//Create new XML document
doc = new XmlDataDocument(ds);
//Create a nodelist with just Licenses
XmlNodeList nodeLst =
doc.SelectNodes("//vrdatabase/vr_record/inquiry_data/license_number");
//Create new vr_record tag
//newVrRecord = doc.CreateElement("vr_record");
//Create inquiry_data child element
// XmlElement newInquiryData =
doc.CreateElement("inquiry_data");
//newVrRecord.AppendChild(newInquiryData);
int nodeTotal = nodeLst.Count;

MessageBox.Show("node total=" + nodeTotal);

//Create Strean reader eventually point to real file
FileStream fileStream = new
FileStream("vrinqout.txt",FileMode.Open,FileAccess.Read);
sr = new StreamReader(fileStream);
//Declare a counter
int totalRecords = 0;
//create the declaration if not created do this on first
run or
whenever file
// does not exist
//XmlDeclaration xmldecl = doc.CreateXmlDeclaration("1.0",
null,
null);
while ((nextLine = sr.ReadLine()) != null)
{
cardNumber = nextLine.Substring(nextLine.Length - 1,
1);
licenseNumber = nextLine.Substring(0, 7);
if (cardNumber == "1")
{
newVrRecord = doc.CreateElement("vr_record");
newInquiryData =
doc.CreateElement("inquiry_data");
newVrRecord.AppendChild(newInquiryData);
XmlElement newLicenseNumber =
doc.CreateElement("license_number");
newLicenseNumber.InnerText =
nextLine.Substring(0,7);
newInquiryData.AppendChild(newLicenseNumber);
//Insert call to section to walk thru loaded
dataset
to see if
//license number exists.

//updateXmlDatabase(newLicenseNumber.ToString());

}
if (cardNumber == "2")
{
XmlElement regExpireDate =
doc.CreateElement("reg_expire_date");
regExpireDate.InnerText =
nextLine.Substring(8, 6);
newInquiryData.AppendChild(regExpireDate);
XmlElement yearModel =
doc.CreateElement("year_model");
yearModel.InnerText = nextLine.Substring(15,
2);
newInquiryData.AppendChild(yearModel);
XmlElement make = doc.CreateElement("make");
make.InnerText = nextLine.Substring(18, 5);
newInquiryData.AppendChild(make);
XmlElement vin = doc.CreateElement("vin");
vin.InnerText = nextLine.Substring(24, 30);
newInquiryData.AppendChild(vin);
XmlElement roCity =
doc.CreateElement("ro_city");
roCity.InnerText = nextLine.Substring(55, 13);
newInquiryData.AppendChild(roCity);
XmlElement roZip =
doc.CreateElement("ro_zip");
roZip.InnerText = nextLine.Substring(69, 5);
newInquiryData.AppendChild(roZip);
XmlElement roCountyCode =
doc.CreateElement("ro_county_code");
roCountyCode.InnerText =
nextLine.Substring(75, 2);
newInquiryData.AppendChild(roCountyCode);
}
if (cardNumber == "3")
{
XmlElement paperIssueDate =
doc.CreateElement("paper_issue_date");
paperIssueDate.InnerText =
nextLine.Substring(8, 6);
newInquiryData.AppendChild(paperIssueDate);
XmlElement roNameAndAddressSourceIndicator =
doc.CreateElement("ro_nameaddress_source_indicator");
roNameAndAddressSourceIndicator.InnerText =
nextLine.Substring(14, 1);
newInquiryData.AppendChild(roNameAndAddressSourceIndicator);

XmlElement roName =
doc.CreateElement("ro_name");
roName.InnerText = nextLine.Substring(15, 30);
newInquiryData.AppendChild(roName);
XmlElement roNameOrAddress =
doc.CreateElement("ro_name_or_address");
roNameOrAddress.InnerText =
nextLine.Substring(46,
30);
newInquiryData.AppendChild(roNameOrAddress);
}
if (cardNumber == "4")
{
XmlElement additionalRoNameOrAddress =
doc.CreateElement("additional_ro_name_or_address");
additionalRoNameOrAddress.InnerText =
nextLine.Substring(8, 30);

newInquiryData.AppendChild(additionalRoNameOrAddress);
XmlElement additionalRoAddress =
doc.CreateElement("additional_ro_address");
additionalRoAddress.InnerText =
nextLine.Substring(31, 30);

newInquiryData.AppendChild(additionalRoAddress);
}
if (cardNumber == "5")
{
XmlElement recordConditionCode =
doc.CreateElement("record_condition_code");
recordConditionCode.InnerText =
nextLine.Substring(8, 2);

newInquiryData.AppendChild(recordConditionCode);
XmlElement recordConditionCodeDate =
doc.CreateElement("record_condition_code_date");
recordConditionCodeDate.InnerText =
nextLine.Substring(11, 6);

newInquiryData.AppendChild(recordConditionCodeDate);
XmlElement recordRemarks =
doc.CreateElement("record_remarks");
recordRemarks.InnerText =
nextLine.Substring(18, 30);
newInquiryData.AppendChild(recordRemarks);
}
if (cardNumber == "6")
{
XmlElement errorCode =
doc.CreateElement("error_code");
errorCode.InnerText = nextLine.Substring(8,
2);
newInquiryData.AppendChild(errorCode);
XmlElement errorMessage =
doc.CreateElement("error_message");
errorMessage.InnerText =
nextLine.Substring(13, 45);
newInquiryData.AppendChild(errorMessage);
XmlElement errorDate =
doc.CreateElement("error_date");
errorDate.InnerText = nextLine.Substring(59,
6);
newInquiryData.AppendChild(errorDate);
}
if (cardNumber == "7")
{
XmlElement nrlDate =
doc.CreateElement("nrl_date");
nrlDate.InnerText = nextLine.Substring(13,
45);
newInquiryData.AppendChild(nrlDate);
XmlElement nrlTransferDate =
doc.CreateElement("nrl_transfer_date");
nrlTransferDate.InnerText =
nextLine.Substring(13,
45);
newInquiryData.AppendChild(nrlTransferDate);
XmlElement nrlNameOrMessage =
doc.CreateElement("nrl_name_or_message");
nrlNameOrMessage.InnerText =
nextLine.Substring(13,
45);
newInquiryData.AppendChild(nrlNameOrMessage);
XmlElement nrlRecordId =
doc.CreateElement("nrl_record_Id");
nrlRecordId.InnerText = nextLine.Substring(13,
45);
newInquiryData.AppendChild(nrlRecordId);
}
if (cardNumber == "8")
{
XmlElement nrlDate =
doc.CreateElement("nrl_date");
nrlDate.InnerText = nextLine.Substring(13,
45);
newInquiryData.AppendChild(nrlDate);
XmlElement nrlTransferDate =
doc.CreateElement("nrl_transfer_date");
nrlTransferDate.InnerText =
nextLine.Substring(13,
45);
newInquiryData.AppendChild(nrlTransferDate);
XmlElement nrlNameOrMessage =
doc.CreateElement("nrl_name_or_message");
nrlNameOrMessage.InnerText =
nextLine.Substring(13,
45);
newInquiryData.AppendChild(nrlNameOrMessage);
XmlElement nrlRecordId =
doc.CreateElement("nrl_record_Id");
nrlRecordId.InnerText = nextLine.Substring(13,
45);
newInquiryData.AppendChild(nrlRecordId);
}

if (oldplate != licenseNumber)
{
XmlElement newCitationNumber =
doc.CreateElement("citation_number");
newCitationNumber.InnerText = null;
newInquiryData.AppendChild(newCitationNumber);
doc.DocumentElement.AppendChild(newVrRecord);

writeOutXml();
}
//when the old plate != new plate write out XML
oldplate = licenseSwitch(licenseNumber);

} //ends while

private string licenseSwitch(string newplate)
{
oldplate = newplate;

return oldplate;
}
private void writeOutXml()
{
XmlTextWriter tr = new XmlTextWriter("vrdatabase.xml",
null);
tr.Formatting = Formatting.Indented;
doc.WriteContentTo(tr);
tr.Close();
}
}//ends tool strip

} //ends public partial class
} //ends namespace
 
T

Toren Valone

Roger, thanks for the reply, yes the errors do include the line numbers, I
have gone thru every } to make sure it has a corresponding {. I know I fixed
these errors in the past but I cannot find this one yet.

Roger Frost said:
1. This really doesn't answer your question
2. I hate to state the obvious.
3. If I don't ask, someone else will...

Does the error not include the offending line number(s)?

I completely understand how it is to go "cross-eyed" staring at the same
code for a period of time

...I dropped it in visual c# express but the text wrapping made it even
harder to understand...but sometimes the "outlining" in visual C# can help
track down missing braces and such




Toren Valone said:
Was editing code, am getting the following errors
} expected
Type or namespace definition, or end-of-file expected
Eyes crossed cannot find code below!

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Net;
using System.Net.Sockets;
using System.IO;
using System.Xml;
using System.Xml.XPath;


namespace File_Generation_System
{

public partial class transfer : Form
{
public string nextLine;
public string cardNumber;
public string licenseNumber;
public string oLicenseNumber = null;
public StreamReader sr;
public XmlDataDocument doc;
public string oldplate;
public XmlElement newVrRecord;
public XmlElement newInquiryData;

public transfer()
{
InitializeComponent();
}

private void exitTransferScreenToolStripMenuItem_Click(object
sender, EventArgs e)
{
this.Close();
}

private void transfer_Load(object sender, EventArgs e)
{
//TcpClient tcpclient = new TcpClient("mvs.teale.ca.gov",
Int32.Parse("21"));
//NetworkStream ns = tcpclient.GetStream();
//FileStream fs = File.Open("form1.cs", FileMode.Open);

//int data = fs.ReadByte();
//while (data != -1)
//{
// ns.WriteByte((byte)data);
// data = fs.ReadByte();
//}
//fs.Close();
//ns.Close();
//tcpclient.Close();
}

private void vRInquiriesToolStripMenuItem1_Click(object sender,
EventArgs e)
{

//Create Dataset
DataSet ds = new DataSet();

//Read XML document into dataset
ds.ReadXml("vrdatabase.xml");

foreach (DataColumn col in ds.Tables["inquiry_data"].Columns)
{
MessageBox.Show("columnname=" + col.ColumnName );
}

//This allows for editing
ds.EnforceConstraints = false;

//Create new XML document
doc = new XmlDataDocument(ds);

//Create a nodelist with just Licenses
XmlNodeList nodeLst =
doc.SelectNodes("//vrdatabase/vr_record/inquiry_data/license_number");

//Create new vr_record tag
//newVrRecord = doc.CreateElement("vr_record");

//Create inquiry_data child element
// XmlElement newInquiryData =
doc.CreateElement("inquiry_data");
//newVrRecord.AppendChild(newInquiryData);

int nodeTotal = nodeLst.Count;

MessageBox.Show("node total=" + nodeTotal);


//Create Strean reader eventually point to real file
FileStream fileStream = new
FileStream("vrinqout.txt",FileMode.Open,FileAccess.Read);
sr = new StreamReader(fileStream);



//Declare a counter
int totalRecords = 0;

//create the declaration if not created do this on first run or
whenever file
// does not exist
//XmlDeclaration xmldecl = doc.CreateXmlDeclaration("1.0",
null,
null);



while ((nextLine = sr.ReadLine()) != null)
{

cardNumber = nextLine.Substring(nextLine.Length - 1, 1);
licenseNumber = nextLine.Substring(0, 7);


if (cardNumber == "1")
{
newVrRecord = doc.CreateElement("vr_record");
newInquiryData = doc.CreateElement("inquiry_data");
newVrRecord.AppendChild(newInquiryData);

XmlElement newLicenseNumber =
doc.CreateElement("license_number");
newLicenseNumber.InnerText =
nextLine.Substring(0,7);
newInquiryData.AppendChild(newLicenseNumber);

//Insert call to section to walk thru loaded
dataset
to see if
//license number exists.

//updateXmlDatabase(newLicenseNumber.ToString());

}
if (cardNumber == "2")
{

XmlElement regExpireDate =
doc.CreateElement("reg_expire_date");
regExpireDate.InnerText = nextLine.Substring(8, 6);
newInquiryData.AppendChild(regExpireDate);

XmlElement yearModel =
doc.CreateElement("year_model");
yearModel.InnerText = nextLine.Substring(15, 2);
newInquiryData.AppendChild(yearModel);

XmlElement make = doc.CreateElement("make");
make.InnerText = nextLine.Substring(18, 5);
newInquiryData.AppendChild(make);

XmlElement vin = doc.CreateElement("vin");
vin.InnerText = nextLine.Substring(24, 30);
newInquiryData.AppendChild(vin);

XmlElement roCity = doc.CreateElement("ro_city");
roCity.InnerText = nextLine.Substring(55, 13);
newInquiryData.AppendChild(roCity);

XmlElement roZip = doc.CreateElement("ro_zip");
roZip.InnerText = nextLine.Substring(69, 5);
newInquiryData.AppendChild(roZip);

XmlElement roCountyCode =
doc.CreateElement("ro_county_code");
roCountyCode.InnerText = nextLine.Substring(75, 2);
newInquiryData.AppendChild(roCountyCode);
}
if (cardNumber == "3")
{
XmlElement paperIssueDate =
doc.CreateElement("paper_issue_date");
paperIssueDate.InnerText = nextLine.Substring(8,
6);
newInquiryData.AppendChild(paperIssueDate);

XmlElement roNameAndAddressSourceIndicator =
doc.CreateElement("ro_nameaddress_source_indicator");
roNameAndAddressSourceIndicator.InnerText =
nextLine.Substring(14, 1);

newInquiryData.AppendChild(roNameAndAddressSourceIndicator);

XmlElement roName = doc.CreateElement("ro_name");
roName.InnerText = nextLine.Substring(15, 30);
newInquiryData.AppendChild(roName);

XmlElement roNameOrAddress =
doc.CreateElement("ro_name_or_address");
roNameOrAddress.InnerText = nextLine.Substring(46,
30);
newInquiryData.AppendChild(roNameOrAddress);
}
if (cardNumber == "4")
{
XmlElement additionalRoNameOrAddress =
doc.CreateElement("additional_ro_name_or_address");
additionalRoNameOrAddress.InnerText =
nextLine.Substring(8, 30);

newInquiryData.AppendChild(additionalRoNameOrAddress);

XmlElement additionalRoAddress =
doc.CreateElement("additional_ro_address");
additionalRoAddress.InnerText =
nextLine.Substring(31, 30);
newInquiryData.AppendChild(additionalRoAddress);

}
if (cardNumber == "5")
{
XmlElement recordConditionCode =
doc.CreateElement("record_condition_code");
recordConditionCode.InnerText =
nextLine.Substring(8, 2);
newInquiryData.AppendChild(recordConditionCode);

XmlElement recordConditionCodeDate =
doc.CreateElement("record_condition_code_date");
recordConditionCodeDate.InnerText =
nextLine.Substring(11, 6);

newInquiryData.AppendChild(recordConditionCodeDate);

XmlElement recordRemarks =
doc.CreateElement("record_remarks");
recordRemarks.InnerText = nextLine.Substring(18,
30);
newInquiryData.AppendChild(recordRemarks);
}

if (cardNumber == "6")
{
XmlElement errorCode =
doc.CreateElement("error_code");
errorCode.InnerText = nextLine.Substring(8, 2);
newInquiryData.AppendChild(errorCode);

XmlElement errorMessage =
doc.CreateElement("error_message");
errorMessage.InnerText = nextLine.Substring(13,
45);
newInquiryData.AppendChild(errorMessage);

XmlElement errorDate =
doc.CreateElement("error_date");
errorDate.InnerText = nextLine.Substring(59, 6);
newInquiryData.AppendChild(errorDate);
}
if (cardNumber == "7")
{
XmlElement nrlDate = doc.CreateElement("nrl_date");
nrlDate.InnerText = nextLine.Substring(13, 45);
newInquiryData.AppendChild(nrlDate);

XmlElement nrlTransferDate =
doc.CreateElement("nrl_transfer_date");
nrlTransferDate.InnerText = nextLine.Substring(13,
45);
newInquiryData.AppendChild(nrlTransferDate);

XmlElement nrlNameOrMessage =
doc.CreateElement("nrl_name_or_message");
nrlNameOrMessage.InnerText = nextLine.Substring(13,
45);
newInquiryData.AppendChild(nrlNameOrMessage);

XmlElement nrlRecordId =
doc.CreateElement("nrl_record_Id");
 
T

Toren Valone

Thanks!

Caio Proiete said:
Hello Toren,

This was probably a simply copy-paste mistake.

The methods "licenseSwitch" and "writeOutXml" are placed *inside* the method
"vRInquiriesToolStripMenuItem1_Click"

Try to move them *below* the "}//ends tool strip", and it should be fine :)

Cheers,

Caio Proiete
www.caioproiete.com

Was editing code, am getting the following errors
} expected
Type or namespace definition, or end-of-file expected
Eyes crossed cannot find code below!
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Net;
using System.Net.Sockets;
using System.IO;
using System.Xml;
using System.Xml.XPath;
namespace File_Generation_System
{
public partial class transfer : Form
{
public string nextLine;
public string cardNumber;
public string licenseNumber;
public string oLicenseNumber = null;
public StreamReader sr;
public XmlDataDocument doc;
public string oldplate;
public XmlElement newVrRecord;
public XmlElement newInquiryData;
public transfer()
{
InitializeComponent();
}
private void exitTransferScreenToolStripMenuItem_Click(object
sender, EventArgs e)
{
this.Close();
}
private void transfer_Load(object sender, EventArgs e)
{
//TcpClient tcpclient = new TcpClient("mvs.teale.ca.gov",
Int32.Parse("21"));
//NetworkStream ns = tcpclient.GetStream();
//FileStream fs = File.Open("form1.cs", FileMode.Open);
//int data = fs.ReadByte();
//while (data != -1)
//{
// ns.WriteByte((byte)data);
// data = fs.ReadByte();
//}
//fs.Close();
//ns.Close();
//tcpclient.Close();
}
private void vRInquiriesToolStripMenuItem1_Click(object
sender,
EventArgs e)
{
//Create Dataset
DataSet ds = new DataSet();
//Read XML document into dataset
ds.ReadXml("vrdatabase.xml");
foreach (DataColumn col in
ds.Tables["inquiry_data"].Columns)
{
MessageBox.Show("columnname=" + col.ColumnName );
}
//This allows for editing
ds.EnforceConstraints = false;
//Create new XML document
doc = new XmlDataDocument(ds);
//Create a nodelist with just Licenses
XmlNodeList nodeLst =
doc.SelectNodes("//vrdatabase/vr_record/inquiry_data/license_number");
//Create new vr_record tag
//newVrRecord = doc.CreateElement("vr_record");
//Create inquiry_data child element
// XmlElement newInquiryData =
doc.CreateElement("inquiry_data");
//newVrRecord.AppendChild(newInquiryData);
int nodeTotal = nodeLst.Count;

MessageBox.Show("node total=" + nodeTotal);

//Create Strean reader eventually point to real file
FileStream fileStream = new
FileStream("vrinqout.txt",FileMode.Open,FileAccess.Read);
sr = new StreamReader(fileStream);
//Declare a counter
int totalRecords = 0;
//create the declaration if not created do this on first
run or
whenever file
// does not exist
//XmlDeclaration xmldecl = doc.CreateXmlDeclaration("1.0",
null,
null);
while ((nextLine = sr.ReadLine()) != null)
{
cardNumber = nextLine.Substring(nextLine.Length - 1,
1);
licenseNumber = nextLine.Substring(0, 7);
if (cardNumber == "1")
{
newVrRecord = doc.CreateElement("vr_record");
newInquiryData =
doc.CreateElement("inquiry_data");
newVrRecord.AppendChild(newInquiryData);
XmlElement newLicenseNumber =
doc.CreateElement("license_number");
newLicenseNumber.InnerText =
nextLine.Substring(0,7);
newInquiryData.AppendChild(newLicenseNumber);
//Insert call to section to walk thru loaded
dataset
to see if
//license number exists.

//updateXmlDatabase(newLicenseNumber.ToString());

}
if (cardNumber == "2")
{
XmlElement regExpireDate =
doc.CreateElement("reg_expire_date");
regExpireDate.InnerText =
nextLine.Substring(8, 6);
newInquiryData.AppendChild(regExpireDate);
XmlElement yearModel =
doc.CreateElement("year_model");
yearModel.InnerText = nextLine.Substring(15,
2);
newInquiryData.AppendChild(yearModel);
XmlElement make = doc.CreateElement("make");
make.InnerText = nextLine.Substring(18, 5);
newInquiryData.AppendChild(make);
XmlElement vin = doc.CreateElement("vin");
vin.InnerText = nextLine.Substring(24, 30);
newInquiryData.AppendChild(vin);
XmlElement roCity =
doc.CreateElement("ro_city");
roCity.InnerText = nextLine.Substring(55, 13);
newInquiryData.AppendChild(roCity);
XmlElement roZip =
doc.CreateElement("ro_zip");
roZip.InnerText = nextLine.Substring(69, 5);
newInquiryData.AppendChild(roZip);
XmlElement roCountyCode =
doc.CreateElement("ro_county_code");
roCountyCode.InnerText =
nextLine.Substring(75, 2);
newInquiryData.AppendChild(roCountyCode);
}
if (cardNumber == "3")
{
XmlElement paperIssueDate =
doc.CreateElement("paper_issue_date");
paperIssueDate.InnerText =
nextLine.Substring(8, 6);
newInquiryData.AppendChild(paperIssueDate);
XmlElement roNameAndAddressSourceIndicator =
doc.CreateElement("ro_nameaddress_source_indicator");
roNameAndAddressSourceIndicator.InnerText =
nextLine.Substring(14, 1);
newInquiryData.AppendChild(roNameAndAddressSourceIndicator);

XmlElement roName =
doc.CreateElement("ro_name");
roName.InnerText = nextLine.Substring(15, 30);
newInquiryData.AppendChild(roName);
XmlElement roNameOrAddress =
doc.CreateElement("ro_name_or_address");
roNameOrAddress.InnerText =
nextLine.Substring(46,
30);
newInquiryData.AppendChild(roNameOrAddress);
}
if (cardNumber == "4")
{
XmlElement additionalRoNameOrAddress =
doc.CreateElement("additional_ro_name_or_address");
additionalRoNameOrAddress.InnerText =
nextLine.Substring(8, 30);

newInquiryData.AppendChild(additionalRoNameOrAddress);
XmlElement additionalRoAddress =
doc.CreateElement("additional_ro_address");
additionalRoAddress.InnerText =
nextLine.Substring(31, 30);

newInquiryData.AppendChild(additionalRoAddress);
}
if (cardNumber == "5")
{
XmlElement recordConditionCode =
doc.CreateElement("record_condition_code");
recordConditionCode.InnerText =
nextLine.Substring(8, 2);

newInquiryData.AppendChild(recordConditionCode);
XmlElement recordConditionCodeDate =
doc.CreateElement("record_condition_code_date");
recordConditionCodeDate.InnerText =
nextLine.Substring(11, 6);

newInquiryData.AppendChild(recordConditionCodeDate);
XmlElement recordRemarks =
doc.CreateElement("record_remarks");
recordRemarks.InnerText =
nextLine.Substring(18, 30);
newInquiryData.AppendChild(recordRemarks);
}
if (cardNumber == "6")
{
XmlElement errorCode =
doc.CreateElement("error_code");
errorCode.InnerText = nextLine.Substring(8,
2);
newInquiryData.AppendChild(errorCode);
XmlElement errorMessage =
doc.CreateElement("error_message");
errorMessage.InnerText =
nextLine.Substring(13, 45);
newInquiryData.AppendChild(errorMessage);
XmlElement errorDate =
doc.CreateElement("error_date");
errorDate.InnerText = nextLine.Substring(59,
6);
newInquiryData.AppendChild(errorDate);
}
if (cardNumber == "7")
{
XmlElement nrlDate =
doc.CreateElement("nrl_date");
nrlDate.InnerText = nextLine.Substring(13,
45);
newInquiryData.AppendChild(nrlDate);
XmlElement nrlTransferDate =
doc.CreateElement("nrl_transfer_date");
nrlTransferDate.InnerText =
nextLine.Substring(13,
45);
newInquiryData.AppendChild(nrlTransferDate);
XmlElement nrlNameOrMessage =
doc.CreateElement("nrl_name_or_message");
nrlNameOrMessage.InnerText =
nextLine.Substring(13,
45);
newInquiryData.AppendChild(nrlNameOrMessage);
XmlElement nrlRecordId =
doc.CreateElement("nrl_record_Id");
nrlRecordId.InnerText = nextLine.Substring(13,
45);
newInquiryData.AppendChild(nrlRecordId);
}
if (cardNumber == "8")
{
XmlElement nrlDate =
doc.CreateElement("nrl_date");
nrlDate.InnerText = nextLine.Substring(13,
45);
newInquiryData.AppendChild(nrlDate);
XmlElement nrlTransferDate =
doc.CreateElement("nrl_transfer_date");
nrlTransferDate.InnerText =
nextLine.Substring(13,
45);
newInquiryData.AppendChild(nrlTransferDate);
XmlElement nrlNameOrMessage =
doc.CreateElement("nrl_name_or_message");
nrlNameOrMessage.InnerText =
nextLine.Substring(13,
45);
newInquiryData.AppendChild(nrlNameOrMessage);
XmlElement nrlRecordId =
doc.CreateElement("nrl_record_Id");
nrlRecordId.InnerText = nextLine.Substring(13,
45);
newInquiryData.AppendChild(nrlRecordId);
}

if (oldplate != licenseNumber)
{
XmlElement newCitationNumber =
doc.CreateElement("citation_number");
 
Top