G
Guest
I am having trouble connecting to a SQL Server 2000 server on our network.
The handheld device is connected wirelessly to the network. I can ping the
IP address of our SQL Server from the mobile device. I can get on the
internet using the device. But I get an SQLException when trying to run just
a very simple app
that is suppose to connect to the SQL Server Northwind database. It doesnt
give any error code. Here is my simple app. The app is suppose to just pull
one record and show the record count in a text box on a form but never gets
to that point. It bombs on the connection. Could someone tell me if my
connection string is off or something?
Thanks,
David
using System;
using System.Drawing;
using System.Collections;
using System.Windows.Forms;
using System.Data;
using System.Data.Common;
using System.Data.SqlClient;
namespace TestSQL
{
/// <summary>
/// Summary description for Form1.
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.TextBox textBox1;
private System.Windows.Forms.TextBox textBox2;
private System.Windows.Forms.MainMenu mainMenu1;
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 )
{
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.mainMenu1 = new System.Windows.Forms.MainMenu();
this.textBox1 = new System.Windows.Forms.TextBox();
this.textBox2 = new System.Windows.Forms.TextBox();
//
// textBox1
//
this.textBox1.Location = new System.Drawing.Point(32, 40);
this.textBox1.Size = new System.Drawing.Size(184, 22);
this.textBox1.Text = "textBox1";
//
// textBox2
//
this.textBox2.Location = new System.Drawing.Point(32, 88);
this.textBox2.Size = new System.Drawing.Size(184, 22);
this.textBox2.Text = "textBox2";
//
// Form1
//
this.Controls.Add(this.textBox2);
this.Controls.Add(this.textBox1);
this.Menu = this.mainMenu1;
this.Text = "Form1";
this.Load += new System.EventHandler(this.Form1_Load);
}
#endregion
/// <summary>
/// The main entry point for the application.
/// </summary>
static void Main()
{
Application.Run(new Form1());
}
private void Form1_Load(object sender, System.EventArgs e)
{
// Connection String for MSSQL Server 200
// Server IP 192.168.251.32, dummy database = WINSTSDB, dummy
user =
sleeptrain
string Connection_String = "Data Source=192.168.251.32;Initial
Catalog=Northwind;User Id=sleeptrain;Password=monkeytrain";
// Setup SQL Connection object
SqlConnection dbConn = new SqlConnection( Connection_String );
// This routine will create a detailed table structure report
SqlDataAdapter da = new SqlDataAdapter("SELECT * FROM
dbo.Employees WHERE
EmployeeID = 1",dbConn);
// Define a Data Table object
System.Data.DataTable WinstisTable = new DataTable();
dbConn.Open();
da.Fill( WinstisTable );
this.textBox1.Text = "Count = " +
WinstisTable.Rows.Count.ToString();
dbConn.Close();
da.Dispose();
}
}
}
The handheld device is connected wirelessly to the network. I can ping the
IP address of our SQL Server from the mobile device. I can get on the
internet using the device. But I get an SQLException when trying to run just
a very simple app
that is suppose to connect to the SQL Server Northwind database. It doesnt
give any error code. Here is my simple app. The app is suppose to just pull
one record and show the record count in a text box on a form but never gets
to that point. It bombs on the connection. Could someone tell me if my
connection string is off or something?
Thanks,
David
using System;
using System.Drawing;
using System.Collections;
using System.Windows.Forms;
using System.Data;
using System.Data.Common;
using System.Data.SqlClient;
namespace TestSQL
{
/// <summary>
/// Summary description for Form1.
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.TextBox textBox1;
private System.Windows.Forms.TextBox textBox2;
private System.Windows.Forms.MainMenu mainMenu1;
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 )
{
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.mainMenu1 = new System.Windows.Forms.MainMenu();
this.textBox1 = new System.Windows.Forms.TextBox();
this.textBox2 = new System.Windows.Forms.TextBox();
//
// textBox1
//
this.textBox1.Location = new System.Drawing.Point(32, 40);
this.textBox1.Size = new System.Drawing.Size(184, 22);
this.textBox1.Text = "textBox1";
//
// textBox2
//
this.textBox2.Location = new System.Drawing.Point(32, 88);
this.textBox2.Size = new System.Drawing.Size(184, 22);
this.textBox2.Text = "textBox2";
//
// Form1
//
this.Controls.Add(this.textBox2);
this.Controls.Add(this.textBox1);
this.Menu = this.mainMenu1;
this.Text = "Form1";
this.Load += new System.EventHandler(this.Form1_Load);
}
#endregion
/// <summary>
/// The main entry point for the application.
/// </summary>
static void Main()
{
Application.Run(new Form1());
}
private void Form1_Load(object sender, System.EventArgs e)
{
// Connection String for MSSQL Server 200
// Server IP 192.168.251.32, dummy database = WINSTSDB, dummy
user =
sleeptrain
string Connection_String = "Data Source=192.168.251.32;Initial
Catalog=Northwind;User Id=sleeptrain;Password=monkeytrain";
// Setup SQL Connection object
SqlConnection dbConn = new SqlConnection( Connection_String );
// This routine will create a detailed table structure report
SqlDataAdapter da = new SqlDataAdapter("SELECT * FROM
dbo.Employees WHERE
EmployeeID = 1",dbConn);
// Define a Data Table object
System.Data.DataTable WinstisTable = new DataTable();
dbConn.Open();
da.Fill( WinstisTable );
this.textBox1.Text = "Count = " +
WinstisTable.Rows.Count.ToString();
dbConn.Close();
da.Dispose();
}
}
}