if (m_conn.State != ConnectionState.Open)
{
m_conn.Open();
}
flag = true;
}
catch (Exception ex)
{
flag = false;
//throw ex;
}
return flag;
}
/// <summary>
/// 读取数据
/// </summary>
/// <returns></returns>
public DataTable GetNetPower(string queryStr)
{
DataTable dt = null;
if (Connection())
{
try
{
dt = new DataTable();
SqlCommand cmd = new SqlCommand(queryStr, m_conn);
SqlDataAdapter adapter = new SqlDataAdapter(cmd);
adapter.Fill(dt);//填充数据表
cmd.Dispose();
}
catch (Exception ex)
{
dt = null;
}
finally
{
m_conn.Close();
m_conn.Dispose();
}
}
return dt;
}
}
}
真不好意思
我是初学者
代码
我要放在VS上
我都弄不好
方便帮我把代码放在VS上吗?
谢谢
--------------------编程问答--------------------
不能什么都找人代劳,百度下vs如何创建工程吧
--------------------编程问答--------------------
namespace BinaryWriterReader
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("***** Fun with Binary Writers / Readers *****\n");
// Open a binary writer for a file.
FileInfo f = new FileInfo("BinFile.dat");
using (BinaryWriter bw = new BinaryWriter(f.OpenWrite()))
{
// Print out the type of BaseStream.
// (System.IO.FileStream in this case).
Console.WriteLine("Base stream is: {0}", bw.BaseStream);
// Create some data to save in the file
double aDouble = 1234.67;
int anInt = 34567;
string aString = "A, B, C";
// Write the data
bw.Write(aDouble);
bw.Write(anInt);
bw.Write(aString);
}
// Read the binary data from the stream.
using (BinaryReader br = new BinaryReader(f.OpenRead()))
{
Console.WriteLine(br.ReadDouble());
Console.WriteLine(br.ReadInt32());
Console.WriteLine(br.ReadString());
}
Console.ReadLine();
}
}
}
--------------------编程问答--------------------
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
namespace BinaryWriterReader
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("***** Fun with Binary Writers / Readers *****\n");
// Open a binary writer for a file.
FileInfo f = new FileInfo("BinFile.dat");
using (BinaryWriter bw = new BinaryWriter(f.OpenWrite()))
{
// Print out the type of BaseStream.
// (System.IO.FileStream in this case).
Console.WriteLine("Base stream is: {0}", bw.BaseStream);
// Create some data to save in the file
double aDouble = 1234.67;
int anInt = 34567;
string aString = "A, B, C";
// Write the data
bw.Write(aDouble);
bw.Write(anInt);
bw.Write(aString);
}
// Read the binary data from the stream.
using (BinaryReader br = new BinaryReader(f.OpenRead()))
{
Console.WriteLine(br.ReadDouble());
Console.WriteLine(br.ReadInt32());
Console.WriteLine(br.ReadString());
}
Console.ReadLine();
}
}
}
--------------------编程问答--------------------
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
namespace BinaryWriterReader
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("***** Fun with Binary Writers / Readers *****\n");
// Open a binary writer for a file.
FileInfo f = new FileInfo("BinFile.dat");
using (BinaryWriter bw = new BinaryWriter(f.OpenWrite()))
{
// Print out the type of BaseStream.
// (System.IO.FileStream in this case).
Console.WriteLine("Base stream is: {0}", bw.BaseStream);
// Create some data to save in the file
double aDouble = 1234.67;
int anInt = 34567;
string aString = "A, B, C";
// Write the data
bw.Write(aDouble);
bw.Write(anInt);
bw.Write(aString);
}
// Read the binary data from the stream.
using (BinaryReader br = new BinaryReader(f.OpenRead()))
{
Console.WriteLine(br.ReadDouble());
Console.WriteLine(br.ReadInt32());
Console.WriteLine(br.ReadString());
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
namespace BinaryWriterReader
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("***** Fun with Binary Writers / Readers *****\n");
// Open a binary writer for a file.
FileInfo f = new FileInfo("BinFile.dat");
using (BinaryWriter bw = new BinaryWriter(f.OpenWrite()))
{
// Print out the type of BaseStream.
// (System.IO.FileStream in this case).
Console.WriteLine("Base stream is: {0}", bw.BaseStream);
// Create some data to save in the file
double aDouble = 1234.67;
int anInt = 34567;
string aString = "A, B, C";
// Write the data
bw.Write(aDouble);
bw.Write(anInt);
bw.Write(aString);
}
// Read the binary data from the stream.
using (BinaryReader br = new BinaryReader(f.OpenRead()))
{
Console.WriteLine(br.ReadDouble());
Console.WriteLine(br.ReadInt32());
Console.WriteLine(br.ReadString());
}