I have a data grid view like this:
i am loading data grid view like this: - Dim cd As SqlCommandBuilder = New SqlCommandBuilder(adapter)
-
adapter = New SqlDataAdapter("select c.cid,c.CompanyName,d.dtId,d.dtName as Department,d.dtPhone as Phone,d.dtEmail as Email,d.empimage from CompanyMaster_tbl c join DepartmentMaster_tbl d on c.Cid=d.cId order by cid", con.connect)
-
-
dt1 = New DataTable
-
bSource = New BindingSource
-
adapter.Fill(dt1) 'Filling dt with the information from the DB
-
bSource.DataSource = dt1
-
gv.DataSource = bSource
-
gv.Columns("cid").Visible = False
-
gv.Columns("dtId").Visible = False
in update button i wrote code like this: - adapter = New SqlDataAdapter()
-
Dim cid As Integer
-
Dim dtid As Integer
-
Dim cmpname As String
-
Dim dtname As String
-
Dim dtPhone As String
-
Dim dtEmail As String
-
Dim dtimage As Image
-
-
-
For i As Integer = 0 To gv.RowCount - 2
-
Dim rv = DirectCast(gv.Rows(i).DataBoundItem, DataRowView)
-
cid = rv.Row.Field(Of Integer)("Cid")
-
-
dtid = rv.Row.Field(Of Integer)("dtId")
-
cmpname = rv.Row.Field(Of String)("CompanyName")
-
dtname = rv.Row.Field(Of String)("Department")
-
dtPhone = rv.Row.Field(Of String)("Phone")
-
dtEmail = rv.Row.Field(Of String)("Email")
-
-
Using ms As New MemoryStream(rv.Row.Field(Of Byte())("empimage"))
-
dtimage = New Bitmap(ms)
-
End Using
-
-
adapter.UpdateCommand = New SqlCommand("UPDATE CompanyMaster_tbl SET CompanyName = @CompanyName", con.connect)
-
'this code for updating image also..
-
adapter.UpdateCommand = New SqlCommand("update DepartmentMaster_tbl set dtName = @dtName,dtPhone = @dtPhone,dtEmail = @dtEmail,empimage=@dtimage where dtId=@dtid", con.connect)
-
adapter.UpdateCommand.Parameters.AddWithValue("@Cid", cid)
-
adapter.UpdateCommand.Parameters.AddWithValue("@CompanyName", cmpname)
-
adapter.UpdateCommand.Parameters.AddWithValue("@dtId", dtid)
-
adapter.UpdateCommand.Parameters.AddWithValue("@dtName", dtname)
-
adapter.UpdateCommand.Parameters.AddWithValue("@dtPhone", dtPhone)
-
adapter.UpdateCommand.Parameters.AddWithValue("@dtEmail", dtEmail)
-
-
Dim md As New MemoryStream()
-
dtimage.Save(md, System.Drawing.Imaging.ImageFormat.Gif)
-
' read to end
-
Dim bmpBytes As Byte() = md.GetBuffer()
-
-
' Dim image As Byte() = System.IO.File.ReadAllBytes()
-
adapter.UpdateCommand.Parameters.AddWithValue("@dtimage", bmpBytes)
-
'adapter.UpdateCommand.Parameters.AddWithValue("@dtimage", dtimage)
-
adapter.UpdateCommand.ExecuteNonQuery()
after updating my first 4 column of data grid view coming proper,,but image coming something like back color,,like this:
what is wrong with my code?? any help is very appreciable?
0 1276 Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Joe Griffith |
last post by:
I'm using a Win Forms Data Grid View control in unbound mode.
When I add columns using the wizard the first item is the column name.
Everything works fine.
However, if you return to the columns collection and look at the
poperties of an individual column the name property is not in the list.
Is there a way to change (or even find) the name of a column in a data
grid view other than looking at it in the *.Designer.vb file?
|
by: Gian Paolo |
last post by:
this is something really i can't find a reason. I have a form with a
tabcontrol with tree pages, in the second page there is a Data GRid View.
Plus i have a class. When i open the form i "inizialize" the Data Grid View
(add a data sorce, filled with notthing at staratup, and hide some columns)
when i put a code in the txtCLCOD textbox start a searsh. If i foud
something i popolate the Data grid view on the second page. Now the magic if
i...
|
by: Dilanka |
last post by:
I want to double click on the particular data item in data grid view and get that those values to another form can somebody tell me how can i do this? i'm using visual studio .net 2005 and the language is c++
|
by: nanaalwi |
last post by:
hi there,
im doing a project right now to download a data from EEPROM of a camcorder. i used a 'data grid view' to display all the data downloaded from the camcorder. however, i have to save the data displayed in the 'data grid view' to a text file (.txt). can anyone help me on this? really appreciate your help. anyway, im using vb.net.
thanx in advance!!
|
by: dineshsanduke |
last post by:
hi
i m new user i created programatic data grid. i want numeric cell validation in data grid view
| |
by: jakeesgirl |
last post by:
I'm creating a C# program in Visual Studio. When I query the sql database, the results are put into a data grid view. However, the column widths are always too small when displayed. I have text that is not shown because the column width is not large enough. Is there a way I can fix that in the data grid view? I see a column height property but not a column width.
|
by: cadab |
last post by:
I have a data grid view, i have specified several columns through the designer that i would like to show on the grid, i have mapped them to the datasource, this works fine, the problem is, my data source contains lots of columns and some of these i do not want to show on the grid.
Is there a property/option where i can just get my specified columns to show, without resorting to removing each column programticly.
Thanks,
James Coverdale
|
by: mcupito |
last post by:
I am trying to populate a data grid view based off of two text boxes, Start date and End date.
I am not sure how to work with DataGridViews or DataSets.
So if textbox1.text = x/x/2013 and textbox2.text = y/y/2014, then clicking a button will filter the records and display only those records with corresponding date values in the data grid view.
The biggest part I am struggling with is getting the records via search button. Here's what I...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
| |
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
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 then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
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 we have to send another system
|
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |