Click here to Skip to main content
15,891,184 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
Where I have a problem please? Sometimes app show me error with this text message.

Thank you


************** Text výjimky **************
System.Data.OleDb.OleDbException (0x80004005): Nespecifikovaná chyba
   v System.Data.OleDb.OleDbConnectionInternal..ctor(OleDbConnectionString constr, OleDbConnection connection)
   v System.Data.OleDb.OleDbConnectionFactory.CreateConnection(DbConnectionOptions options, DbConnectionPoolKey poolKey, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningObject)
   v System.Data.ProviderBase.DbConnectionFactory.CreateConnection(DbConnectionOptions options, DbConnectionPoolKey poolKey, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection, DbConnectionOptions userOptions)
   v System.Data.ProviderBase.DbConnectionFactory.CreateNonPooledConnection(DbConnection owningConnection, DbConnectionPoolGroup poolGroup, DbConnectionOptions userOptions)
   v System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal oldConnection, DbConnectionInternal& connection)
   v System.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions)
   v System.Data.ProviderBase.DbConnectionClosed.TryOpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions)
   v System.Data.ProviderBase.DbConnectionInternal.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory)
   v System.Data.OleDb.OleDbConnection.Open()
   v LSiMontix.Log.updatelog() v C:\Users\cahafi\Desktop\V2-Solution2\WindowsApplication17\WindowsApplication17\Log.vb:řádek 102
   v LSiMontix.iMontix.Button1_Click(Object sender, EventArgs e) v C:\Users\cahafi\Desktop\V2-Solution2\WindowsApplication17\WindowsApplication17\Form.vb:řádek 537
   v System.Windows.Forms.Control.OnClick(EventArgs e)
   v System.Windows.Forms.Button.OnClick(EventArgs e)
   v System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
   v System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
   v System.Windows.Forms.Control.WndProc(Message& m)
   v System.Windows.Forms.ButtonBase.WndProc(Message& m)
   v System.Windows.Forms.Button.WndProc(Message& m)
   v System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
   v System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
   v System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)


************** Načtená sestavení **************
mscorlib
    Verze sestavení: 4.0.0.0
    Verze Win32: 4.7.3163.0 built by: NET472REL1LAST_C
    Základ kódu (CodeBase): file:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/mscorlib.dll
----------------------------------------
iMontix
    Verze sestavení: 1.0.0.0
    Verze Win32: 1.0.0.0
    Základ kódu (CodeBase): file:///C:/Users/Balen%C3%AD%20NH/Desktop/Debug/iMontix.exe
----------------------------------------
Microsoft.VisualBasic
    Verze sestavení: 10.0.0.0
    Verze Win32: 14.7.3062.0 built by: NET472REL1
    Základ kódu (CodeBase): file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/Microsoft.VisualBasic/v4.0_10.0.0.0__b03f5f7f11d50a3a/Microsoft.VisualBasic.dll
----------------------------------------
System
    Verze sestavení: 4.0.0.0
    Verze Win32: 4.7.3163.0 built by: NET472REL1LAST_C
    Základ kódu (CodeBase): file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System/v4.0_4.0.0.0__b77a5c561934e089/System.dll
----------------------------------------
System.Core
    Verze sestavení: 4.0.0.0
    Verze Win32: 4.7.3163.0 built by: NET472REL1LAST_C
    Základ kódu (CodeBase): file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Core/v4.0_4.0.0.0__b77a5c561934e089/System.Core.dll
----------------------------------------
System.Windows.Forms
    Verze sestavení: 4.0.0.0
    Verze Win32: 4.7.3163.0 built by: NET472REL1LAST_C
    Základ kódu (CodeBase): file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Windows.Forms/v4.0_4.0.0.0__b77a5c561934e089/System.Windows.Forms.dll
----------------------------------------
System.Drawing
    Verze sestavení: 4.0.0.0
    Verze Win32: 4.7.3163.0 built by: NET472REL1LAST_C
    Základ kódu (CodeBase): file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Drawing/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll
----------------------------------------
System.Configuration
    Verze sestavení: 4.0.0.0
    Verze Win32: 4.7.3062.0 built by: NET472REL1
    Základ kódu (CodeBase): file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Configuration/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Configuration.dll
----------------------------------------
System.Xml
    Verze sestavení: 4.0.0.0
    Verze Win32: 4.7.3163.0 built by: NET472REL1LAST_C
    Základ kódu (CodeBase): file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Xml/v4.0_4.0.0.0__b77a5c561934e089/System.Xml.dll
----------------------------------------
System.Runtime.Remoting
    Verze sestavení: 4.0.0.0
    Verze Win32: 4.7.3163.0 built by: NET472REL1LAST_C
    Základ kódu (CodeBase): file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Runtime.Remoting/v4.0_4.0.0.0__b77a5c561934e089/System.Runtime.Remoting.dll
----------------------------------------
System.Data
    Verze sestavení: 4.0.0.0
    Verze Win32: 4.7.3163.0 built by: NET472REL1LAST_C
    Základ kódu (CodeBase): file:///C:/Windows/Microsoft.Net/assembly/GAC_32/System.Data/v4.0_4.0.0.0__b77a5c561934e089/System.Data.dll
----------------------------------------
System.Data.resources
    Verze sestavení: 4.0.0.0
    Verze Win32: 4.7.3062.0 built by: NET472REL1
    Základ kódu (CodeBase): file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Data.resources/v4.0_4.0.0.0_cs_b77a5c561934e089/System.Data.resources.dll
----------------------------------------
System.Windows.Forms.resources
    Verze sestavení: 4.0.0.0
    Verze Win32: 4.7.3062.0 built by: NET472REL1
    Základ kódu (CodeBase): file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Windows.Forms.resources/v4.0_4.0.0.0_cs_b77a5c561934e089/System.Windows.Forms.resources.dll
----------------------------------------
System.Data.DataSetExtensions
    Verze sestavení: 4.0.0.0
    Verze Win32: 4.7.3062.0 built by: NET472REL1
    Základ kódu (CodeBase): file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Data.DataSetExtensions/v4.0_4.0.0.0__b77a5c561934e089/System.Data.DataSetExtensions.dll
----------------------------------------
System.Numerics
    Verze sestavení: 4.0.0.0
    Verze Win32: 4.7.3062.0 built by: NET472REL1
    Základ kódu (CodeBase): file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Numerics/v4.0_4.0.0.0__b77a5c561934e089/System.Numerics.dll
----------------------------------------
mscorlib.resources
    Verze sestavení: 4.0.0.0
    Verze Win32: 4.7.3062.0 built by: NET472REL1
    Základ kódu (CodeBase): file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/mscorlib.resources/v4.0_4.0.0.0_cs_b77a5c561934e089/mscorlib.resources.dll
----------------------------------------
Accessibility
    Verze sestavení: 4.0.0.0
    Verze Win32: 4.7.3062.0 built by: NET472REL1
    Základ kódu (CodeBase): file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/Accessibility/v4.0_4.0.0.0__b03f5f7f11d50a3a/Accessibility.dll
----------------------------------------
System.Transactions
    Verze sestavení: 4.0.0.0
    Verze Win32: 4.7.3163.0 built by: NET472REL1LAST_C
    Základ kódu (CodeBase): file:///C:/Windows/Microsoft.Net/assembly/GAC_32/System.Transactions/v4.0_4.0.0.0__b77a5c561934e089/System.Transactions.dll
----------------------------------------
System.EnterpriseServices
    Verze sestavení: 4.0.0.0
    Verze Win32: 4.7.3062.0 built by: NET472REL1
    Základ kódu (CodeBase): file:///C:/Windows/Microsoft.Net/assembly/GAC_32/System.EnterpriseServices/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.EnterpriseServices.dll
----------------------------------------

************** Ladění JIT **************
Aby bylo povoleno ladění JIT, musí konfigurační soubor
pro tuto aplikaci nebo počítač (machine.config) mít
v oddílu system.windows.forms nastavenou hodnotu njitDebugging.
Aplikace rovněž musí být kompilována s povoleným
laděním.

Příklad:

<configuration>
    <system.windows.forms jitDebugging="true" />
</configuration>

Je-li ladění JIT povoleno, budou všechny neošetřené výjimky
odeslány ladicímu programu JIT, který je registrován v počítači,
a nebudou zpracovány tímto dialogovým oknem.


What I have tried:

I dont known what is wrong. ..........................

here is my code:

VB
Public Shared Sub updatelog()

        Dim formattedDate As String = Date.Today.ToString("dd/MM/yyyy")
        Dim OnlyTime As String = DateTime.Now.ToString("HH:mm:ss")
        Dim cislod As String
        Dim zakazc As String
        Dim stav As String
        Dim ID = iMontix.TextBox6.Text
        Dim kod_operace = iMontix.TextBox8.Text
        Dim smena = iMontix.TextBox5.Text
        Dim provider As String
        Dim dataFile As String
        Dim connString As String
        Dim myConnection As OleDbConnection = New OleDbConnection

        cislod = iMontix.TextBox1.Text
        zakazc = iMontix.TextBox2.Text
        stav = "OK"

        provider = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source ="
        dataFile = "sdf.accdb" ' Change it to your Access Database location
        connString = provider & dataFile
        myConnection.ConnectionString = connString

        myConnection.Open()
        Dim str As String
        str = "INSERT INTO Log ([Číslo dílu], [Zákaznické číslo], [Výsledek], [Datum], [Čas], [ID], [Směna], [Kód operace]) values('" & cislod & "','" & zakazc & "','" & stav & "','" & formattedDate & "','" & OnlyTime & "','" & ID & "','" & smena & "','" & kod_operace & "')"
        Dim cmd As OleDbCommand = New OleDbCommand(str, myConnection)
        cmd.Parameters.Add(New OleDbParameter("Číslo dílu", CType(cislod, String)))
        cmd.Parameters.Add(New OleDbParameter("Zákaznické číslo", CType(zakazc, String)))
        cmd.Parameters.Add(New OleDbParameter("Výsledek", CType(stav, String)))
        cmd.Parameters.Add(New OleDbParameter("Datum", CType(formattedDate, String)))
        cmd.Parameters.Add(New OleDbParameter("Čas", CType(OnlyTime, String)))
        cmd.Parameters.Add(New OleDbParameter("ID", CType(ID, String)))
        cmd.Parameters.Add(New OleDbParameter("Směna", CType(smena, String)))
        cmd.Parameters.Add(New OleDbParameter("Kód operace", CType(kod_operace, String)))
       
        cmd.ExecuteNonQuery()
        cmd.Dispose()
        myConnection.Close()        
    End Sub
Posted
Updated 9-Oct-18 8:15am
v3

str = "INSERT INTO Log ([Číslo dílu], [Zákaznické číslo], [Výsledek], [Datum], [Čas], [ID], [Směna], [Kód operace]) values('" & cislod & "','" & zakazc & "','" & stav & "','" & formattedDate & "','" & OnlyTime & "','" & ID & "','" & smena & "','" & kod_operace & "')"
Dim cmd As OleDbCommand = New OleDbCommand(str, myConnection)
cmd.Parameters.Add(New OleDbParameter("Číslo dílu", CType(cislod, String)))
cmd.Parameters.Add(New OleDbParameter("Zákaznické číslo", CType(zakazc, String)))
cmd.Parameters.Add(New OleDbParameter("Výsledek", CType(stav, String)))
cmd.Parameters.Add(New OleDbParameter("Datum", CType(formattedDate, String)))
cmd.Parameters.Add(New OleDbParameter("Čas", CType(OnlyTime, String)))
cmd.Parameters.Add(New OleDbParameter("ID", CType(ID, String)))
cmd.Parameters.Add(New OleDbParameter("Směna", CType(smena, String)))
cmd.Parameters.Add(New OleDbParameter("Kód operace", CType(kod_operace, String)))

That's not how parameters work. You're still concatenating the parameter values directly into the query, which leaves your code vulnerable to SQL Injection.

Your query should contain parameter placeholders instead. For MS Access, that's the ? character:
str = "INSERT INTO Log ([Číslo dílu], [Zákaznické číslo], [Výsledek], [Datum], [Čas], [ID], [Směna], [Kód operace]) values(?, ?, ?, ?, ?, ?, ?, ?)"

The rest of the code remains the same. The parameter names don't matter; you just need to make sure you add them in the same order as they appear in the command text.

Once you've fixed that, you'll probably find that it fixes your "unspecified error" too.

Everything you wanted to know about SQL injection (but were afraid to ask) | Troy Hunt[^]
How can I explain SQL injection without technical jargon? | Information Security Stack Exchange[^]
Query Parameterization Cheat Sheet | OWASP[^]
 
Share this answer
 
"Unspecified error" means pretty much just that.

Basically, there is something wrong with your SQL query, and that means you need to look at the code that is controlling SQL, and probably at your data as well.

We can't do that for you: we have access to neither of those!

So, it's going to be up to you.
Fortunately, you have a tool available to you which will help you find out what is going on: the debugger. If you have no idea how to use it, then a quick Google for the "Visual studio debugger" should give you the info you need.

Put a breakpoint on the first line in the function, and run your code through the debugger. Then look at your code, and at your data and work out what should happen manually. Then single step each line checking that what you expected to happen is exactly what did. When it isn't, that's when you have a problem, and you can back-track (or run it again and look more closely) to find out why.

Sorry, but we can't do that for you - time for you to learn a new (and very, very useful) skill: debugging!
 
Share this answer
 
Comments
[no name] 5-Oct-18 3:30am    
Debug is ok application running but sometimes unexpectedly show me this error.
OriginalGriff 5-Oct-18 3:47am    
Then you need to either run it under the debugger until it does, and then look at exactly where, or cover your app with logging statements to let you do a post-crash analysis and identify the area it is crashing in. you can then refine your loggin until you have an idea of the conditions it crashes under.

But we can't do any of that for you - we can't run your code at all, much less duplicate the conditions under which it crashes!
[no name] 5-Oct-18 11:11am    
ok, thank you for answer :)
OriginalGriff 5-Oct-18 11:34am    
You're welcome!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900