这是我的代码:
private void loadlist()
{
comboBox1.Items.Clear();
cn.Open();
cmd.CommandText = "Select * from info";
dr = cmd.ExecuteNonQuery();
if (dr.HasRows)
{
while (dr.Read())
{
comboBox1.Items.Add(dr[0].ToString());
}
cn.Close();
}
}
Run Code Online (Sandbox Code Playgroud)
此行发生错误:
dr = cmd.ExecuteNonQuery();
Run Code Online (Sandbox Code Playgroud)
我在用 System.Data.SqlClient;
和:
SqlConnection cn = new SqlConnection(@"//HERE IS MY STRING CONNECTION");
SqlCommand cmd = new SqlCommand();
SqlDataReader dr;
Run Code Online (Sandbox Code Playgroud) 以下代码不起作用。它不会从TestApp.Config文件中获取应用程序设置。你知道为什么吗?我该如何解决?
public void GetConfig()
{
AppDomain.CurrentDomain.SetData("APP_CONFIG_FILE", @"C:\dev\VS\ProofOfConcept\ProofOfConcept\TestApp.config");
var a = ConfigurationManager.AppSettings;
}
Run Code Online (Sandbox Code Playgroud) 我的代码中有一些错误,由于某种原因,当我试图抓住最后它会抛出错误,说它缺少很多括号,尽管我认为不是.有人可以让我知道我哪里出错了.
码:
namespace login
{
public partial class _Default : Page
{
// decleration of tabels and dataadapters including my connection string for my MySQL databse
DataSet ds = new DataSet();
MySqlConnection cs = new MySqlConnection(@"SERVER= ********;username=******;password=******;Allow Zero Datetime=true; Initial Catalog = benoatsc_GreenFilm");
MySqlDataAdapter da = new MySqlDataAdapter();
DataTable dt = new DataTable();
String totalDonations = string.Empty;
protected void Button1_Click(object sender, EventArgs e)
{
try
{
MySqlCommand SelectCommand = new MySqlCommand("select * from films.user where user_name='" + this.username.Text + "; …Run Code Online (Sandbox Code Playgroud) 我正在转换一些类C#,VB.NET并且此行无法正确转换.我尝试了很少的在线转换器,但它们似乎没有用.
this.mGrid.RowDataBound += new GridViewRowEventHandler(RowDataBoundHandler);
Run Code Online (Sandbox Code Playgroud)
转换后VB.NET不起作用.
Me.mGrid.RowDataBound += New GridViewRowEventHandler(RowDataBoundHandler)
Run Code Online (Sandbox Code Playgroud)
以下是我从中得到的两个错误.任何人都可以帮助我,因为我的大脑已经死了.
谢谢,
Error 4 Delegate 'System.Web.UI.WebControls.GridViewRowEventHandler' requires an 'AddressOf' expression or lambda expression as the only argument to its constructor. C:\My Projects\PMS\App_Code\GridViewHelper.vb 110 62 C:\My Projects\PMS\
Error 3 'Public Event RowDataBound(sender As Object, e As System.Web.UI.WebControls.GridViewRowEventArgs)' is an event, and cannot be called directly. Use a 'RaiseEvent' statement to raise an event. C:\My Projects\PMS\App_Code\GridViewHelper.vb 110 9 C:\My Projects\PMS\
我有一个C#班级(很多行).我想class在我的VB.NET项目中使用它.所以,我尝试将.cs文件添加到我的VB.NET项目中,然后通过以下方式调用它:
MyclassName.VoidName()
它不起作用.
('MycalssName' is not declared. It may be inaccessible due to its protection level.)
我怎样才能C# class在我的VB.NET项目中使用?
我有一个带有a的表单,listView通过调用该showCheckedInFiles()方法填充.当我向表单添加一个简单的按钮并按下它时,该方法完全正常,调用该方法,但是当我从其他地方调用该方法时,它将不会填充我的listview.
请帮助它让我疯狂.下面的第一个方法是从另一个类调用的,它显示在下面,我已经包含了按钮方法以供参考,正如我所说,按钮工作完美,但我需要能够调用方法而不需要单击一个按钮!!:
public void openProject(string projectname)
{
projectName = projectname;
string userDir = CSDBpath + projectname + "\\checkedOUT\\" + userName;
if (!Directory.Exists(userDir)) //Does the user's directory exist, if not, create it
{
Directory.CreateDirectory(userDir);
}
showCheckedInFiles();
}
private void button3_Click(object sender, EventArgs e)
{
showCheckedInFiles();
}
Run Code Online (Sandbox Code Playgroud)
调用上述方法:
private void buttonOpenProject_Click(object sender, EventArgs e)
{
ListView.SelectedListViewItemCollection mySelectedItems;
mySelectedItems = listView1.SelectedItems;
Form1 mainform = new Form1();
string myProject = "";
foreach (ListViewItem item in mySelectedItems)
{
myProject …Run Code Online (Sandbox Code Playgroud) 有人可以提出实现目标的最佳方法吗?
所以,我有一个带有三个按钮的表单.我想要的是,根据按下面板上的按钮应该显示不同的控件(用户控件).我以一种简单的方式做到了这一点:所有都是从头开始添加的,我只是改变了可见性.但更好的是,如果有人能提出更合适的方法,因为不需要从头开始创建对象.
所以基本上发生了什么是我的代码编译并运行良好.但是当它运行时,为minScore和minName变量存储的值保持为0
static void Main(string[] args)
{
int count = 0;
string[] names = new string[MAX_SIZE];
int[] scores = new int[MAX_SIZE];
string name;
int sum = 0;
int minScore = 0;
int maxScore = 0;
string minName = string.Empty;
string maxName = string.Empty;
string input;
int score;
Console.WriteLine("===============Saturday Night Coders================");
Console.WriteLine("===============Bowling Score Program================");
for (int i = 0; i < MAX_SIZE; i++)
{
Console.WriteLine("\n Please Enter a name and a score separated by a space");
Console.WriteLine("Enter a blank line when finished"); …Run Code Online (Sandbox Code Playgroud) 我试图发布无限数量的喜欢,但根据数组中存储的cookie数量来循环cookie和代理.显然,i ++是无法访问的代码.这是什么原因?
public void PostLikes()
{
PostLike postLike = new PostLike();
for (int i =0;i<this.cookies.ToArray().Length;i++)
{
for (int j = 0; ; j++)
{
postLike.PostLike(this.cookies[i], this.importedProxies[i], this.proxyUsernameTextbox, this.proxyPasswordTextbox, this.postsIds[j]);
}
}
}
Run Code Online (Sandbox Code Playgroud) 目前我正在制作一个程序,我想连接到数据库.
我想知道如何使用ADO.NET概念连接数据库.
我生成的步骤很少.请按照以下步骤操作.
生成ValidateModel.edmx(ADO.NET).
生成Windows应用程序表单并尝试调用.
任何人都知道如何连接到SQL Server或某些命令.
我已经尝试连接以使用Microsoft.Practices.EnterpriseLibrary.
但是在创建数据库时会有异常.
private string dbInstance = "testEntities";
try
{
Database db = DatabaseFactory.CreateDatabase(dbInstance);
DbCommand dbCommand = db.GetStoredProcCommand("GetUserNameByUserId");
db.AddInParameter(dbCommand, "@UserId", DbType.String, sPIN);
db.AddOutParameter(dbCommand, "@UserName", DbType.String, 30); //sTechnicianName
sTechnicianName = db.ExecuteScalar(dbCommand).ToString();
}
Run Code Online (Sandbox Code Playgroud)
并具有TypeInitializationException.
App.Config中的testEntities信息设置.
我想在C#中定义一个类.我找到了这两种方法:
方法1:
public class customer
{
private string _name ;
private string _family;
public string Name
{
get { return __name; }
set { if(value=="")message(" ??? ??????? ?? ???? ???? ");
_name= value; }
}
public string Family
{
get { return _family; }
set { if(value=="")message(" ??? ??????? ?? ???? ???? ");
_family= value; }
}
public void AddCustomer()
{
add _name and _family to database
}
}
Run Code Online (Sandbox Code Playgroud)
方法2:
public class customer
{
public void AddCustomer(string name ,string family) …Run Code Online (Sandbox Code Playgroud) 我得到一个错误,说'构造函数文件[string]不可见.当我将我的方法和类声明为公共时,为什么我会得到这个.
package appium1;
import static org.junit.Assert.*;
import org.junit.Test;
import org.openqa.selenium.remote.DesiredCapabilities;
import com.gargoylesoftware.htmlunit.javascript.host.file.File;
import io.appium.java_client.remote.MobileCapabilityType;
import io.appium.java_client.remote.MobilePlatform;
public class desiredcap {
@Test
public void test() {
File appDir = new File("src");
File app = new File(appDir, "BookMyShow.apk");
DesiredCapabilities cap = new DesiredCapabilities();
cap.setCapability(MobileCapabilityType.PLATFORM,MobilePlatform.ANDROID);
cap.setCapability(MobileCapabilityType.DEVICE_NAME, "Android Emulator");
}
}
Run Code Online (Sandbox Code Playgroud)