TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
David
NA
1
0
C# Code Quit Working in VS2005
May 16 2010 10:32 AM
Hello-
And thank you in advance. I am somewhat of a novice C# programmer who has written several apps for WM2005 using VisualStudio 2005. Several of my programs interface to MS SQL Server 2005/2008. My programs have worked correctly until recently when trying to connect/perform SQL operations on my SQL Server. The SQL Server is on my PC and I have ensure TCP/IP is enabled, no firewall restrictions, etc. Once again, something has caused my code to quit working. Below is a stack trace and output of the error of one of my programs I am trying to Debug:
The error is happening when trying to open the connection to the database. This error is happening when I try to connect to other SQL Servers on other PCs as well.
Start
Start2
'GPscan.exe' (Managed): Loaded 'C:\Program Files\Microsoft.NET\SDK\CompactFramework\v2.0\Debugger\BCL\System.Xml.dll', No symbols loaded.
Set SP
Set SP2
Data Source=192.168.1.101,1433;Database=mydbTEST;User ID=sa;Password=pword;
A first chance exception of type 'System.IO.FileNotFoundException' occurred in mscorlib.dll
'GPscan.exe' (Managed): Loaded 'System.Data.SqlClient.resources.dll', No symbols loaded.
A first chance exception of type 'System.Data.SqlClient.SqlException' occurred in System.Data.SqlClient.dll
A first chance exception of type 'System.Data.SqlClient.SqlException' occurred in System.Data.SqlClient.dll
A first chance exception of type 'System.Data.SqlClient.SqlException' occurred in System.Data.SqlClient.dll
at System.Data.SqlClient.SqlConnection.OnError()
at System.Data.SqlClient.SqlInternalConnection.OnError()
at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning()
at System.Data.SqlClient.TdsParser.ReadNetlib()
at System.Data.SqlClient.TdsParser.ReadBuffer()
at System.Data.SqlClient.TdsParser.ReadByte()
at System.Data.SqlClient.TdsParser.Run()
at System.Data.SqlClient.TdsParser.Run()
at System.Data.SqlClient.SqlInternalConnection.Login()
at System.Data.SqlClient.SqlInternalConnection.OpenAndLogin()
at System.Data.SqlClient.SqlInternalConnection..ctor()
at System.Data.SqlClient.SqlConnection.Open()
at GPscan.gpscan.uploadItems_Click()
at System.Windows.Forms.Control.OnClick()
.............................................................................
Here is my source code:
Debug
.WriteLine(
"Start"
);
string
connectionstring3 =
"Data Source=192.168.1.101,1433;Database=mydbTEST;User ID=sa;Password=pword;"
;
using
(
SqlConnection
connection3 =
new
SqlConnection
(connectionstring3))
{
Debug
.WriteLine(
"Start 2"
);
string
[] data =
new
string
[2];
SqlCommand
sqlinsertcomm =
new
SqlCommand
(
"sp_rpc_history_Update"
, connection3);
Debug
.WriteLine(
"Set SP"
);
sqlinsertcomm.CommandType =
CommandType
.StoredProcedure;
ArrayList
arrayList =
new
ArrayList
(recordedassets.Keys);
IEnumerator
recordEnumerator = arrayList.GetEnumerator();
Debug
.WriteLine(
"Set SP2"
);
int
x = 0;
Debug
.WriteLine(connection3.ConnectionString);
sqlinsertcomm.Connection.Open();
Debug
.WriteLine(
"Set SP3"
);
while
(recordEnumerator.MoveNext())
{
Debug
.WriteLine(
"Set SP4"
);
data = (
string
[])recordedassets[recordEnumerator.Current];
sqlinsertcomm.Parameters.Add(
"@lpn_num"
,
SqlDbType
.VarChar).Value = data[0];
sqlinsertcomm.Parameters.Add(
"@shipped_order_num"
,
SqlDbType
.VarChar).Value = data[1];
sqlinsertcomm.Parameters.Add(
"@shipped_when"
,
SqlDbType
.DateTime).Value = System.
DateTime
.Now;
Debug
.WriteLine(
"Finished Param"
);
int
t = sqlinsertcomm.ExecuteNonQuery();
Debug
.WriteLine(
"End"
);
x++;
}
MessageBox
.Show(x.ToString() +
" records updated!"
,
"Upload"
);
connection3.Close();
}
}
catch
(
SqlException
se)
{
Debug
.WriteLine(se.StackTrace);
}
Reply
Answers (
1
)
listview
Testing Latest Activity