|
|
Hello
I am makeing one small application which saves and delete images in to sql database the code bellow is to load images it's works fine i can save new images to database and delete it and also moves back and forward in picture box but when i add or delete any image it does'nt shows any changes after saveing or deleting image so i have to close application and rerun it again so it shows changes i mean refresh in code bellow i have cleared dataset and then get sql connection and then fill data adapter but still it's not working
and i call this sub after save and delete image click event
any help
Private Sub LoadImages()
dsImage.Clear()
Try
conImage = GetDBConnection()
daImage.Fill(dsImage.Images)
If Me.BindingContext(dsImage.Images).Count = 0 Then
Label1.Text = "Empty Database"
Else
Label1.Text = Me.BindingContext(dsImage.Images).Count.ToString & " - Image(s) in database"
End If
Catch ex As Exception
MsgBox(ex.Message)
End Try
conImage.Close()
conImage.Dispose()
End Sub
waiting for your kind rep.
have a nice day
thanks again
|
|
|
|
|
Changes you make to the database will not show up in the application unless the DataSet is refreshed. That means rerunning the query that filled the dataset in the first place.
|
|
|
|
|
Hello sir
thanks for your kind rep.
but sir i dont understand what you are trying to say so can you please tell me how to refresh data set
waiting for your kind rep.
have a nice day
|
|
|
|
|
You have to do whatever you did to fill the dataset again. I have no idea what you did to get the initial data, so I can't explain it any further than this. Whatever you did to get the initial data is what you have to do again to refresh the dataset.
|
|
|
|
|
hello sir
thanks for your rep.
this is the code i am using
and as you said that load the data in to dataset so i am loading data in loaddata sub but still i dont know what's wrong there
Private Sub LoadImages()<br />
dsImage.Clear() :confused:<br />
Try<br />
conImage = GetDBConnection()<br />
daImage.Fill(dsImage.Images) :confused:<br />
If Me.BindingContext(dsImage.Images).Count = 0 Then<br />
Label1.Text = "Empty Database"<br />
Else<br />
Label1.Text = Me.BindingContext(dsImage.Images).Count.ToString & " - Image(s) in database"<br />
End If<br />
Catch ex As Exception<br />
MsgBox(ex.Message)<br />
End Try<br />
conImage.Close()<br />
conImage.Dispose()<br />
End Sub
and code for save image
Private Sub btnSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSave.Click<br />
Dim fs As FileStream = New FileStream(mImageFilePath.ToString(), FileMode.Open)<br />
Dim img As Byte() = New Byte(fs.Length) {}<br />
fs.Read(img, 0, fs.Length)<br />
fs.Close()<br />
<br />
mImageFile = Image.FromFile(mImageFilePath.ToString())<br />
Dim imgHeight As Integer = mImageFile.Height<br />
Dim imgWidth As Integer = mImageFile.Width<br />
Dim imgLength As Integer = mImageFile.PropertyItems.Length<br />
Dim imgType As String = Path.GetExtension(mImageFilePath)<br />
mImageFile = Nothing<br />
'get sql connection<br />
conImage = GetDBConnection()<br />
Dim sSQL As String = "INSERT INTO Images (Pic,Title, IType, Height, Width) VALUES(" & _<br />
"@pic, @title, @itype, @iheight, @iwidth)"<br />
commImage = New Data.SqlClient.SqlCommand(sSQL, conImage)<br />
' image content<br />
Dim pic As SqlParameter = New SqlParameter("@pic", SqlDbType.Image)<br />
pic.Value = img<br />
commImage.Parameters.Add(pic)<br />
<br />
' title<br />
Dim title As SqlParameter = New SqlParameter("@title", System.Data.SqlDbType.VarChar, 50)<br />
title.Value = txtTitle.Text.ToString()<br />
commImage.Parameters.Add(title)<br />
<br />
' type<br />
Dim itype As SqlParameter = New SqlParameter("@itype", System.Data.SqlDbType.Char, 4)<br />
itype.Value = imgType.ToString()<br />
commImage.Parameters.Add(itype)<br />
<br />
' height<br />
Dim iheight As SqlParameter = New SqlParameter("@iheight", System.Data.SqlDbType.Int)<br />
iheight.Value = imgHeight<br />
commImage.Parameters.Add(iheight)<br />
<br />
' width<br />
Dim iwidth As SqlParameter = New SqlParameter("@iwidth", System.Data.SqlDbType.Int)<br />
iwidth.Value = imgWidth<br />
commImage.Parameters.Add(iwidth)<br />
<br />
Try<br />
commImage.ExecuteNonQuery()<br />
MessageBox.Show("Image successfuly saved in database", "Image Load")<br />
Catch ex As Exception<br />
MsgBox(ex.Message)<br />
<br />
End Try<br />
commImage.Dispose()<br />
commImage = Nothing<br />
conImage.Close()<br />
conImage.Dispose()<br />
Call LoadImages()<br />
End Sub
any help
and i have drag and drop sqlcomand, sqladapter objects on form
waiting for your kind rep.
have a nice day
|
|
|
|
|
It's simple thing really. If you ran LoadImage in your code to setup the list before, you run it again to refresh that list and update the control.
|
|
|
|
|
hello sir
thanks for your rep.
but i think that's what i did i mean i call loadimages in form load and then i call it again after adding new image in btnSave click event and alos btnDelete click event
but not i am lost i know it's looks small thing but i can not see it
any way thank you again
|
|
|
|
|
We use spreadsheets with 40+ worksheets in the workbook. I have written a VBA macro to help navigate to specific worksheets. I read the names of all the sheets into an array, check each name for certain keywords, then load the name as a sub-menu of grouped menus.
The macro works fine with one exception, whenever a chart sheet is selected from the menu that chart is displayed but the custom menu disappears. Then if a non-chart worksheet is manually selected, then the custom menu reappears and works normally.
Thanks for any help.
A pertinent parts of the code which shows the same behavior is listed here:
' Macros by D. Simms
' with heavy reliance on Microsoft Excel 2000 Power Programming with VBA by John Walkenbach
' easier worksheet navigation in work books with a large number of worksheets
' arranges worksheets into groups with separate sheets in sub menus
' Auto_open and close macros are in the "ThisWorkbook" object code
Public SheetData() As String
Public ShtCount, ShtNumber As Integer ' these are all sheets visible and hidden
Public CurrentSheet As Object
Dim MenuSheet As Object 'Worksheet
Dim MenuObject As CommandBarPopup
Dim MenuItem As Object
Dim SubMenuItem As CommandBarButton
Dim Counter As Integer
Dim NumSheets As Integer 'this is the number of visible sheets
Sub IBWMenu()
' adds menu to navigate to one of the worksheets
' call get sheet list routine
Call FillWorksheetArray
' delete previous menu bar if it exists
Call DeleteIBWMenu
' add menu and submenus
Call AddIBWMenu
End Sub
Sub AddIBWMenu()
'Add IBW menubar just before help menu
Dim HelpMenu As CommandBarControl
' find Help menu
Set HelpMenu = CommandBars(1).FindControl(ID:=30010)
Set MenuObject = Application.CommandBars(1). _
Controls.Add(Type:=msoControlPopup, _
Before:=HelpMenu.Index, _
Temporary:=True)
MenuObject.Caption = "I&BW Worksheets" ' Name of menu; change to suit
'add menu categories
Set MenuItem = MenuObject.Controls.Add(Type:=msoControlPopup)
MenuItem.Caption = "&Tabs"
For Counter = 1 To NumSheets
If SheetData(Counter, 2) = "Tab" Then
Set SubMenuItem = MenuItem.Controls.Add
SubMenuItem.Caption = SheetData(Counter, 1)
SubMenuItem.OnAction = "SelectSheet"
End If
Next Counter
Set MenuItem = MenuObject.Controls.Add(Type:=msoControlPopup)
MenuItem.Caption = "&Charts"
For Counter = 1 To NumSheets
If SheetData(Counter, 2) = "Chart" Then
Set SubMenuItem = MenuItem.Controls.Add
SubMenuItem.Caption = SheetData(Counter, 1)
SubMenuItem.OnAction = "SelectSheet"
End If
Next Counter
Set MenuItem = MenuObject.Controls.Add(Type:=msoControlPopup)
MenuItem.Caption = "&Data"
For Counter = 1 To NumSheets
If SheetData(Counter, 2) = "Data" Then
Set SubMenuItem = MenuItem.Controls.Add
SubMenuItem.Caption = SheetData(Counter, 1)
SubMenuItem.OnAction = "SelectSheet"
End If
Next Counter
Set MenuItem = MenuObject.Controls.Add(Type:=msoControlPopup)
MenuItem.Caption = "&Other"
For Counter = 1 To NumSheets
If SheetData(Counter, 2) = "Other" Then
Set SubMenuItem = MenuItem.Controls.Add
SubMenuItem.Caption = SheetData(Counter, 1)
SubMenuItem.OnAction = "SelectSheet"
End If
Next Counter
Set MenuItem = MenuObject.Controls.Add(Type:=msoControlButton)
MenuItem.Caption = "&Reset"
MenuItem.BeginGroup = True
MenuItem.OnAction = "ResetIBWMenu"
End Sub
|
|
|
|
|
I have a customer who wants an existing C application ported to VB, and I'm having a bit of trouble trying to find a way to read and write the same data files as the previous program used.
Existing struct example: (the actual structures are quite a bit more complex but I'm going for clarity here)
struct system_info
{
char name[32];
int number;
int more_numbers[DEFINED_LENGTH];
double even_more_numbers[OTHER_DEFINED_LENGTH];
unsigned char padding[103];
};
fread(&system_info, sizeof(system_info), 1, file);
I've found that there's no way to have fixed-length arrays inside a struct in VB (2005, if it matters), so I'm stumped as to how to load in fixed-length records with numerous arrays inside them.
On top of that, when I use variable length arrays the size of the structure is not correct (by which I mean it doesn't match what I expect).
Any ideas/suggestions?
|
|
|
|
|
First question: VB 6 or VB.NET? The answer will help determine how I look for a solution.
Tim
|
|
|
|
|
.Net - VB2005.
I've spent over an hour looking for some sort of solution already, and either Google has failed me or I have failed at using Google. I hope someone else has better luck, or better intuition.
|
|
|
|
|
(no <pre> here due to VB attribute syntax)
Maybe partial solution: (from http://answers.google.com/answers/threadview?id=95319)
structure system_info
<VBFixedString(32)> dim name as char
dim number as integer
<VBFixedArray(DEFINED_LENGTH)> dim more_numbers as integer
'... etc
end structure
FileOpen (1,filename, OpenMode.Binary)
FileGet(1,system_info)
Still got a bunch of stuff to apply this attribute tag to before I can see if it works though...
|
|
|
|
|
Private Structure OPENFILENAME
Dim lStructSize As Integer
Dim Arr(len(msString)) as string
Dim hwndOwner As Integer
Dim hInstance As Integer
Dim lpstrFilter As String
Dim lpstrCustomFilter As String
Dim nMaxCustFilter As Integer
Dim nFilterIndex As Integer
Dim lpstrFile As String
End Struct
you can use some type of Solution.you can use variable first then execute the query now.
'Nothing Is Impossible'
Regard
Anubhava Dimri
anubhava.prodata@gmail.com
919250168195
|
|
|
|
|
salam sir;
how can made msn messenger or windows messenger in vb.net?please send me coding of this application and send me msn messenger application in vb.net project
thanks sir
mohammedali
|
|
|
|
|
You are asking for a complete application to be written for you.
The forums are for asking direct questions about a specific problem.
I doubt anyone will send you a complete Instant Messenger application.
Search the Internet for examples and write your own.
|
|
|
|
|
OK - sure. That will be $20k.
Do you want my Paypal details ?
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
mohammedali2006 wrote: how can made msn messenger or windows messenger in vb.net?
Ok. Use windows controls suitable for the application, write code, and then hit Ctrl+Shift+B to Build Appication OR hit F5 to run it.
mohammedali2006 wrote: please send me coding of this application and send me msn messenger application in vb.net project
Stop asking people to do your work!! We're here to help you not to do your homework.
And READ THIS[^] very carefully. And read it every time before you post any question.
- Stop thinking in terms of limitations and start thinking in terms of possibilities -
|
|
|
|
|
--> i have written an application like that but works only on LAN.
--> Do you want it. if yes then send me $10k.
--> iif(AGREE,i will send you my mailing information,LEAVE IT)
J A Nasir K
|
|
|
|
|
I have used the visual basic express edition 2008 to create an application. In order to run this application the user must have the .net 3.5 framework installed. I have created an deployed an application but it downloads the framework from microsoft. But the user may not have an internet connection and there for i wish to include the framework when creating the application setup.exe. Can anyone tell me how i would go about this? Any help is much appreciated.
|
|
|
|
|
You'll have to include the dotnetfx.exe setup on the distribution media (CD, DVD, what have you). Using the Express Editions, you don't have the options available to add the .NET Framework into the installation.
|
|
|
|
|
I am using a cd. Is there any help available online in using this method?
Regards
McGann
|
|
|
|
|
A CD?? Then all you have to do is put the dotnetfx.exe installation on the same CD. Run the dotnetfx.exe setup first, then run your app's installation.
The method I mentioned only work with the full versions of Visual Studio, and it's as simple as turning on a prerequisite option in the Setup project.
|
|
|
|
|
Hello every one
I want to know ow can i
- Find the dimensions of a image
- Size of Image
without actually opening it in a picture bos
My objective is
- I have a application in Vb.net where i let the user select a JPEG file and upload it in a DB
- Now if the image is too big in size and dimensions then it takes a good time in retrieving it from the DB.
What my idea is
- Reduce the picture dimension if it is too big for the application use
- Reduce the size (if possible) by reducing the picture quality if the size is still too big after reducing the dimensions
Regards
Nishkarsh
|
|
|
|
|
Load it into a Bitmap object. You don't need a PictureBox at all. Once you have it in a Bitmap object, there are Width and Height properties you can look at. To get the file size, you'd have to check the size from the streamed number of bytes. There is no size property in the Bitmap object.
|
|
|
|