F
Familjen Karlsson
How will the code under look like in Visual Basic .Net, since you can't use
the keyword null anymoore in Visual Basic .Net. What can I use instead.
SqlConnection connection = null; SqlCommand command = null; SqlDataReader
reader = null;
String connectionString = "integrated security=SSPI;"; connectionString +=
"data source=(local);"; connectionString += "initial catalog=Northwind";
String sqlCommandString = "SELECT CustomerID, CompanyName FROM Customers";
try {
connection = new SqlConnection(connectionString);
command = new SqlCommand(sqlCommandString, connection); connection.Open();
reader = command.ExecuteReader();
if(reader != null)
{
while(reader.Read())
{
Console.Write(reader["CustomerID"]+ "\t");
Console.WriteLine(reader["CompanyName"]); ...
}
}
}catch( ){....}
finally
{
if(reader != null)
reader.Close();
if(connection.State == ConnectionState.Open)
connection.Close();
}
mvh
Fia
the keyword null anymoore in Visual Basic .Net. What can I use instead.
SqlConnection connection = null; SqlCommand command = null; SqlDataReader
reader = null;
String connectionString = "integrated security=SSPI;"; connectionString +=
"data source=(local);"; connectionString += "initial catalog=Northwind";
String sqlCommandString = "SELECT CustomerID, CompanyName FROM Customers";
try {
connection = new SqlConnection(connectionString);
command = new SqlCommand(sqlCommandString, connection); connection.Open();
reader = command.ExecuteReader();
if(reader != null)
{
while(reader.Read())
{
Console.Write(reader["CustomerID"]+ "\t");
Console.WriteLine(reader["CompanyName"]); ...
}
}
}catch( ){....}
finally
{
if(reader != null)
reader.Close();
if(connection.State == ConnectionState.Open)
connection.Close();
}
mvh
Fia