that one is ok, only the simple one not work, attached again.
Main Topics
Browse All TopicsI made a small program running on PDA to check data inside SQL Server database on the server.
When program runup, it will excutive 'SELECT TABLE_SCHEMA, TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_TYPE = 'BASE TABLE'' to get all the table list. It runs successful.
After that I manaully key in a SQL(select * from station) in a text window and run it, then got error as below.
Any suggestion?
The C# project code also attached.
at System.Data.SqlClient.TdsP
at System.Data.SqlClient.TdsP
at System.Data.SqlClient.TdsP
at System.Data.SqlClient.SqlD
at System.Data.SqlClient.SqlD
at System.Data.SqlClient.SqlC
at System.Data.SqlClient.SqlC
at System.Data.Common.DbDataA
at System.Data.Common.DbDataA
at System.Data.Common.DbDataA
at Database_Connection.PDADat
at Database_Connection.Form1.
at System.Windows.Forms.Form.
at System.Windows.Forms.Form.
at System.Windows.Forms.Contr
at System.Windows.Forms.Appli
at Database_Connection.Progra
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
namespace FW2WM5
{
public partial class Form1 : Form
{
SqlConnection myConn;
String connStr;
public Form1()
{
InitializeComponent();
connStr =
@"Server='203.117.170.74';
}
private void button10_Click(object sender, EventArgs e)
{
try
{
myConn = new SqlConnection(connStr);
myConn.Open();
FillList();
}
catch (Exception ex)
{
MessageBox.Show("Connectio
}
finally
{
myConn.Close();
}
}
private void FillList()
{
//SqlDataReader myDataReader;
SqlDataAdapter myAdapter = new SqlDataAdapter(txtSQL.Text
DataSet myDataSet = new DataSet();
myAdapter.Fill(myDataSet, "Result");
// dataGridView1.DataSource = myDataSet.DefaultViewManag
dataGrid1.DataSource = myDataSet.Tables["Result"]
}
private void FillObject()
{
try
{
myConn = new SqlConnection(connStr);
myConn.Open();
SqlDataReader myDataReader;
SqlCommand myCmd = myConn.CreateCommand();
myCmd.CommandText = @"SELECT TABLE_SCHEMA, TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_TYPE = 'BASE TABLE'";
treeView1.BeginUpdate();
treeView1.Nodes.Clear();
treeView1.Nodes.Add(new TreeNode("Tables"));
TreeNode childNode = treeView1.Nodes[0];
int childCount = 0;
myDataReader = myCmd.ExecuteReader();
while (myDataReader.Read())
{
string TableName = (myDataReader[0].ToString(
childNode.Nodes.Insert(chi
childCount += 1;
}
myDataReader.Close();
treeView1.Nodes.Add(new TreeNode("Views"));
SqlCommand myCmdView = myConn.CreateCommand();
myCmdView.CommandText = @"SELECT TABLE_SCHEMA, TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_TYPE = 'VIEW'";
TreeNode childNodeView = treeView1.Nodes[1];
int childCountView = 0;
myDataReader = myCmdView.ExecuteReader();
while (myDataReader.Read())
{
string ViewName = (myDataReader[0].ToString(
childNodeView.Nodes.Insert
childCountView += 1;
}
myDataReader.Close();
treeView1.ExpandAll();
treeView1.EndUpdate();
myConn.Close();
} // try
catch (SqlException myexception)
{
foreach (SqlError err in myexception.Errors)
{
MessageBox.Show(err.Messag
}
} // catch
}
private void Form1_Load(object sender, EventArgs e)
{
//if (PDADataSetUtil.DesignerUt
//{
// TODO: ddLãåûdpDADataSet.Statio
//this.stationTableAdapter
//}
FillObject();
}
private void textBox2_Click(object sender, EventArgs e)
{
}
private void txtSQL_TextChanged(object sender, EventArgs e)
{
}
private void stationNameComboBox_Select
{
}
private void treeView1_AfterSelect(obje
{
}
}
}
Business Accounts
Answer for Membership
by: momi_sabagPosted on 2008-09-09 at 03:16:09ID: 22425705
your c# code is not here but maybe you should try this instead
'SELECT TABLE_SCHEMA, TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_TYPE = ''BASE TABLE'' '