Question about Microsoft Compilers & Programming Tools

1 Answer

Use vb.net and access

I m Trying to insert picture into access database using oledb parameters but it will not add the picture in access database
the Code like this
Dim FileName As String
Dim FileStream1 As System.IO.FileStream
Dim FileInfo1 As System.IO.FileInfo
Dim o As System.IO.FileStream
Dim sr As System.IO.StreamReader
Dim gifFile As String
Console.Write(p1)
gifFile = Console.ReadLine
On Error Resume Next
o = New System.IO.FileStream(p2, IO.FileMode.CreateNew)
On Error Resume Next
sr = New System.IO.StreamReader(o) Dim FileByteArray(o.Length - 1) As Byte
o.Read(FileByteArray, 0, o.Length)
Dim Con As New System.Data.OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.3.51;Persist Security Info=False;Data Source=C:\Project\WindowApplication1\Parana.mdb")
Dim Sql As String = "INSERT INTO DRAWING (D_A,FileSize) VALUES (?,?)"
Dim Cmd As New System.Data.OleDb.OleDbCommand(Sql, Con)
Cmd.Parameters.Add("@D_A", System.Data.OleDb.OleDbType.Binary, o.Length).Value = FileByteArray
Cmd.ExecuteNonQuery()
Console.Write(p1)
here p1 and p2 is string variable thet contain file path.
What is the problem inthis code,
plz, reply me as soon as possible
b'cos i m working on this project it's my big problem for developing the software.

thanks,
regards
from
manisha

Posted by on

1 Answer

  • Level 1:

    An expert who has achieved level 1.

  • Contributor
  • 3 Answers

Imports System
Imports System.IO
Imports System.Data
Public Class SaveImage
Shared Sub main()
Dim o As System.IO.FileStream
Dim r As StreamReader
Dim gifFile As String
Console.Write("Enter a Valid .Gif file path")
gifFile = Console.ReadLine
If Dir(gifFile) = "" Then
Console.Write("Invalid File Path")
Exit Sub
End If
o = New FileStream(gifFile, FileMode.Open, FileAccess.Read, FileShare.Read)
r = New StreamReader(o)
Try
Dim FileByteArray(o.Length - 1) As Byte
o.Read(FileByteArray, 0, o.Length)
Dim Con As New _ System.Data.OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.3.51;Persist Security Info=False;Data
Source=Test.mdb")
Dim Sql As String = "INSERT INTO images (Pic,FileSize) VALUES (?,?)"
Dim Cmd As New System.Data.OleDb.OleDbCommand(Sql, Con)
Cmd.Parameters.Add("@Pic", System.Data.OleDb.OleDbType.Binary, o.Length).Value = FileByteArray
Cmd.Parameters.Add("@FileSize", System.Data.OleDb.OleDbType.VarChar, 100).Value = o.Length
Con.Open()
Cmd.ExecuteNonQuery()
Con.Close()
Catch ex As Exception
Console.Write(ex.ToString)
End Try
End Sub
End Class

Posted on Jul 17, 2008

  • keshav sambyal Jul 17, 2008

    --- Insert Image in Ms-Access ----

    objConnection = New OleDbConnection(objConnectionString)
    objConnection.Open

    Dim content As Byte() = ReadBitmap2ByteArray(ImagePath)

    SqlQuery = "Update ImgTable Set Img=? Where ImgTableID = 1"

    Dim objInsert As OleDbCommand = New OleDbCommand(SqlQuery, objConnection)

    Dim objParam As OleDbParameter = objInsert.Parameters.Add("@Barcode", OleDbType.Binary)

    objParam.Value = content
    objParam.Size = content.Length

    objInsert.ExecuteNonQuery

    objConnection.Close


×

Add Your Answer

Uploading: 0%

my-video-file.mp4

Complete. Click "Add" to insert your video. Add

×

Loading...
Loading...

Related Questions:

1 Answer

How to insert datepicker value in access with use of C#


1.U have to create one acess database .
2 create connection to database using odbc or oledb connection.
3.Write one insert query.
4 execute that query.
5.close the connection

Nov 16, 2009 | Microsoft Visual Basic .NET Standard 2003...

1 Answer

Developing an application with vb.net 2008 and i'm finding it


You need to set up an ODBC DSN and use this in your connection string then instantiate an ODBC connection. For example:

Dim MyConnectionString As String = "Driver={MySQLDSN};SERVER=localhost;DATABASE=MySQLDatabase;" '
Dim conn As New OdbcConnection(connectionString)
conn.Open()
Dim da As New OdbcDataAdapter("SELECT * FROM Customers", conn)
Dim ds As New DataSet()
da.Fill(ds, "Customers")
dataGrid1.DataSource = ds.DefaultViewManager
conn.Close()

Sep 04, 2009 | Microsoft Compilers & Programming Tools

1 Answer

How can i save the data inputted from a textbox to the recordset or to its table in MS Access?


If you want to save it in MS Access, you need an OLEDB Connection.

You need to declare few arguments first to accomplish your tast like, OLEDB Connection String, Connection, Data Adapter....

I'll write a simple program to show you.
---------------------------------------------------------------------------
Const cn As String = "Provider=Microsoft.Jet.OLEDB.4.0;" & "data source=path of Access file(2003) where you want to save input data.mdb;"

Dim conn As New oledb.OleDbConnection(cn)

Dim objda As New oledb.OleDbDataAdapter

Dim cmd as string = "insert into login (loginid,pass) values('" & TextBox1.Text & "')"

conn.Open()

objda.InsertCommand = New OleDbCommand(sql, conn)

objda.SelectCommand.ExecuteNonQuery()

conn.Close()
----------------------------------------------------------------------

Copy and paste the above source code, and then tell me what happens.
If you got any more quries, don't hesitate to ask.

And If I was helpful, Kindly do Rate!
Regards,
Waqar.


Sep 03, 2009 | Microsoft Visual Basic 6.0 for PC

1 Answer

Runtime error 2147467259 (80004005) in VB


either the database is in the wrong directory or it doesnt exist

Aug 05, 2009 | Microsoft Visual Basic Enterprise Edition...

2 Answers

Free visual basic source code salary database sample


you solution is her



Building Websites with VB.NET and DotNetNuke 4/by Daniel N. Egan (Author), Steve Valenzuela (Author), Michael Washington (Author)
Description
DotNetNuke is an open-source Content Management System and web application framework. DotNetNuke has taken the Microsoft world by storm and now at version 4, its community has grown to over 200,000 users. This book covers virtually everything you need to know to get your DotNetNuke website up and running. Concisely written and with clear explanations, this book is covers installation, administration, deployment, site creation and all of the basic built in DotNetNuke modules. For developers, chapters on the core architecture, skinning and custom modules, including coverage of the DAL+, give you the skills to customize and extend your site. The book starts off by giving you a deep understanding of working with basic DotNetNuke sites, guiding you through the features and giving you the confidence to create and manage your site. After that, you will journey to the heart of DotNetNuke, and learn about its core architecture. Always concise, relevant and practical, you will find out what makes DotNetNuke tick, and from there, you will be ready to customize DotNetNuke. Developers will enjoy the detailed walkthrough of creating a new custom modules. Special emphasis is given to the DAL+, an extended feature set of the DotNetNuke Data Access Layer (DAL). You will see how to create custom modules with the DAL+, and invigorate your module development. Web designers will enjoy the material on skinning, helping them to create a new look for their site. You will learn about creating new skins, and packaging them up for easy deployment. You will master all of this as you leap into the development of a DotNetNuke 4 site. This book will give you the skills to create and manage DotNetNuke websites as quickly as possible. You will:
* Install and configure DotNetNuke
* Master the standard modules
* Understand the core architecture of DotNetNuke
* Explore the inner workings of DotNetNuke modules
* Extend DotNetNuke using the DAL and DAL+ to create powerful custom modules
* Create your own skin using a HTML Editor
* Find out about where and how to host and deploy your site
You can use this book to help you set up and administer a DotNetNuke portal, even if you have a limited knowledge of ASP.NET. You will learn how to setup and administer an example site, stepping through all the tasks to ease your learning. If you are a developer, this book will help you extend the DotNetNuke portal by first helping you understand how the core framework works and then show you how to create custom modules and skins. A rudimentary knowledge of VB.NET programming is assumed, but the emphasis is not on becoming a better VB.NET programmer but on taming DotNetNuke. This book has been written for both the beginner wanting to set up a website and also ASP.NET developers with a grasp of VB.NET who want a deeper understanding of how to work with DotNetNuke. To work with the DotNetNuke code, you will need access to Visual Web Developer Express or Visual Studio .NET 2005. No prior knowledge of DotNetNuke is assumed.

download link:
http://w14.easy-share.com/1701584071.html
or:
http://dep

May 03, 2009 | Microsoft Visual Basic Enterprise Edition...

1 Answer

Retrieving acess data which is password protected thru VB


You will need to use a connection string. But - before you can configure the string correctly, I'd need to know how the data is stored (Access, SQL, ODBC, etc). You can find examples online. Just know that you are looking for "Connection String." Here's two examples:
1. For MS Access (Jet files):
' Set up the connection string.
m_strConn = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & strDestDBPath & ";" & _
"Jet OLEDB:Engine Type=5" ' NOTE: Use Type=5 for Jet 4.x.

2. For SQL database:
g_strADOConn = "Provider=SQLOLEDB;" & _
"Data Source=SERVER_NAME;" & _
"Initial Catalog=DATABASE_NAME;" & _
"User ID=mssql_userid;" & _
"Password=mssql_password;"

Apr 22, 2009 | Microsoft Visual Basic 6.0 for PC

1 Answer

I can't add data in the database using vb


Hi,
The database can be any like oracle.

Two type of connection u can make.
One of such connection is ADODB

The code is like

Dim ors As ADODB.Recordset
Dim oconn As Connection
Dim Qry as String
dim Qry1 as string
Set ors = New ADODB.Recordset
Set oconn = New ADODB.Connection
Chk_selectall.Visible = False

oconn.Open "Provider=MSDAORA.1;" & "user id = " & Username & _
";password = " & Password & ";data source = " & Conn_string _
& ";Persist Security Info=True"

Qry = "insert into table1 values (100,'we')"

oconn.execute "Qry"

If u select any data then u ve to use
Qry1 = "select * from table1"

ors.open "Qry1",oconn

do until ors.EOF

msgbox ors(0) & "," & ors(1)

ors.movenext;

loop

Mar 17, 2009 | Microsoft Visual Basic 6.0 for PC

1 Answer

I want to add a calendr in my vb form when i clicked on perticular date that gies me the report which already stored in my database which has stored how many person are entered on perticular date please...


I suggest you this URL:
http://www.codeproject.com/
You will get your answers there simply. This websit eis the source of .NET programming like C#, VB, J#, ASP and ....
enjoy it!

Jan 21, 2009 | Microsoft Visual Basic 6.0 for PC

1 Answer

Vb 6.0 ado connection without ado control moving next record


I see 2 problems with your code.

1) Each time you call cmdnext_Click, you're reopening the database. Each time you do that, you start at the beginning of the file. You need to have the database opened once, somewhere else in your program. Be sure that the record set is visible from this sub.

2) In order to use the "Next" function, you need a loop like this

'test for no records
IF REC.BOF and REC.EOF then
msgbox "No Records Found"
exit sub
end if

IF NOT REC.EOF then
REC.MoveNext
(display your fields)
END IF


Again, this will only work if your database is opened outside of the cmdNext_Click routine.

Jul 08, 2008 | Microsoft Compilers & Programming Tools

1 Answer

Bde error


Different versions of Access use and make different DBE's. Check the versions when using VB to access this database. Sometimes u have to load the proper drivers in VB to access this databases.

Mar 05, 2008 | Compilers & Programming Tools

Not finding what you are looking for?
Compilers & Programming Tools Logo

Related Topics:

286 people viewed this question

Ask a Question

Usually answered in minutes!

Top Microsoft Compilers & Programming Tools Experts

Robin Hill
Robin Hill

Level 3 Expert

1251 Answers

Alex Krenvalk

Level 2 Expert

401 Answers

Brian Sullivan
Brian Sullivan

Level 3 Expert

27725 Answers

Are you a Microsoft Compiler and Programming Tool Expert? Answer questions, earn points and help others

Answer questions

Manuals & User Guides

Loading...