当前位置: 动力学知识库 > 问答 > 编程问答 >

vb.net - Code Stopping when Opening an Oledbconnection

问题描述:

Running the following code, my program just will not get past the 'connection.Open()' line in this sub. I had a similar problem before where I was using a datareader when it was not needed, but in this sub I am not doing anything like that, merely opening a connection to the database. I can't figure out what I am doing wrong here, especially as there are no errors or anything.

Using connection As New OleDbConnection(connectionstring)

connection.Open()

Dim Command As New OleDbCommand("SELECT SUM(Price) FROM ItemsSold", conection)

Dim Command2 As New OleDbCommand("SELECT SUM(TotalCost) FROM Inventory", connection)

Dim Turnover As Double = Convert.ToDouble(Command.ExecuteScalar())

Dim Cost As Double = Convert.ToDouble(Command2.ExecuteScalar())

lblProfit.Text = "Profit: £" & (Turnover - Cost)

connection.Close()

End Using

网友答案:

Ah, I replaced the app.config file with a fresh one and the program now works perfectly fine once more. Thanks for your help!

分享给朋友:
您可能感兴趣的文章:
随机阅读: