Odbc error code 42000



Odbc error code 42000

This forum has migrated to Microsoft Q&A. Visit Microsoft Q&A to post new questions.

Answered by:

Question

When i tried to setup an ODBC data source to a text file the connection and read the file perfectly.

when tried to set up an ODBC data source other then text file (Eg. *.p06), I am reciving an error that says, ‘ERROR [42000] [Microsoft][ODBC Text Driver] Cannot update. Database or object is read-only.’.

I read some where this is a security feature of the Microsoft Jet ODBC Text driver. The ODBC driver only allows you to read files with the following extensions txt, csv, tab, asc, htm, html.

My question is: How can fix the ODBC issue if I want to process the file with extension file (Eg. *.p06).

Quick reply is appreciable.

a) I have tried below way to fix the issue but no luck.

I have tried below changes as suggested some other blug. but below solution did not fix the issue either.

1. Start the registry editor (regedit.exe).

2. Navigate to the HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced registry subkey.

3. Double-click HideFileExt and set it to 1 to hide known file extensions.

Источник

Odbc error code 42000

This is my first tutorial using Stored Procedure in VB.Net

Sub Main()
ProductsProcs()
End Sub

‘ Products Stored Procs to be added to the db.
Sub ProductsProcs()
Dim sSQL As String

‘ procAddRumahLokasi — Add record to the Rumah_Bancian table
sSQL = «CREATE PROC procAddRumahLokasi (inNoKPKIR varchar(12), inKodNeg varchar(2), inKodPar varchar(3), inKodDun varchar(2), inKodDae varchar(2), inStatusLokasi varchar(50), inGPSNorth varchar(50), inGPSEast varchar(50), inAlamat1 varchar(50), inAlamat2 varchar(50), inAlamat3 varchar(50), inPoskod varchar(50), inBandar varchar(50), inNegeri varchar(50))» & _
» AS INSERT INTO Rumah_Bancian (NoKPKIR, KodNegeri, KodParlimen, KodDun, KodDaerah, StatusLokasi, GPSNorth, GPSEast, Alamat1, Alamat2, Alamat3, Poskod, Bandar, Negeri) » & _
» Values (inNoKPKIR, inKodNeg, inKodPar, inKodDun, inKodDae, inStatusLokasi, inGPSNorth, inGPSEast, inAlamat1, inAlamat2, inAlamat3, inPoskod, inBandar, inNegeri);»
CreateStoredProc(sSQL)
End Sub

Читайте также:  Vba on error debug

‘ Execute the creation of Stored Procedures
Sub CreateStoredProc( ByVal sSQL As String )
Dim conn As OdbcConnection
Dim cmd As OdbcCommand = New OdbcCommand

conn = New OdbcConnection(sConStr)
cmd.Connection = conn
cmd.CommandText = sSQL

conn.Open()
cmd.ExecuteNonQuery()
conn.Close()
End Sub

the codes seem ok to me, since i do refer it from an online tutorial. but when i run, it generate me this error;

ERROR [42000] [Microsoft][ODBC Microsoft Access Driver]Syntax error or access violation

what should i do?
any help will be highly appreciated..

Источник

Odbc error code 42000

Answered by:

Question

getting this error when storing the data in a database.

ERROR [42000] [Microsoft][ODBC Microsoft Access Driver] Syntax error (missing operator) in query expression

Answers

String values need to be enclosed by a delimiter:

«INSERT INTO LoginDB (Name, UserName, . ) VALUES (‘name’, ‘username’)»

But your code is vulnarable to SQL injection:

Also note that you better use OleDb instead of ODBC to connect to Access

In Jet. Password is a reserved word, and should be enclosed in brackets when used as a fieldname:

«INSERT INTO loginDB (Name, . [Password]. . )»

And instead of reinventing the wheel by creating your own login system, you can use formsauthentication as well

Источник

42000 Error ODBC driver for Oracle Syntax error or access violation

I have a simple Oracle stored procedure:

CREATE OR REPLACE procedure DEV.SL_CLOB_TEST(numId1 IN PLS_INTEGER,id IN PLS_INTEGER, strText IN CLOB)
as
begin
insert into test_table
values (numId1,id, strText, sysdate, user);
end;
/

And I have a client .net code to use ODBC.NET

class Program
<
static void Main(string[] args)
<
string connectionString = «Driver=;Server=servername;Uid=myusername;Pwd=mypassword»;
var connection = new OdbcConnection(connectionString);
connection.Open();

Читайте также:  Error system fan has failed f2 как убрать

IDbCommand command = connection.CreateCommand();

command.CommandText = ««;
command.CommandType = CommandType.StoredProcedure;

OdbcParameter parameter1 = new OdbcParameter(«NUMID1», OdbcType.Int);
parameter1.Value = 123;
parameter1.Direction = ParameterDirection.Input;
command.Parameters.Add(parameter1);

OdbcParameter parameter2 = new OdbcParameter(«ID», OdbcType.Int);
parameter2.Value = 234;
parameter2.Direction = ParameterDirection.Input;
command.Parameters.Add(parameter2);

OdbcParameter parameter3 = new OdbcParameter(«STRTEXT», OdbcType.VarChar);
parameter3.Value = getClob();
parameter3.Direction = ParameterDirection.Input;
command.Parameters.Add(parameter3);

private static string getClob()
<
return new string(‘a’, 10);
>
>

When I ran it I got ERROR [42000] [Microsoft][ODBC driver for Oracle]Syntax error or access violation, the whole call stack is

System.Data.Odbc.OdbcException was unhandled
Message=ERROR [42000] [Microsoft][ODBC driver for Oracle]Syntax error or access violation
Source=msorcl32.dll
ErrorCode=-2146232009
StackTrace:
at System.Data.Odbc.OdbcConnection.HandleError(OdbcHandle hrHandle, RetCode retcode)
at System.Data.Odbc.OdbcCommand.ExecuteReaderObject(CommandBehavior behavior, String method, Boolean needReader, Object[] methodArguments, SQL_API odbcApiMethod)
at System.Data.Odbc.OdbcCommand.ExecuteReaderObject(CommandBehavior behavior, String method, Boolean needReader)
at System.Data.Odbc.OdbcCommand.ExecuteNonQuery()
at ConsoleApplication1.Program.Main(String[] args) in \Temp\ConsoleApplication1\ConsoleApplication1\Program.cs:line 32
at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
InnerException:

Anybody could point out what is wrong with my .Net code?

Источник

Odbc error code 42000

This is my first tutorial using Stored Procedure in VB.Net

Sub Main()
ProductsProcs()
End Sub

‘ Products Stored Procs to be added to the db.
Sub ProductsProcs()
Dim sSQL As String

‘ procAddRumahLokasi — Add record to the Rumah_Bancian table
sSQL = «CREATE PROC procAddRumahLokasi (inNoKPKIR varchar(12), inKodNeg varchar(2), inKodPar varchar(3), inKodDun varchar(2), inKodDae varchar(2), inStatusLokasi varchar(50), inGPSNorth varchar(50), inGPSEast varchar(50), inAlamat1 varchar(50), inAlamat2 varchar(50), inAlamat3 varchar(50), inPoskod varchar(50), inBandar varchar(50), inNegeri varchar(50))» & _
» AS INSERT INTO Rumah_Bancian (NoKPKIR, KodNegeri, KodParlimen, KodDun, KodDaerah, StatusLokasi, GPSNorth, GPSEast, Alamat1, Alamat2, Alamat3, Poskod, Bandar, Negeri) » & _
» Values (inNoKPKIR, inKodNeg, inKodPar, inKodDun, inKodDae, inStatusLokasi, inGPSNorth, inGPSEast, inAlamat1, inAlamat2, inAlamat3, inPoskod, inBandar, inNegeri);»
CreateStoredProc(sSQL)
End Sub

Читайте также:  Error while opening the virtual machine vmx file is corrupt что делать

‘ Execute the creation of Stored Procedures
Sub CreateStoredProc( ByVal sSQL As String )
Dim conn As OdbcConnection
Dim cmd As OdbcCommand = New OdbcCommand

conn = New OdbcConnection(sConStr)
cmd.Connection = conn
cmd.CommandText = sSQL

conn.Open()
cmd.ExecuteNonQuery()
conn.Close()
End Sub

the codes seem ok to me, since i do refer it from an online tutorial. but when i run, it generate me this error;

ERROR [42000] [Microsoft][ODBC Microsoft Access Driver]Syntax error or access violation

what should i do?
any help will be highly appreciated..

Источник

Оцените статью
toolgir.ru
Adblock
detector