VB.NET Conversion Error

N

Neel

HiAll,

I converted the below 2 sets of code into VB.net,with
conversion tools. I am getting a syntax error.

Can some one help me to convert the below code into
VB.net ?
I am building on the fly xml for xmlhttp to fill up the
drop downs. i have tested this in C# it is working fine.
------------------Set 1-----------------------------
strSQL = "Select Title from [Titles] Where ISBN = '" + Id
+ "'";
da = new OleDbDataAdapter(strSQL,conn);
ds = new DataSet();
da.Fill(ds,"TitleName");
dt = ds.Tables[0];
StringBuilder sbTitle = new StringBuilder("");
if(dt.Rows.Count > 0)
{
foreach(DataRow dr in dt.Rows)
{
sbTitle.Append("<TITLE VALUE=");
sbTitle.Append("\"" + dr["Title"].ToString() + "\"");
sbTitle.Append("/>");
}
StringBuilder sb = new StringBuilder("");
sb.Append("<?xml version=\"1.0\"?>");
sb.Append("<ROOT>");
sb.Append(sbTitle.ToString());
sb.Append("</ROOT>");
Response.Write(sb.ToString());
========================================================
-----------Set 2 ---------------------------------------
strSQL = "Select ISBN,Au_id from [Title Author] Where
Au_Id = " + Id;
da = new OleDbDataAdapter(strSQL,conn);
ds = new DataSet();
da.Fill(ds,"ISBNList");
dt = ds.Tables[0];
StringBuilder sbISBN = new StringBuilder("");
if(dt.Rows.Count > 0)
{
foreach(DataRow dr in dt.Rows)
{
sbISBN.Append("<ISBN VALUE=");
sbISBN.Append("\"" + dr["ISBN"].ToString() + "\"");
sbISBN.Append(" ID=");
sbISBN.Append("\"" + dr["AU_ID"].ToString() + "\"");
sbISBN.Append("/>");
}
StringBuilder sb = new StringBuilder("");
sb.Append("<?xml version=\"1.0\"?>");
sb.Append("<ROOT>");
sb.Append(sbISBN.ToString());
sb.Append("</ROOT>");
Response.Write(sb.ToString());
}
======================================================
 
D

David Williams

I find a couple of problems with the code (when translating). In both
examples, if you put the first two lines together, you will find that the
syntax errors go away. In the first example, the "if" statement on line 8
is never terminated, so will generate an error there also.

HTH

David
 
N

Neel

Thanx for the reply, I will try it
-----Original Message-----
I find a couple of problems with the code (when translating). In both
examples, if you put the first two lines together, you will find that the
syntax errors go away. In the first example, the "if" statement on line 8
is never terminated, so will generate an error there also.

HTH

David

HiAll,

I converted the below 2 sets of code into VB.net,with
conversion tools. I am getting a syntax error.

Can some one help me to convert the below code into
VB.net ?
I am building on the fly xml for xmlhttp to fill up the
drop downs. i have tested this in C# it is working fine.
------------------Set 1-----------------------------
strSQL = "Select Title from [Titles] Where ISBN = '" + Id
+ "'";
da = new OleDbDataAdapter(strSQL,conn);
ds = new DataSet();
da.Fill(ds,"TitleName");
dt = ds.Tables[0];
StringBuilder sbTitle = new StringBuilder("");
if(dt.Rows.Count > 0)
{
foreach(DataRow dr in dt.Rows)
{
sbTitle.Append("<TITLE VALUE=");
sbTitle.Append("\"" + dr["Title"].ToString() + "\"");
sbTitle.Append("/>");
}
StringBuilder sb = new StringBuilder("");
sb.Append("<?xml version=\"1.0\"?>");
sb.Append("<ROOT>");
sb.Append(sbTitle.ToString());
sb.Append("</ROOT>");
Response.Write(sb.ToString());
========================================================
-----------Set 2 ---------------------------------------
strSQL = "Select ISBN,Au_id from [Title Author] Where
Au_Id = " + Id;
da = new OleDbDataAdapter(strSQL,conn);
ds = new DataSet();
da.Fill(ds,"ISBNList");
dt = ds.Tables[0];
StringBuilder sbISBN = new StringBuilder("");
if(dt.Rows.Count > 0)
{
foreach(DataRow dr in dt.Rows)
{
sbISBN.Append("<ISBN VALUE=");
sbISBN.Append("\"" + dr["ISBN"].ToString() + "\"");
sbISBN.Append(" ID=");
sbISBN.Append("\"" + dr["AU_ID"].ToString() + "\"");
sbISBN.Append("/>");
}
StringBuilder sb = new StringBuilder("");
sb.Append("<?xml version=\"1.0\"?>");
sb.Append("<ROOT>");
sb.Append(sbISBN.ToString());
sb.Append("</ROOT>");
Response.Write(sb.ToString());
}
======================================================


.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top