根据下面的代码,我收到以下消息.我很确定"为什么"我得到它,我只是不知道如何重新排列代码来移动/删除/替换其中一个错误导致语句.
"使用/ main编译以指定包含入口点的类型."
在"static void Main(string [] args)"下面有一堆代码,我从 http://support.microsoft.com/kb/816112 得到的目的是为了从自动增量获取ID,所以当其余代码填充Access数据库时,我可以自动增加它.任何帮助表示赞赏.我们也欢迎使用更简单的代码获得结果的建议!
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
OleDbConnection vcon = new OleDbConnection(@"Provider=Microsoft.ACE.OLEDB.12.0;data source=C:\Hazardous Materials\KinneyDatabase.accdb");
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
vcon.Open();
try
{
StreamReader sr = new StreamReader(@"C:\Hazardous Materials\cities.txt");
string line = sr.ReadLine();
StreamReader sr2 = new StreamReader(@"C:\Hazardous Materials\drugs.txt");
string line2 = sr2.ReadLine();
StreamReader sr3 = new StreamReader(@"C:\Hazardous Materials\strengths.txt");
string line3 = sr3.ReadLine();
while (line != null)
{
comboBox1.Items.Add(line); …Run Code Online (Sandbox Code Playgroud) 我收到错误:
"输入字符串的格式不正确."
注意:如果我将第182行更改为引号中的实际数字(即"3"或"875"),并注释掉第171行,则此代码可以正常工作.但是,第174行中的"{7}"是一个应该自动递增的字段,但不会.所以我试图在第171行得到一个"数字",它将使用行数+ 1来进行auto- =增量.
这个上有任何人吗?:-)
171 string rowCount = string.Format("SELECT COUNT(*) FROM Log WHERE Location is NULL");
173 string sql = string.Format("insert into Log values " +
174 "('{0}','{1}',{2},{3},'{4}',#{5}#,'{6}','{7}')",
175 comboBox1.Text,
176 comboBox2.Text,
177 float.Parse(textBox1.Text),
178 float.Parse(comboBox3.Text),
179 textBox3.Text,
180 textBox2.Text,
181 addRemove,
182 int.Parse(rowCount)
183 );
Run Code Online (Sandbox Code Playgroud)