我想连接到我的GuvenliBilgisayarim数据库.但是baglanti为空 - 为什么?
我的代码是:
SqlConnection baglanti = new SqlConnection("Data Source=DILEKZ\\SQLEXPRESS;Initial Catalog=GuvenliBilgisayarim;Integrated Security=True");
private void btn_giris_Click(object sender, EventArgs e)
{
baglanti.Open();
SqlCommand komut = new SqlCommand("select * from Login where kullanici_adi='" + txt_kulAdi.Text + " and kullanici_sifre=" + txt_sifre.Text +"',baglanti");
komut.Connection = baglanti;
SqlDataReader dr = komut.ExecuteReader();
if (dr.Read())
{
Rapor rpr = new Rapor();
rpr.Show();
}
else
{
MessageBox.Show("Kullan?c? ad? veya ?ifre yanl??");
}
dr.Close();
}
Run Code Online (Sandbox Code Playgroud) 如何使用聚合运算符转换linq查询输出并将不同的输出显示到列表?
这是我存储在DB中的内容,它是通过linq查询提取的:
Date Hours
07/29/2013 1.3
07/29/2013 2.0
07/30/2013 3.1
07/31/2013 0.1
07/31/2013 5.2
08/01/2013 1.1
08/01/2013 1.1
08/01/2013 2.2
08/02/2013 3.3
08/02/2013 4.0
08/03/2013 2.1
Run Code Online (Sandbox Code Playgroud)
这是我想要的数据:
Day Hours
07/29/2013 3.3
07/30/2013 3.1
07/31/2013 5.3
08/01/2013 4.4
08/02/2013 7.3
08/03/2013 2.1
Run Code Online (Sandbox Code Playgroud)
任何帮助深表感谢
我在创建错误处理方法时遇到了一些问题.遇到错误后,sub继续,好像什么也没发生.这就是我所拥有的:
try
{
int numericID = Convert.ToInt32(titleID);
}
catch(Exception)
{
errorHandling("Invalid Title");
}
void errorHandling(string error)
{
MessageBox.Show("You have encountered an error: " + error, "Error");
return;
}
Run Code Online (Sandbox Code Playgroud)
提前致谢!
在我的程序中,我需要在字符串中添加一个字符,然后在控制台上打印它.在我的情况下,数字将不会始终相同,但总是有2个字符.我需要在中间位置添加','但我不知道如何.(我是初学者,请发布示例代码).一个例子是,我想把"25"改为"2,5".谢谢你的帮助.[对不起英语不好,标题也可能很糟糕/误导]
我试图让一个类继承一个带有通用属性的抽象类。我想我错过了一些真正重要的东西。我可以摆脱这个错误的唯一方法是摆脱基类中的构造函数。但如果我这样做的话,我的班级就会缺乏目标。
错误
错误 CS7036 没有给出与所需的形式参数“propA”相对应的参数...
基类
public abstract class BaseClass<T> where T:class
{
public string propA{ get; set; }
public int propB{ get; set; }
public IEnumerable<T> propC { get; set; }
public BaseClass(string propA, int propB, IEnumerable<T> propC)
{
this.propA = propA;
this.propB = spropB;
this.propC = propC;
}
public abstract IEnumerable<T> Method1();
public abstract string Method2();
public abstract void Method3();
}
Run Code Online (Sandbox Code Playgroud)
派生类
public class DerivedClass: BaseClass<SomeClass>
{
public override IEnumerable<SomeClass> Method1()
{
//Code Here
}
public override string …Run Code Online (Sandbox Code Playgroud) 我的代码遇到了一些问题.
这是我的数据库类中的方法
public void editproduct(string a, int b, int c)
{
conn.Open();
SqlCommand command = new SqlCommand("UPDATE Productdescription SET pdescription = '" + a + "',Price = " + b + " WHERE pid = " + c + ")", conn);
command.ExecuteNonQuery();
conn.Close();
}
Run Code Online (Sandbox Code Playgroud)
我尝试用我的按钮在这里执行它.
private void button1_Click(object sender, EventArgs e)
{
Database db = new Database();
db.editproduct(textBox1.Text, Convert.ToInt32(textBox2.Text), Convert.ToInt32(textBox3.Text));
}
Run Code Online (Sandbox Code Playgroud)
但我得到这个错误::
See the end of this message for details on invoking
just-in-time (JIT) debugging instead of this dialog box. …Run Code Online (Sandbox Code Playgroud) 我有这门课:
public class Person
{
public String name;
public int score;
public float multiplier;
public Person(String nameID)
{
name = nameID;
score = 0;
multiplier = 1.0f;
}
}
Run Code Online (Sandbox Code Playgroud)
我有一个包含这些类的List:
private List<Person> _people;
Run Code Online (Sandbox Code Playgroud)
有什么方法可以使用这个名字得分吗?
_people.GetScore("example name"); // return the score of the class containing that name?
Run Code Online (Sandbox Code Playgroud) 我有一个这样的简单模型:
public class AssignStatisticsModel
{
public string TasksName { get; set; }
public int Time { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
我想创建四个对象,如:
List<AssignStatisticsModel> textModels = new List<AssignStatisticsModel>();
AssignStatisticsModel textmodel = new AssignStatisticsModel();
textmodel.TasksName = "Progress to Back Check";
textModels.Add(textmodel);
textmodel.TasksName = "Back Check to Corrections";
textModels.Add(textmodel);
textmodel.TasksName = "Corrections to Completed";
textModels.Add(textmodel);
textmodel.TasksName = "Progress to Completed";
textModels.Add(textmodel);
Run Code Online (Sandbox Code Playgroud)
但由于某些原因,所有TasksNames叫"Progress to Completed",而不是创建一个与每个TasksName我补充道.为什么最后 textModels.Add(textmodel);用相同的四个物体替换TasksName?
考虑以下函数。我是用C#写的。
public void Test()
{
statement1;
try
{
statement2;
}
catch (Exception)
{
//Exception caught
}
}
Run Code Online (Sandbox Code Playgroud)
statement1我只想在没有引起异常的情况下执行statement2。是否可以statement1只在statement2 不抛出任何异常的情况下执行?
我有以下Graphql类型类,包括POCO类:Order.cs.
在这里,我想设置每个字段的默认值.例如,Name我想返回"No Name",以防没有返回值.如果是Created,我想默认返回今天的日期.
public class OrderType : ObjectGraphType<Order>
{
public OrderType(ICustomerService customers)
{
Field(o => o.Id);
Field(o => o.Name);
Field(o => o.Description);
Field(o => o.Created);
}
}
public class Order
{
public Order(string name, string description, DateTime created, string Id)
{
Name = name;
Description = description;
Created = created;
this.Id = Id;
}
public string Name { get; set; }
public string Description { get; set; }
public DateTime Created { get; private …Run Code Online (Sandbox Code Playgroud)