Dear Brothers & Sisters,
Please, I 'm using vb 2008 and I connect it to MS SQL 08. Now, I have a picture field named, "pic" and I want the content of the picture to be saved in the SQL database & retrieved onto the VB form. Below is the code and how to store the pic field indicated in bold below is the problem. The pic field in the database is an image datatype. Please, help me with VB code. Thank you in advance. - Public Sub SaveCompensationValue()
-
-
If frmMain.txtLocation.Text.Trim = "" Then
-
frmMain.txtLocation.Focus()
-
MsgBox("Location cannot be empty", MsgBoxStyle.Exclamation, "Location")
-
Exit Sub
-
End If
-
-
If frmMain.txtFileNo.Text.Trim = "" Then
-
frmMain.txtFileNo.Focus()
-
MsgBox("File No. cannot be empty", MsgBoxStyle.Exclamation, "File No.")
-
Exit Sub
-
End If
-
strUsername = GetSetting("Valuation", "Connection", "DataL1")
-
strPassword = GetSetting("Valuation", "Connection", "DataL2")
-
strServerName = GetSetting("Valuation", "Connection", "DataL3")
-
strInitialCatalog = GetSetting("Valuation", "Connection", "DataL4")
-
DataL1 = strUsername & strPassword & strServerName & strInitialCatalog
-
SQLcon = New SqlConnection
-
SQLCom = New SqlCommand
-
SQLcon.ConnectionString = DataL1
-
Dim SqlQuery As String = "Insert into CompensationValuation (DateOfValuation, ValueOrCost, TotalFloorArea, UnitCostRate, [Floor], Wall, Door, [Windows], [Ceiling], Roof, Location, FileNo, Remarks, pic) " & _
-
"Values('" & frmMain.dtDateOfValuation.Text.Trim & "','" & frmMain.txtValue.Text.Trim & "','" & frmMain.txtTotalFloorArea.Text.Trim & "','" & frmMain.txtUnitCostRate.Text.Trim & "','" & frmMain.txtFloor.Text.Trim & _
-
"', '" & frmMain.txtWall.Text.Trim & "','" & frmMain.txtDoor.Text.Trim & "','" & frmMain.txtWindows.Text.Trim & "','" & frmMain.txtCeiling.Text.Trim & "','" & frmMain.txtRoof.Text.Trim & _
-
"', '" & frmMain.txtLocation.Text.Trim & "','" & frmMain.txtFileNo.Text.Trim & "','" & frmMain.txtRemarks.Text.Trim & "','" & frmMain.pic.Text.Trim & "')" '& "','" & frmMain.txtCeiling.Text.Trim & "','" & frmMain.txtRoof.Text.Trim & _
-
SQLCom.Connection = SQLcon
-
SQLCom.CommandType = 1
-
SQLCom.CommandText = SqlQuery
-
Try
-
SQLcon.Open()
-
Dim strMsg As String = MsgBox("Save data?", MsgBoxStyle.Question + MsgBoxStyle.YesNo, "Saving confirmation")
-
If strMsg = MsgBoxResult.Yes Then
-
SQLCom.ExecuteNonQuery()
-
MsgBox("Data saved successfully", MsgBoxStyle.Information)
-
End If
-
Catch
-
MsgBox(Err.Description)
-
End Try
-
-
End Sub
0 1070 Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Michael Walton |
last post by:
I need some help, because I am utterly confused with how to do this. I have
2 things that I need to figure out, and could use some sample code or just
some general direction:
1) I need to build...
|
by: bissatch |
last post by:
Hi,
I am currently writing a news admin system. I would like to add the
ability to add images to each article.
What I have always done in the past is uploaded (using a form) the
image to a...
|
by: Adam J Knight |
last post by:
Hi all,
Just wondering whats everyones prefered method of storing images ?
1) File System
2) Database (SqlServer) (Seems to be easier, but has a performance hit)
Appreciate some insight!!!...
|
by: steelghost |
last post by:
I'm currently trying to store images into my DB. But the collation used
on my DB is big5, since my client wants this default encoding on their
webpage.
So to be able read the retreived data I have...
|
by: Spondishy |
last post by:
Hi,
I've taken over a publishing application that stores images in a sql
server db. The architecture is basically many load balanced web servers
connecting to the db. When an image is pulled...
| |
by: gomzi |
last post by:
hi,
I would like to know as to how I could enable write access to one of my folder( on my hosting company's server-shared hosting account) for storing the images.
I can't seem to find any way of...
|
by: CAM |
last post by:
Hello,
I am using SQL Server Express 2008 for my database and Visual Studios 2008 -
Visual Basic.Net for my forms. I Gone into VS 2008 and specify the source
of data using the Data Sources...
|
by: MMcCarthy |
last post by:
I have an upcoming project which requires the recording of thumbprint/fingerprint scans in a database (currently proposed as sql server). Now I have a few questions I need to explore:
How does...
|
by: kino |
last post by:
I am trying to test storing images in a database, I got this code after searching on Google but it doesn't work:
protected void Button1_Click(object sender, EventArgs e)
{
string...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...
| |