本文整理汇总了C#中db类的典型用法代码示例。如果您正苦于以下问题:C# db类的具体用法?C# db怎么用?C# db使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
db类属于命名空间,在下文中一共展示了db类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: Save
public void Save(object o)
{
db db1 = new db();
character t = (character)o;
if (t.IsDirty)
{
// save dirt to database
db1 = new MMO.db();
db1.SetCommand("s_SaveCharacter", CommandType.StoredProcedure);
db1.AddParam<int>("id", SqlDbType.Int, 4, t.id);
db1.AddParam<int>("login", SqlDbType.Int, 4, owner.loginID);
db1.AddParam<string>("charactername", SqlDbType.VarChar, 50, t.name);
db1.AddParam<int>("charactertype", SqlDbType.Int, 4, 0);
db1.AddParam<int>("hp", SqlDbType.Int, 4, t.hp);
db1.AddParam<int>("stamina", SqlDbType.Int, 4, t.stamina);
db1.AddParam<int>("mana", SqlDbType.Int, 4, t.mana);
db1.AddParam<int>("x", SqlDbType.Int, 4, t.x);
db1.AddParam<int>("y", SqlDbType.Int, 4, t.y);
// return value of runscalar is the new or old id of tile
t.id = Int32.Parse(db1.RunScalar().ToString());
// no dirt to save
t.IsDirty = false;
}
}
开发者ID:joelldj,项目名称:ajaxmmo,代码行数:27,代码来源:characterDB.cs
示例2: regDBImage
protected void regDBImage(string[] info)
{
string name = info[0];
string fn = info[1];
string description = info[2];
string email = info[3];
string path = info[4];
DateTime date = DateTime.Now;
int UserID = util.getID(email);
db dbc = new db();
try
{
dbc.cmd.CommandText = "INSERT INTO pictures (name,filename,description,userID,date,path) VALUES(@Name,@FileName,@Description,@UserID,@Date,@Path)";
dbc.cmd.Parameters.Add(new SqlParameter("Name", name));
dbc.cmd.Parameters.Add(new SqlParameter("FileName", fn));
dbc.cmd.Parameters.Add(new SqlParameter("Description", description));
dbc.cmd.Parameters.Add(new SqlParameter("UserID", UserID));
dbc.cmd.Parameters.Add(new SqlParameter("Date", date));
dbc.cmd.Parameters.Add(new SqlParameter("Path", path));
dbc.cmd.ExecuteNonQuery();
}
catch
{
Gavan.Global.error = "ההעלה נכשלה נסה שוב.";
}
}
开发者ID:nick2il,项目名称:GavanGallery,代码行数:26,代码来源:upload.aspx.cs
示例3: GetCharacters
public List<character> GetCharacters()
{
db db1 = new db();
db1.SetCommand("s_CharactersGet", CommandType.StoredProcedure);
db1.AddParam<int>("LoginID", SqlDbType.Int, 4, owner.loginID);
db1.Read();
// access the datareader within the class
while (db1.dr.Read())
{
character chr1 = new character();
chr1.id = Int32.Parse(db1.dr["id"].ToString());
chr1.hp = Int32.Parse(db1.dr["hp"].ToString());
chr1.mana = Int32.Parse(db1.dr["mana"].ToString());
chr1.owner = owner.loginName;
chr1.stamina = Int32.Parse(db1.dr["stamina"].ToString());
//chr1.tile_on = Int32.Parse(db1.dr["tile_on"].ToString());
chr1.x = Int32.Parse(db1.dr["x"].ToString());
chr1.y = Int32.Parse(db1.dr["y"].ToString());
chr1.name = db1.dr["charactername"].ToString();
list.Add(
chr1
);
}
return list;
}
开发者ID:joelldj,项目名称:ajaxmmo,代码行数:31,代码来源:characterDB.cs
示例4: getquestionorder
//get the order
protected int getquestionorder()
{
int temporder = 0;
SqlDataReader dreader;
SqlCommand findorder = new SqlCommand("select Top 1* from " + quizquestionstable + " where [email protected] order by 'questionorder' Desc");
findorder.Parameters.AddWithValue("quizid", quizId);
db getorder = new db();
dreader = getorder.returnDataReader(findorder);
if (!dreader.HasRows)
{
temporder = 1;
}
else
{
while (dreader.Read())
{
string temporderstr = dreader["questionorder"].ToString();
int itempos = Convert.ToInt32(temporderstr);
temporder = itempos + 1;
}
}
return temporder;
}
开发者ID:sampathN,项目名称:quizgit,代码行数:26,代码来源:addquestion.aspx.cs
示例5: LoadData
protected void LoadData()
{
db dbc = new db();
string query = "SELECT * FROM pages ORDER BY id DESC";
dbc.cmd.CommandText = query;
SqlDataAdapter da = new SqlDataAdapter(dbc.cmd);
DataTable dt = new DataTable();
da.Fill(dt);
PagedDataSource pgitems = new PagedDataSource();
DataView dv = new DataView(dt);
pgitems.DataSource = dv;
pgitems.AllowPaging = true;
pgitems.PageSize = 9;
pgitems.CurrentPageIndex = PageNumber;
if (pgitems.PageCount > 1)
{
rptPages.Visible = true;
ArrayList pages = new ArrayList();
for (int i = 0; i < pgitems.PageCount; i++)
pages.Add((i + 1).ToString());
rptPages.DataSource = pages;
rptPages.DataBind();
}
else
rptPages.Visible = false;
rptContent.DataSource = pgitems;
rptContent.DataBind();
}
开发者ID:nick2il,项目名称:GavanGallery,代码行数:28,代码来源:default.aspx.cs
示例6: bindentries
protected void bindentries()
{
DataTable dTable = new DataTable();
SqlCommand getresponses = new SqlCommand("select id, email, name, correctanswers, wronganswers from " + quizresponsestable + " where [email protected]");
getresponses.Parameters.AddWithValue("quizid", quizId);
db getresponseslist = new db();
dTable = getresponseslist.returnDataTable(getresponses);
if (dTable.Rows.Count > 0)
{
responsesdiv.Visible = true;
responsesrpt.Visible = true;
exportdiv.Visible = true;
lblmessage.Visible = false;
responsesrpt.DataSource = dTable;
responsesrpt.DataBind();
lblmessage.Visible = true;
lblmessage.Text = "Total Entries: " + dTable.Rows.Count.ToString() + "<br />";
}
else
{
responsesdiv.Visible = false;
responsesrpt.Visible = false;
exportdiv.Visible = false;
lblmessage.Visible = true;
lblmessage.Text = "Nothing available at the moment" + "<br /><br />";
}
}
开发者ID:sampathN,项目名称:quizgit,代码行数:31,代码来源:viewresponses.aspx.cs
示例7: Edit
//
// GET: /Product/Edit/5
public ActionResult Edit(int id)
{
var db = new db();
var product = db.Products.SingleOrDefault(x => x.Id == id);
return View(product);
}
开发者ID:r3adm3,项目名称:cSharp-vs2012,代码行数:10,代码来源:ProductController.cs
示例8: deleteUserPicturesFromDB
protected void deleteUserPicturesFromDB(int id)
{
db dbc = new db();
string query = "DELETE FROM pictures WHERE userID = @Id";
dbc.cmd.Parameters.Add(new SqlParameter("Id", id));
dbc.cmd.CommandText = query;
dbc.cmd.ExecuteNonQuery();
}
开发者ID:nick2il,项目名称:GavanGallery,代码行数:8,代码来源:delete.aspx.cs
示例9: AuthWindow
public AuthWindow()
{
InitializeComponent();
DataContext = new db();
// InitAuth();
}
开发者ID:en9ineeeeer,项目名称:TwitterVideoUploader,代码行数:8,代码来源:AuthWindow.xaml.cs
示例10: DeleteInfo
protected void DeleteInfo(int id)
{
db dbc = new db();
string query = "DELETE FROM Info WHERE [email protected]";
dbc.cmd.Parameters.Add(new SqlParameter("Id", id));
dbc.cmd.CommandText = query;
dbc.cmd.ExecuteNonQuery();
}
开发者ID:nick2il,项目名称:GavanGallery,代码行数:8,代码来源:delete.aspx.cs
示例11: UpdatePicture
protected void UpdatePicture(int PictureID, string picname, string description)
{
db dbc = new db();
dbc.cmd.Parameters.Add(new SqlParameter("Name", picname));
dbc.cmd.Parameters.Add(new SqlParameter("Description", description));
dbc.cmd.Parameters.Add(new SqlParameter("PictureID", PictureID));
dbc.cmd.CommandText = "UPDATE pictures SET name = @Name, description = @Description WHERE id = @PictureID";
dbc.cmd.ExecuteNonQuery();
}
开发者ID:nick2il,项目名称:GavanGallery,代码行数:9,代码来源:edit_act.aspx.cs
示例12: SendInfo
protected void SendInfo(string name, string content, string url)
{
db dbc = new db();
string query = "INSERT INTO pages(title, content,url) VALUES(@Name, @Content, @URL)";
dbc.cmd.Parameters.Add(new SqlParameter("Name", name));
dbc.cmd.Parameters.Add(new SqlParameter("Content",content));
dbc.cmd.Parameters.Add(new SqlParameter("URL",url));
dbc.cmd.CommandText = query;
dbc.cmd.ExecuteNonQuery();
}
开发者ID:nick2il,项目名称:GavanGallery,代码行数:10,代码来源:add_send.aspx.cs
示例13: GetLoginID
private int GetLoginID(string username)
{
MMO.db db1 = new db();
/* if not exist, create and then return id */
db1.SetCommand("s_LoginIDGet", CommandType.StoredProcedure);
db1.AddParam<string>("Login", SqlDbType.NVarChar, 50, username);
return Int32.Parse(db1.RunScalar().ToString());
}
开发者ID:joelldj,项目名称:ajaxmmo,代码行数:10,代码来源:loginDB.cs
示例14: UpdateInfo
protected void UpdateInfo(string name, string content,int id)
{
db dbc = new db();
string query = "UPDATE Info SET [email protected], [email protected] WHERE [email protected]";
dbc.cmd.Parameters.Add(new SqlParameter("Name", name));
dbc.cmd.Parameters.Add(new SqlParameter("Content",content));
dbc.cmd.Parameters.Add(new SqlParameter("Id", id));
dbc.cmd.CommandText = query;
dbc.cmd.ExecuteNonQuery();
}
开发者ID:nick2il,项目名称:GavanGallery,代码行数:10,代码来源:edit_act.aspx.cs
示例15: bindquestion
protected void bindquestion()
{
SqlDataReader dreader;
SqlCommand getquestioncmd = new SqlCommand("select id, quizid, type, title from " + quizquestionstable + " where [email protected]");
getquestioncmd.Parameters.AddWithValue("questionid", qId);
db getquestion = new db();
dreader = getquestion.returnDataReader(getquestioncmd);
if (!dreader.HasRows)
{
editquestiondiv.InnerHtml = "<br /><span style='color:#FF0000; font-size:15px;'>Sorry! we could not complete your request at this time. please try again later.</span><br />";
}
else
{
while (dreader.Read())
{
//set the home link
string quizidstr = dreader["quizid"].ToString();
HyperLink homelink = (HyperLink)Master.FindControl("homelnk");
if (homelink != null)
{
homelink.NavigateUrl = "setquestions?q=" + quizidstr;
}
//detect question type and set the template
qtype = dreader["type"].ToString();
if (qtype == "single")
{
singleoptiondiv.Visible = true;
textoptiondiv.Visible = false;
questionstr = dreader["title"].ToString();
txtsingleoption.Text = questionstr;
populateoptions(qId);
}
else if (qtype == "text")
{
singleoptiondiv.Visible = false;
textoptiondiv.Visible = true;
questionstr = dreader["title"].ToString();
txttextoption.Text = questionstr;
txttextoptionanswer.Text = textoptionstr;
}
else
{
//do nothing for time being
}
}
}
}
开发者ID:sampathN,项目名称:quizgit,代码行数:55,代码来源:editquestion.aspx.cs
示例16: FaceSetBrowser
public FaceSetBrowser(String faceSetName, Manager fm, db.TrainingRunInfo modelInfo)
{
InitializeComponent();
faceGridControl1.initColumns(2);
faceGridControl1._fm = fm;
_faces = fm.GetFaceSet(faceSetName);
this.Text = "Face Set: " + faceSetName + ", " + _faces.Count + " faces.";
faceGridControl1.Init(_faces);
_modelInfo = modelInfo;
_fm = fm;
_faceSetName = faceSetName;
}
开发者ID:rwoodley,项目名称:FaceToys,代码行数:12,代码来源:FaceSetBrowser.cs
示例17: form1
private db dba; //-> Persistent database handler objecct in form memory
#endregion Fields
#region Constructors
public form1()
{
InitializeComponent();
try
{
dba = new db();
}
catch(Exception e)
{
MetroFramework.MetroMessageBox.Show(this, "Database Connection Failure: " + e.Message.ToString() , "MySQL Error",
MessageBoxButtons.OK, MessageBoxIcon.Error);
throw;
}
}
开发者ID:mattmarillac,项目名称:pear-app-store,代码行数:20,代码来源:login.cs
示例18: deleteFromPics
protected void deleteFromPics(int pictureID)
{
db dbc = new db();
try
{
string query = "DELETE FROM pictures WHERE id = @PictureID";
dbc.cmd.Parameters.Add(new SqlParameter("PictureID", pictureID));
dbc.cmd.CommandText = query;
dbc.cmd.ExecuteNonQuery();
}
catch
{
Response.Write("ישנה בעיה.");
}
}
开发者ID:nick2il,项目名称:GavanGallery,代码行数:15,代码来源:delete.aspx.cs
示例19: UpdateUser
protected void UpdateUser(string[] data)
{
db dbc = new db();
string query = "UPDATE users SET name = @Name, email = @Email, password = @Password, status = @Status, grade = @Grade WHERE id = @ID";
if(String.IsNullOrEmpty(data[2]) && data[2] == data[3])
query = "UPDATE users SET name = @Name, [email protected], status = @Status, grade = @Grade WHERE id = @ID";
dbc.cmd.Parameters.Add(new SqlParameter("Name", data[0]));
dbc.cmd.Parameters.Add(new SqlParameter("Email", data[1]));
dbc.cmd.Parameters.Add(new SqlParameter("Password", util.hashSalt(data[2])));
dbc.cmd.Parameters.Add(new SqlParameter("Status", data[4]));
dbc.cmd.Parameters.Add(new SqlParameter("Grade", data[5]));
dbc.cmd.Parameters.Add(new SqlParameter("ID", data[6]));
dbc.cmd.CommandText = query;
dbc.cmd.ExecuteNonQuery();
}
开发者ID:nick2il,项目名称:GavanGallery,代码行数:16,代码来源:edit_act.aspx.cs
示例20: deleteComment
protected void deleteComment(int commentID)
{
try
{
db dbc = new db();
string query = "DELETE FROM comments WHERE id = @CommentID";
dbc.cmd.Parameters.Add(new SqlParameter("CommentID", commentID));
dbc.cmd.CommandText = query;
dbc.cmd.ExecuteNonQuery();
}
catch
{
Response.Write("ישנה בעיה..");
}
}
开发者ID:nick2il,项目名称:GavanGallery,代码行数:16,代码来源:delete.aspx.cs
注:本文中的db类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论