社区
C#
帖子详情
有个float类型的值,在写入数据库的时候,oledbtype应该选哪种呢?是VarNumeric还是numeric呢?
dahai99007
2008-08-26 09:41:48
如题.
...全文
129
2
打赏
收藏
有个float类型的值,在写入数据库的时候,oledbtype应该选哪种呢?是VarNumeric还是numeric呢?
如题.
复制链接
扫一扫
分享
转发到动态
举报
写回复
配置赞助广告
用AI写文章
2 条
回复
切换为时间正序
请发表友善的回复…
发表回复
打赏红包
lijin84100
2008-08-26
打赏
举报
回复
System.Data.OleDb.OleDbType.Decimal
ericzhangbo1982111
2008-08-26
打赏
举报
回复
OleDbType.Double=SqlDbType.Float
用ASP.NET做的博客系统
用ASP.NET做的 using System; using System.Data; using System.Configuration; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Web.UI.HtmlControls; using System.Data.
OleDb
; ///
/// Class1 的摘要说明 ///
public class Class1 { private
OleDb
Connection m_Connection; private String m_brChar = "\n"; public Class1() { // // TODO: 在此处添加构造函数逻辑 // } private void ExecuteCommand(
OleDb
Command cmd) { cmd.Connection=m_Connection; try { m_Connection.Open(); cmd.ExecuteNonQuery(); } finally { m_Connection.Close(); } } public DataSet GetNotes(DateTime fromDate, DateTime toDate) { DataSet ds=new DataSet();
OleDb
DataAdapter da=new
OleDb
DataAdapter("select * from Notes where DateTime BETWEEN ? and ? ORDER BY DateTime DESC",m_Connection); da.SelectCommand.Parameters.Add("FromDate",
OleDb
Type
.Date).Value = fromDate.AddDays(1); m_Connection.Open(); da.Fill(ds,"MyNotes"); m_Connection.Close(); return ds; } public void InsertNote(string title,string contents) {
OleDb
Command cmd =new
OleDb
Command ("insert into Notes(Title,Contents) values(?,?)"); cmd.Parameters .Add ("Title",
OleDb
Type
.
Var
Char ).Value =title ; cmd.Parameters .Add ("Contents",
OleDb
Type
.Long
Var
Char ).Value =contents.Replace (m_brChar ,"
"); ExecuteCommand (cmd); } public void InsertComment(int noteid,string author,string email,string comment) {
OleDb
Command cmd=new
OleDb
Command ("insert into Comments(NoteID,Author,Email,Comment) values(?,?,?,?)"); cmd.Parameters .Add ("NoteID",
OleDb
Type
.
Var
Char ).Value =noteid; cmd.Parameters .Add ("Author",
OleDb
Type
.
Var
Char ).Value =author ; cmd.Parameters .Add ("Email",
OleDb
Type
.
Var
Char ).Value =email ; cmd.Parameters .Add ("Comment",
OleDb
Type
.Long
Var
Char ).Value =comment.Replace (m_brChar ,"
"); ExecuteCommand (cmd); } public void UpdaeNote(int noteid, string title, string contents) {
OleDb
Command cmd = new
OleDb
Command("UPDATE [Notes] SET [Title]=?,[Contents]=? WHERE [NoteID]=?"); cmd.Parameters.Add("Title",
OleDb
Type
.
Var
Char).Value = title; cmd.Parameters.Add("Contents",
OleDb
Type
.Long
Var
Char).Value = contents.Replace(m_brChar, "
"); cmd.Parameters.Add("NoteID",
OleDb
Type
.Integer).Value = noteid; ExecuteCommand(cmd); } public void UpdateComment(int commentid,string author,string email,string comment) {
OleDb
Command cmd =new
OleDb
Command ("UPDATE Comments SET Author =?,Email=?,Comment=? WHERE CommentID=?"); cmd.Parameters .Add ("Author",
OleDb
Type
.
Var
Char ).Value =author; cmd.Parameters .Add ("Comment",
OleDb
Type
.Long
Var
Char).Value =comment.Replace (m_brChar ,"
"); cmd.Parameters.Add("Email",
OleDb
Type
.
Var
Char).Value = email; cmd.Parameters.Add("CommentID",
OleDb
Type
.
Var
Char).Value = commentid; ExecuteCommand(cmd); } public void DeleteNote(int noteid) {
OleDb
Command cmd =new
OleDb
Command ("delete from Notes where NoteID="+noteid); ExecuteCommand(cmd); } public void DeleteComment(int commentid) {
OleDb
Command cmd =new
OleDb
Command ("delete from Comments where CommentID="+commentid); ExecuteCommand (cmd); } public void GetNoteData(int noteid,ref string title,ref string contents,ref string post_time) {
OleDb
Command cmd=new
OleDb
Command ("select * from Notes where NoteID="+ noteid ,m_Connection ); try { m_Connection .Open();
OleDb
DataReader reader=cmd.ExecuteReader (CommandBehavior .CloseConnection ); if(reader .Read ()) { title =reader ["Title"].ToString (); contents =reader ["Contents"].ToString ().Replace ("
",m_brChar ); post_time =reader ["DataTime"].ToString (); reader .Close (); } } finally { m_Connection .Close (); } } public void GetCommentData(int commentid,ref string author,ref string email,ref string comment) {
OleDb
Command cmd=new
OleDb
Command ("select * from Comments where CommentID="+commentid ,m_Connection ); try { m_Connection .Open ();
OleDb
DataReader reader=cmd.ExecuteReader (CommandBehavior .CloseConnection ); if(reader.Read ()) { author =reader ["Author"].ToString (); email =reader ["Comment"].ToString ().Replace ("
",m_brChar ); reader .Close (); } } finally { m_Connection .Close (); } } } ///
/// data 的摘要说明 ///
C#编程登陆界面代码
C#编程登陆界面代码 using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; using System.Data.
OleDb
; namespace 人事管理系统 { public partial class FormLogin : Form { public FormLogin() { InitializeComponent(); } private void FormLogin_Load(object sender, EventArgs e) { } public void buttonLogin_Click_1(object sender, EventArgs e) { try { if (textBoxName .Text =="") { MessageBox.Show ("用户名不能为空!","提示",MessageBoxButtons.OKCancel,MessageBoxIcon.Warning ); } else { if (textBoxPassword .Text =="") { MessageBox.Show("密码不能为空!", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning); } else { String connStr = "Provider=Microsoft.Jet.
OLEDB
.4.0;Data Source=" + Application.StartupPath + "\\人事
数据库
.mdb";
OleDb
Connection conn = new
OleDb
Connection(connStr); //String sql = "select count(*) from 用户密码表 where username='" + textBoxName.Text + "' and password='" + textBoxPassword.Text + "'"; conn.Open(); string sql = "select count(*) from 用户密码表 where username=@name and password=@pass";
OleDb
Command cmd = new
OleDb
Command(sql ,conn ); cmd.Parameters.Add(new
OleDb
Parameter ("@name",
OleDb
Type
.Char )); cmd.Parameters["@name"].Value = textBoxName.Text; cmd.Parameters.Add(new
OleDb
Parameter("@pass",
OleDb
Type
.Char)); cmd.Parameters["@pass"].Value = textBoxPassword.Text; //
OleDb
DataAdapter da = new
OleDb
DataAdapter(sql, conn); //DataTable dt = new DataTable(); //da.Fill(dt); //int i = dt.Rows.Count; int i =(int )cmd.ExecuteScalar (); conn.Close(); if (i > 0) { FormMain fm = new FormMain(); fm.admintime = DateTime.Now.ToShortDateString(); fm.adminname = textBoxName.Text; fm.Show(); this.Hide (); } else { MessageBox.Show("用户名或密码错误!", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Error ); { textBoxName.Text = ""; textBoxPassword.Text = ""; textBoxName.Focus(); } } } } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } } private void button1_Click(object sender, EventArgs e) { if (MessageBox.Show("您确定要退出本系统吗?", "警告", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) == DialogResult.OK) { Application.Exit(); } } private void textBoxName_KeyPress(object sender, KeyPressEventArgs e) { if (e.KeyChar == 13) { textBoxPassword.Focus(); e.Handled = true; } } private void textBoxPassword_KeyPress(object sender, KeyPressEventArgs e) { if (e.KeyChar == 13) { buttonLogin.Focus(); e.Handled = true; } } private void linkLabeladd_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) { Form添加 fpty = new Form添加(); fpty.Show(); } private void linkLabelpass_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) { Formpasswordmodify fpmd = new Formpasswordmodify(); fpmd.Show(); } } }
C#,
OleDb
Type
,Access 对应数据
类型
访问
类型
名称
数据库
数据
类型
OLEDB
类型
.NET 框架
类型
成员名称 文本
Var
WChar DB
TYPE
_ WSTR System.String
OleDb
Type
.
Var
WChar 备忘录 Long
Var
WCha R DB
TYPE
_ WSTR System.String
OleDb
Type
.Long
Var
WC...
OleDb
Type
,C#,access 对应数据
类型
访问
类型
名称
数据库
数据
类型
OLEDB
类型
.NET 框架
类型
成员名称文本
Var
WCharDB
TYPE
_ WSTRSystem.String
OleDb
Type
.
Var
WChar备忘录Long
Var
WCha RDB
TYPE
_ WSTRSystem.String
OleDb
Type
.Long
Var
WChar字节数:UnsignedTinyIntDB
TYPE
_ UI 1System.Byte
OleDb
Type
.UnsignedTinyInt是 / 否BooleanDB
TYPE
_BOOLSystem.Boolea
c#图文混合,以二进制方式
写入
数据库
图片与文字二进制
写入
数据库
C#
110,533
社区成员
642,574
社区内容
发帖
与我相关
我的任务
C#
.NET技术 C#
复制链接
扫一扫
分享
社区描述
.NET技术 C#
社区管理员
加入社区
获取链接或二维码
近7日
近30日
至今
加载中
查看更多榜单
社区公告
让您成为最强悍的C#开发者
试试用AI创作助手写篇文章吧
+ 用AI写文章