私は初心者で、.NET アプリケーションをコンパイルしようとしていますが、再コンパイルで多くのエラーが発生しています。特に次のエラーが発生します。
ステートメントとして使用できるのは、割り当て、呼び出し、インクリメント、デクリメント、および新しいオブジェクトの式のみです。
これが配置されている116行目で、{ SqlDataReader CS;1;0000; }
あなたは何を提案しますか?
namespace ProBall
{
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data.SqlClient;
using System.IO;
using System.Net;
using System.Runtime.InteropServices;
public class DataManager
{
public static List<string> barcodes = new List<string>();
private string connStr;
private string queryStr;
public static bool queueMessage;
public static bool serverStatus = false;
public DataManager()
{
}
public DataManager(string connStr, string queryStr)
{
this.connStr = connStr;
this.queryStr = queryStr;
}
public static IPAddress FindIPAddress(bool localPreference)
{
return FindIPAddress(Dns.GetHostEntry(Dns.GetHostName()), localPreference);
}
public static IPAddress FindIPAddress(IPHostEntry host, bool localPreference)
{
if (host == null)
{
throw new ArgumentNullException("host");
}
if (host.AddressList.Length != 1)
{
foreach (IPAddress address in host.AddressList)
{
bool local = IsLocal(address);
if (local && localPreference)
{
return address;
}
if (!(local || localPreference))
{
return address;
}
}
}
return host.AddressList[0];
}
public string FormatDates(string date)
{
string tmpDate = date;
try
{
string[] nDate = null;
string day = string.Empty;
string month = string.Empty;
string year = string.Empty;
if (tmpDate.Contains("/"))
{
nDate = date.Split(new char[] { '/' });
day = nDate[0];
month = nDate[1];
year = nDate[2].Split(new char[] { ' ' })[0];
return (month + "/" + day + "/" + year);
}
if (tmpDate.Contains("-"))
{
tmpDate = date.Split(new char[] { ' ' })[0];
}
}
catch (Exception er)
{
this.LogError(er.Message, "GENERIC");
}
return tmpDate;
}
public string GetUserName(string tableName = "employees")
{
return this.ReadValue(string.Concat(new object[] { "select id from ", tableName, " where CurrentlyLoggedIn = 1 and LastLoginStation = '", ReturnHostName(), "' and LastLoginStationIP = '", FindIPAddress(true), "'" }), ConfigurationSettings.AppSettings["kcam"]);
}
public static bool IsLocal(IPAddress address)
{
if (address == null)
{
throw new ArgumentNullException("address");
}
byte[] addr = address.GetAddressBytes();
return (((addr[0] == 10) || ((addr[0] == 0xc0) && (addr[1] == 0xa8))) || (((addr[0] == 0xac) && (addr[1] >= 0x10)) && (addr[1] <= 0x1f)));
}
public void LogError(string message, string logType = "GENERIC")
{
StreamWriter ftmp = new StreamWriter(@"c:\coopnet\server\debug.txt", true);
ftmp.WriteLine(message);
ftmp.Close();
}
public bool LogOffUser(string tableName = "employees")
{
return this.SaveEntityData(string.Concat(new object[] { "update ", tableName, " set CurrentlyLoggedIn = 0 where LastLoginStation = '", ReturnHostName(), "' and LastLoginStationIP = '", FindIPAddress(true), "'" }), ConfigurationSettings.AppSettings["kcam"]);
}
public SqlDataReader ReadData()
{
SqlDataReader CS;1;0000;
using (SqlConnection conn = new SqlConnection(this.connStr))
{
using (SqlCommand cmd = new SqlCommand(this.queryStr, conn))
{
conn.Open();
using (SqlDataReader reader = cmd.ExecuteReader())
{
CS;1;0000 = reader;
}
}
}
; return CS; 1; 0000;
}
public bool ReadData(string query)
{
bool status = false;
this.queryStr = query;
using (SqlConnection conn = new SqlConnection(this.connStr))
{
using (SqlCommand cmd = new SqlCommand(this.queryStr, conn))
{
conn.Open();
using (SqlDataReader reader = cmd.ExecuteReader())
{
if (reader.HasRows)
{
status = true;
}
}
return status;
}
}
}
public bool ReadData(string query, string connection)
{
bool status = false;
using (SqlConnection conn = new SqlConnection(connection))
{
using (SqlCommand cmd = new SqlCommand(query, conn))
{
conn.Open();
using (SqlDataReader reader = cmd.ExecuteReader())
{
if (reader.HasRows)
{
status = true;
}
}
return status;
}
}
}
public string ReadValue(string query, string connectionStr)
{
string value = string.Empty;
this.queryStr = query;
try
{
using (SqlConnection conn = new SqlConnection(connectionStr))
{
using (SqlCommand cmd = new SqlCommand(this.queryStr, conn))
{
conn.Open();
using (SqlDataReader reader = cmd.ExecuteReader())
{
if (reader.HasRows)
{
reader.Read();
return reader[0].ToString();
}
}
}
return value;
}
}
catch (Exception)
{
return value;
}
return value;
}
public static string ReturnHostName()
{
return Dns.GetHostName();
}
public bool SaveData()
{
try
{
bool status = false;
using (SqlConnection conn = new SqlConnection(this.connStr))
{
using (SqlCommand cmd = new SqlCommand(this.queryStr, conn))
{
conn.Open();
cmd.ExecuteReader();
status = true;
}
}
return status;
}
catch (Exception se)
{
this.LogError(se.Message, "GENERIC");
return false;
}
}
public bool SaveEntityData(string query, string connectionString)
{
try
{
Func<string, bool> performQuery = delegate (string querySql) {
this.connStr = connectionString;
this.queryStr = querySql;
return this.SaveData();
};
return performQuery(query);
}
catch (Exception e)
{
this.LogError("Error: " + e.Message, "GENERIC");
return false;
}
}
}
}