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(); } } }
exec sp_configure 'show advanced options',1
reconfigure
exec sp_configure 'Ad Hoc Distributed Queries',1
reconfigureinsert into
OpenRowset('MSDASQL', 'Driver={Microsoft Text Driver (*.txt; *.csv)};DefaultDir=d:\;',
'select *from [22.txt] ')
select * from Products---关闭
exec sp_configure 'show advanced options',0
reconfigure
这对我太难了
有没有C#的代码
谢谢
然后再变成txt吗?
可是这样我还是不知代码要怎么写
麻烦教一下
谢谢
代码要如何写呢?
谢谢
不知道你用的是什么编程语言,
.Net使用ADO.NET...
代码要如何写呢?
谢谢
不知道你用的是什么编程语言,
.Net使用ADO.NET...
只要C#可以写出来即可
我有买书
可是书上都没教怎么把data转出来
麻烦教教我
谢谢
{
/// <summary>
/// 连接sqlserver对象
/// </summary>
private SqlConnection m_conn;
/// <summary>
/// 数据库名称,需要根据使用的数据库修改
/// </summary>
public string m_DatabaseName = "";
/// <summary>
/// 服务器IP或名称
/// </summary>
private string m_ServerName = "";
/// <summary>
/// 用户名
/// </summary>
private string m_UserName = "";
/// <summary>
/// 密码
/// </summary>
private string m_Password = ""; public DbInterface(string serverName, string userName, string passWord, string dataBase)
{
m_ServerName = serverName;
m_UserName = userName;
m_Password = passWord;
m_DatabaseName = dataBase;
} /// <summary>
/// 数据库连接
/// </summary>
/// <returns>是否连接</returns>
private bool Connection()
{
bool flag = false;
try
{
String connStr = "User ID=" + m_UserName + ";Password=" + m_Password + ";database="
+ m_DatabaseName + ";Data Source =" + m_ServerName;
m_conn = new SqlConnection(connStr);
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上吗?
谢谢
{
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.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();
} }
}