|
Lisana wrote:
I can't recall the function in the ImageButton1ClickHandler, what should I do?
If you want to call the code in the handler, just move the code to another method outside the handler.
Public Sub ImageButton1ClickHandler(ByVal sender As Object, ByVal e As System.EventArgs)
Dim results As Int32 = CType(CType(sender, Button).Name, Int32)
BindDataSources(results)
End Sub
Public Sub BindDataSources(ByVal entityID As Int32)
' I'm assuming client_entityID is a "global" variable
objConn.Open()
Dim DA As New OleDbDataAdapter
DA.SelectCommand = New OleDbCommand
With DA.SelectCommand
.Connection = objConn
.CommandType = CommandType.Text
.CommandText = "UPDATE Contacts set primary_contact = 0 WHERE client_entity_id = " & client_entityID
.ExecuteNonQuery()
End With
Dim DA2 As New OleDbDataAdapter
DA2.SelectCommand = New OleDbCommand
With DA2.SelectCommand
.Connection = objConn
.CommandType = CommandType.Text
.CommandText = "UPDATE Contacts set primary_contact = 1 WHERE entity_id = " & entityID
.ExecuteNonQuery()
End With
objConn.Close()
End Sub
Now you can call BindDataSources from anywhere in your code, so long as you provide it an entityID.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
I think you misunderstood my meaning, I want to call the function contactView not the update query.
Public Sub ImageButtonClickHandler(ByVal sender As Object, ByVal e As System.EventArgs)
results = CType(CType(sender, Button).Name, Int32)
contactView() 'give me error
end sub
it gave me error when I call the contactView() in the ImageButtonClickHandler
The main thing I want to do in here is when the blankImageButton Click, then go the database to change the pimary_contact to 1, the other pimary_contact=1 to 0, at the same time, the button image changes as well, in the output, the imagebutton didn't change when I click, but the database is updated. I have to close the window, then reopen again, then it shows the change.
Lisa
|
|
|
|
|
Whopps! My mistake.
What's the error?
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
The main thing I want to do in here is when the blankImageButton Click, then go the database to change the pimary_contact to 1, the other pimary_contact=1 to 0, at the same time, the button image changes as well, in the output, the imagebutton didn't change when I click, but the database is updated. I have to close the window, then reopen again, then it shows the change.
Lisa
|
|
|
|
|
You've got a major design flaw in there. Every time you call contactView, you're created new buttons. But, you're never removing the old ones that you created.
What are you trying to do with the buttons? Implement paging?
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
How can I remove the old buttons when before contactView() called?
those buttons are checked and unchecked buttons, if you have 5 contacts, there is only one pimary contact that would be the checked buttons, if you want to change your pimary contact, then click one unchecked button, the one you just clicked will become the pimary contact(changed to checked button), the old pimary contact changed to unchecked button.
like this:
-Unchecked X checked
5 lists, when the second record click, then
old new
- -
- X
- -
X -
- -
Lisa
|
|
|
|
|
If there is some compelling reason whay you absolutely have to add the buttons at run-time - like the numebr of buttons changes depending on the number of contacts, then load them all one time when the form is initialized. After you create each button, also add it to a local collection.
Then when a person clicks on a button, enumerate the local collection, set each button's state to unchecked, then continue to process the click event to perform the query and reset the newly checked contact.
This will be much faster than trying to constantly add and remove buttons and their event handlers from the form. You also do not need to keep track of the current state of any given button, because you simply reset them all to unchecked whenever one is clicked.
Unless you have a lot of buttons, simply enumerating the list will be about as fast, and much simpler than writing code to keep track of the the button state.
Robert
|
|
|
|
|
it's very complicate in this data binding..I have a very hard time to get around all of those.
this is my form look like:
PC|View|Name|Phone|email
PC column: imagebutton
View: button --when the user click button, then open a form to view the detail, and the user and change the data, when the form closed, in this form's data has to be updated as well, this is a hard part I haven't found a way to fix the problem..in my app now, I can't get to refresh and load the update data, I have to close this form and open again to get the newest data.
Name: textbox
phone: combobox, binding all the phone number in db to combobox
email: button - when the user click the button, then auto start a outlook to send email.
I can't use datagrid because I can't find a way to add those controls to datagrid. so I only can use the dataReader to menually creat those needed in my app. that is very annoying to do that. but I can't find any other way to do it. IF you know a better way to do it, please tell me. I will very appricate it.
Lisa
|
|
|
|
|
Wow! Talk about doing it the hard way!
The DataGrid is the tool choice for this project, but admittedly, it's not an easy tool to learn to use. Ummmm... Try seeing what you can glean from this[^] little article by Omri. There's even a link in it to show you how to get a ComboBox column into a DataGrid.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Thanks;)
how about a button inside datagrid, and when it click, open another window? This is I always want to do it, but I just can't get around it, it includes some drawing and you need to creat a button by your own...do you have any experience for the button inside datagrid. I know the combobox inside datagrid is much easier to do it than button. I have buttons and combobox at the same time.
Lisa
|
|
|
|
|
expression is not a method.
Lisa
|
|
|
|
|
TextBox, Button, CheckBox and most (not all but most) NET controls can display images from an ImageList.
You will find that your code is simpler, easier to deploy, and easier to manage in general if you just abandon the whole approach of loading images from a file. Put them in an ImageList control instead.
Robert
|
|
|
|
|
Hi there
I want to use a wavelet filter in my program but i can't find any documentation and i dont know if VB is able to do it. I tried to use CxImage (which seems to work with matrice ?!) but I'm a little bit lost....
Thx for answerds
Anthony
|
|
|
|
|
There's no reason why you shouldn't be able to use VB to do this. If you don't know anything about the algorithm, just Google for it. Results for "wavelet filter algorithm vb"[^].
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
<br />
<br />
<% @Import Namespace="System.Data" %><br />
<script language="vb" runat="server"><br />
Dim searchword as String<br />
Dim pls as New DataTable()<br />
<br />
Sub Page_Load(sender as Object, e as EventArgs)<br />
BuildDataStore()<br />
<br />
completeData.DataSource = pls<br />
completeData.DataBind()<br />
End Sub<br />
<br />
<br />
Sub BuildDataStore()<br />
Dim dr as DataRow<br />
<br />
pls.Columns.Add(new DataColumn("Results", GetType(String)))<br />
<br />
dr = pls.NewRow()<br />
dr(0) = "If only God would give me some clear sign! Like making a large deposit in my name at a Swiss bank."<br />
pls.Rows.Add(dr)<br />
<br />
dr = pls.NewRow()<br />
dr(0) = "Is sex dirty? Only when it's being done right."<br />
<br />
pls.Rows.Add(dr)<br />
<br />
dr = pls.NewRow()<br />
dr(0) = "On the plus side, death is one of the few things that can be done just as easily as lying down."<br />
pls.Rows.Add(dr)<br />
<br />
dr = pls.NewRow()<br />
dr(0) = "I took a speed reading course and read 'War and Peace' in twenty minutes. It involves Russia."<br />
pls.Rows.Add(dr)<br />
<br />
dr = pls.NewRow()<br />
dr(0) = "To *you* I'm an atheist; to God, I'm the Loyal Opposition."<br />
pls.Rows.Add(dr)<br />
<br />
dr = pls.NewRow()<br />
dr(0) = "Sex without love is an empty experience, but as empty experiences go, it's a pretty good empty experience."<br />
pls.Rows.Add(dr)<br />
<br />
dr = pls.NewRow()<br />
dr(0) = "It's not that I'm afraid to die. I just don't want to be there when it happens."<br />
pls.Rows.Add(dr)<br />
<br />
dr = pls.NewRow()<br />
dr(0) = "What if everything is an illusion and nothing exists? In that case, I definitely overpaid for my carpet."<br />
pls.Rows.Add(dr)<br />
<br />
dr = pls.NewRow()<br />
dr(0) = "Interestingly, according to modern astronomers, space is finite. This is a very comforting thought-- particularly for people who can never remember where they have left things."<br />
pls.Rows.Add(dr)<br />
<br />
dr = pls.NewRow()<br />
dr(0) = "Eighty percent of success is showing up."<br />
pls.Rows.Add(dr)<br />
End Sub<br />
<br />
<br />
Sub BindData(strQuery as String)<br />
searchword = strQuery<br />
<br />
Dim dv as DataView<br />
dv = New DataView(pls)<br />
dv.RowFilter = "Results LIKE '%" & Regex.Replace(searchword,"'","''") & "%'"<br />
<br />
SearchResults.DataSource = dv<br />
SearchResults.DataBind()<br />
End Sub<br />
<br />
<br />
Function Highlight(Search_Str as String, _<br />
InputTxt as String, _<br />
StartTag as String, _<br />
EndTag as String) As String<br />
<br />
Dim ResultStr As String <br />
Return Regex.Replace(InputTxt, "\b(" & Regex.Escape(Search_Str) & ")\b", _<br />
StartTag & "$1" & EndTag, RegExOptions.IgnoreCase)<br />
End Function<br />
<br />
<br />
Sub searchQuotes(sender as Object, e as EventArgs)<br />
BindData(SearchTerm.Text)<br />
SearchResults.Visible = True<br />
End Sub<br />
</script><br />
<br />
<style type="text/css"><br />
.highlight {text-decoration: none;color:black;background:yellow;}<br />
</style><br />
<br />
<form runat="server"><br />
Text to Search: <asp:TextBox id="SearchTerm" runat="server" /><br />
<asp:button runat="server" Text="Search Woody Allen Quotes"<br />
OnClick="searchQuotes" /><br />
<p><br />
<asp:DataGrid runat="server" id="SearchResults" AutoGenerateColumns="False"<br />
Visible="False" ShowHeader="False"><br />
<Columns><br />
<asp:TemplateColumn><br />
<ItemTemplate><br />
<%# Highlight(searchword, DataBinder.Eval(Container.DataItem, "results"), "", "") %><br />
</ItemTemplate><br />
</asp:TemplateColumn><br />
</Columns><br />
</asp:DataGrid><br />
<p><br />
The Data Being Search<br />
<asp:datagrid runat="server" id="completeData" ShowHeader="False" /><br />
I imported this code in Visual studio.net and change on click events and other thing that they have to change but
there is a problem ! Framework said that error BC30390: 'webapplication1.webform1.searchwords' is not
accessible in this context because it is 'Private'.
any idea ?
onezero@gmail.com
|
|
|
|
|
First off, this questio njbelongs in the ASP.NET Forum, not VB.
Yeah, you can't use the variable searchword outside the <script> block. When you called Highlight , you tried to use a variable that was not visible outside the script block.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
how can i connect the microsoft chart control with a table in the db so i can plot the data on the MS chart control.
|
|
|
|
|
Hello
I want to preview MS office documents (word and excel) on windows form using VB.NET (example how to do this can be in any language, but VB id preffered ). Somewhere I have found, that this is done using Microsoft Web Browser component (SHDocVw.dll). Well, this seems to almost work, but...
Problem #1:
When I try to open an office document caling webBrowser.navigate("file:///some_document.doc") , it pop-ups a dialog offering me to open or download this document. There is a check box, so next time I try to open this kind of documents, it will not ask me, but display it.
Problem #2:
Vhen a document is opened in a web browser, it is editable. Well, this is normal, because there is an instance of MS word opened in the web browser.
What I need:
I need to show (preview) an office document in a windows form. The "preview" meens, it must be read only and not bothering users with some dialog if they want to download or open it.
Thanks a lot for any help.
Satano.
|
|
|
|
|
i have this code and i want this as a windows service.
i like this to execute every 20 secs
Dim olapp As New Outlook.Application
Dim olNs As Outlook.NameSpace
Dim myrecipient, myfolder
Dim myitems As Outlook.Items
Dim mymail As Outlook.MailItem
Dim myitem As Object
Dim myConnection As SqlConnection
Dim myCommand As SqlDataAdapter
Dim cmd As New SqlCommand
olapp = CreateObject("Outlook.application")
olNs = olapp.GetNamespace("MAPI")
myrecipient = olNs.CreateRecipient("someusername")
myrecipient.resolve()
If myrecipient.resolved Then
myfolder = olNs.GetSharedDefaultFolder(myrecipient, Outlook.OlDefaultFolders.olFolderInbox).Items
End If
myitems = myfolder
myConnection = New SqlConnection("Data Source=.....")
myCommand = New SqlDataAdapter
myitems = myitems.Restrict("[Unread] = true")
myConnection.Open()
For Each myitem In myitems
On Error Resume Next
cmd = New SqlCommand("Insert into NewMessages (EntryID,SenderName,Subject,ReceivedTime,Body,UnRead) values(@EntryID ,@SenderName,@Subject,@ReceivedTime,@Body,@UnRead)", myConnection)
cmd.Parameters.Add(New SqlParameter("@EntryID", SqlDbType.Variant))
cmd.Parameters("@EntryID").Value = myitem.entryid
cmd.Parameters.Add(New SqlParameter("@SenderName", SqlDbType.NVarChar, 100))
cmd.Parameters("@SenderName").Value = myitem.sendername
cmd.Parameters.Add(New SqlParameter("@Subject", SqlDbType.NVarChar, 1000))
cmd.Parameters("@Subject").Value = myitem.subject
cmd.Parameters.Add(New SqlParameter("@ReceivedTime", SqlDbType.DateTime))
cmd.Parameters("@ReceivedTime").Value = myitem.ReceivedTime
cmd.Parameters.Add(New SqlParameter("@Body", SqlDbType.Variant))cmd.Parameters("@Body").Value = myitem.Body
cmd.Parameters.Add(New SqlParameter("@UnRead", SqlDbType.NChar, 5))cmd.Parameters("@UnRead").Value = myitem.UnRead
cmd.ExecuteNonQuery()
Next myitem
myConnection.Close()
olapp = Nothing
olNs = Nothing
myrecipient = Nothing
myfolder = Nothing
myitem = Nothing
myitems = Nothing
myrecipient = Nothing
i've already created a service for this one but, on its first start, it extracts unread mails, but when new mails come, it does not extract anything and when i checked on the application log it says, Microsoft Office 11 - Rejected safe mode action - Microsoft Outlook. on the system log: DCOM - The server {0006F03A-0000-0000-C000-000000000046} did not register with DCOM within the required timeout. I already uninstalled and killed the service but i'm still getting this errors on the eventlog. why is this so? i think i messed everything up. :'( please help me resolve this..
|
|
|
|
|
hi
is it necessary to have smtp server on that machine to send mail.
suppose i dont have the smtp server than how can i send mail through code(dont tell me the code just what process should be followed).
|
|
|
|
|
Private Sub showMonth()
MonthlyCalendar1.FirstDate = d
txtMonth.Text = DatePart(DateInterval.Month, d) & "," & " " & DatePart
(DateInterval.Year, d)
End Sub
The above code displays the month in a number format like 4, 2005. I want to know how to modify the above code to display the month in April, 2005 format. How should I do it? I have tried select case but I get an error saying that I can't combine 'Date' with an 'Integer'.
|
|
|
|
|
Try the command Format
Here dt is a datetimepicker control
Format(Me.dt.Value, "d/MMM/yyyy")
|
|
|
|
|
I'm interested in adding custom columns to a datagrid (not ASP), and am using sample code I found, which illustrates how to do so with a combo box. The sample works fine. But, when I substitute code to implement a DataGridTextColumn with either a NumericUpDown or DateTimePicker, I run into at least one problem. That is, the control in the columns works well until the user pans the grid (scrolls horizontally). The custom control remains in the same location relative to the grid, rather than moving with the column. I've looked at the code that implements the combo box and, except for the differences in the custom control I'm adding, I can't tell why the combo box moves as it should and the others don't.
Any ideas?
Thanks in advance
Dan
|
|
|
|
|
In my vb app, I have a sql connect string in my publicModule. when the user install the app, it will ask the "Initial Catalog" and "Data Source" value, then open the app. if the user input the wrong value, then the app can't open the sql data, how can I check the two value are matching in the sql data? and what's the best way to put the sql connection string in my app.
I created a registry key for the two value. Is it the best way? how can I check the registry key if it's not exist?
Lisa
|
|
|
|
|
When your application starts, it should check to see if there are values in the appropriate storage locations for your Inital Catalog and Data Source. These could be in the Registry or in a config file somewhere. If the values are not there, then your app should ask for them.
Once you have them, either input by the user or fetched out of the saved config, you can try and connect to the database and run a small query. If any part of the query process fails, then you can be pretty sure something is wrong and the code should return any errors to the user and either ask for corrected, or alternate, connection information or quit.
In my work, I like to setup a stored procedure in the database that returns a value specific to that database. For example, returning a string that specifies what the database name is, it's code version and its schema revision, like "TSEC ver:2.00 schema:6.30". This way, my code knows that this database is the correct one it should be working with, regardless of what the Data Source name is(!) and it gets additional information that the application might need. Such as taking into account dealing with an older version of a database's procedures or dealing with a minimum database version that's supported by the code.
Currently, Microsoft recommends NOT using the registry to store application configuration values, such as a connection string, but instead, recommends using .config files. Rocky Lhotka wrote a very good article for MSDN, found here[^], that explains configuration files and how to read and write them.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|