vb点虐 断电保存数据 vbnet recordset
VB点虐 怎样保存文件
保存文件的步骤为:
创新互联公司始终坚持【策划先行,效果至上】的经营理念,通过多达十余年累计超上千家客户的网站建设总结了一套系统有效的全网整合营销推广解决方案,现已广泛运用于各行各业的客户,其中包括:成都主动防护网等企业,备受客户认可。
关闭流,特别是写入流
关闭并保存文件
示例代码如下:
Imports System.Windows.Forms
Imports System.IO
Imports System.Text
Sub SaveFileDemo()
'打开文件。如果文件不存在则创建新的文件
Dim myFile As New IO.FileStream("d:\data.txt", _
FileMode.OpenOrCreate, _
FileAccess.Write)
'在文件末尾添加一行
Dim tw As New StreamWriter(myFile)
myFile.Seek(0, SeekOrigin.End)
tw.WriteLine("白刃格斗英雄连英模部队方队亮相阅兵")
'关闭流
tw.Close()
'关闭文件并保存文件
myFile.Close()
End Sub
如何实现VB.NET退出程序保存设置
Private Sub Form1_FormClosed(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosedEventArgs) Handles Me.FormClosed
SaveSetting("appname", "Startup", "text1", TextBox1.Text)
SaveSetting("appname", "Startup", "text2", TextBox2.Text)
End Sub
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim text1 As Double
Dim text2 As Double
text1 = GetSetting("appname", "startup", "text1", 8)
text2 = GetSetting("appname", "Startup", "text2", 6)
TextBox1.Text = text1
TextBox2.Text = text2
End Sub
vb点虐 保存数据
都是用SQL语句完成的
写入数据库
strSQL="INTO TABLENAME (OPTION1,OPTIN2)VALUES(VALUE1,VALUE2)";
cmd.Connection = conn;
cmd.CommandText = strSQL;
cmd.Parameters.Add(paramrs[i]);
try
{
conn.Open();
}
catch(Exception ex)
{
throw ex;
}
finally
{
cmd.Parameters.Clear();
cmd.CommandText = null;
cmd.Dispose();
conn.Close();
}
读取值
strSQL ="SELECT OPTION1,OPTION2 FROM TABLENAME";
cmd.CommandText = strSQL;
cmd.Connection = conn;
DataSet ds = new DataSet();
try
{
conn.Open();
SqlDataAdapter da = new SqlDataAdapter(cmd);
da.Fill(ds);
}
catch (Exception ex)
{
throw ex;
}
finally
{
cmd.Dispose();
conn.Close();
}
TextBox2.text = ds.Tables[0].rows[0][0].value.tostring();
文章名称:vb点虐 断电保存数据 vbnet recordset
转载来于:http://cdiso.cn/article/ddjsioh.html