|
How do you format DateTime values in a comboBox to display the date only without the time ("mm/dd/yyyy") in the text box as well as in the list. The ComboBox is bound to a datetime field in MS Access (Jet.OLEDB.4.0) ?
Thanks very much.
|
|
|
|
|
I need code to create a shortecut in vb4 onto the main win screen
|
|
|
|
|
Did I hear you correctly? Did you say VB FOUR??
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Expertise: Intermediate
Language: VB4,VB5,VB6
January 22, 2000
Create an Internet shortcut
Unlike regular LNK shortcut, which contain data in binary file, Internet shortcut files are just text files in this format:
[InternetShortcut]
URL=www.domain.com
Thus it is simple to programmatically create an Internet shortcut that, when double-clicked, will load the default browser and have it point to the specified URL. Here is a reusable routine that does it all:
' Create an internet shortcut
'
' when double-clicked, this shortcut will
' load the default browser and point it to
' the specified URL page
Sub CreateInternetShortcut(ByVal FileName As String, ByVal URL As String)
Dim fnum As Integer
' an Internet shortcut is just a two-line text file
fnum = FreeFile
Open FileName For Output As #fnum
Print #fnum, "[InternetShortcut]"
Print #fnum, "URL=" & URL
Close #fnum
End Sub
|
|
|
|
|
how can i make datagrid with check ???
i want that to delete the entries of a table whose corresponding entries in checkbox are select
"its like yahoomail"
all the message are deleted whose checkbox are selected
i want same functionality
plz help
|
|
|
|
|
i want to retrieve of a table whose schema and other constraints i do not know
basically , i had given user opurtunity to browse the database (and select any table) and based on that i will display the priary keys(if it does not had primey keys then a msgbox will be displayed)
is there any method to know wheteher table has primary keys and to bind that column to the combobox
plz help
a code snippet will be more helpfull....
|
|
|
|
|
You can use the stored proc sp_primarykeys
Best of luck
Forever Developing
|
|
|
|
|
i m using ms access
plz help me
code will be very useful
|
|
|
|
|
I was not sure if you were using OLEDB or ODBC so I did it in OLEDB.
Private Sub cmdFindPrimary_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdFindPrimary.Click
Try
Dim ConnString As String = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=V:\VBScratchPad\test.mdb;"
Dim cn As OleDbConnection = New OleDbConnection(ConnString)
cn.Open()
Dim da As New OleDbDataAdapter("Select * from Test", cn)
Dim ds As New DataSet("TESTING")
da.FillSchema(ds, SchemaType.Mapped)
For i As Integer = 0 To ds.Tables(0).PrimaryKey.GetUpperBound(0)
Console.WriteLine(ds.Tables(0).PrimaryKey(i).ColumnName)
Next
Catch ex As ApplicationException
MessageBox.Show(ex.ToString())
End Try
End Sub
Best of Luck
Forever Developing
|
|
|
|
|
i had written the code but i m still getting exceptions
here is my code
con is oledbconnection
adap is oledbdataadapter
ds is dataset
con = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Password=;User ID=Admin;Data Source=D:\Documents and Settings\sumit\My Documents\db1.mdb")
adap = New OleDbDataAdapter("select * from table4", con)
ds = New DataSet("testing")
adap.FillSchema(ds, SchemaType.Mapped)
Dim i As Integer
Try
For i = 0 To ds.Tables("table4").PrimaryKey.GetUpperBound(0)
combobox1.items.add(ds.Tables("Table4").PrimaryKey(i).ColumnName())
Next
Catch ex As System.Exception
MsgBxox(ex.Source + " " + ex.Message + " " + ex.ToString)
End Try
End Sub
and i m getting the exception
"object refrence not set to instance of object"
help plz
|
|
|
|
|
Not sure why this is but I found a solution to you problem
For i = 0 To ds.Tables(0).PrimaryKey.GetUpperBound(0)
ComboBox1.Items.Add(ds.Tables(0).PrimaryKey(i).ColumnName())
Next
it seems that when filling the schema you cannot refer to the table by its name but only by index number or the value "Table"
Forever Developing
|
|
|
|
|
it still not working
is there any method top get the name of that column.
|
|
|
|
|
Hi
I was wondering if there is anyway to use VB.NET 2003 to determine the bit rate of an MP3, If so how?
Thanks
- Colin
|
|
|
|
|
http://www.codeproject.com/vb/net/vbmp3header.asp
Read MP3 header information and read/write the ID3v1 tag
By Thommy Mewes
|
|
|
|
|
Hello all... I am trying to make a program in VB that flashes between black and white... basically all I am looking for is a small box on the screen which will be able to flash at a rate of approximately 50-60hz... I was told that directdraw was the best method for this. Does anyone have any idea on how I could start this or some directions to a tutorial for more info.. any help would be greatly appreciated.. thanks a lot
tim
|
|
|
|
|
I have a asp.net datagrid which has a datatable as the datasource. The grid's last row must must always be empty(easy part). My problem is a have to load a dynamic dropdown list to a column in the last row in the grid, i can do that but every time i click on the list it disappears. Problem no.2 i need to display a datetime picker dynamically in the last row of the grid as well but the calendar control is just too big. The code to do all of this is in the ItemDataBound
All help is appreciated
|
|
|
|
|
Hi!
I'm looking for a sound recorder to integrate with my application.
are there any tools available?
Thanks!!!!
|
|
|
|
|
Hi,
I would like to use the F1 and F2 key to set the focus between 2 grids in the form.
Lets say the cursor focus is in DBgrid1, on hitting F1 I want the focus to shift to Dbgrid2.
And again on hiting F2 I want the focus to go back to DBgrid1.
Here is a piece of my code but wont work.
It does not give me an error mssg but wont fire.
If I change it to DbGrid2.Focus = True then I get an error mssg.
Private Sub Form1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles MyBase.KeyDown
If e.KeyCode = Keys.F2 Then
DBGrid2.Item(0, 0).Focus = True
'Dbgrid2.Focus = True
End If
End Sub
|
|
|
|
|
try uncommending 'Dbgrid2.Focus = True or using enabled or visible instead. They may accomplish somthing acceptable without the fuss
|
|
|
|
|
I have problem to reload DataReader in my app. Here is my code:
Private Function ContactView()
Dim DA As New OleDbDataAdapter
Dim DR As OleDbDataReader
objConn.Open()
DA.SelectCommand = New OleDbCommand
DA.SelectCommand.Connection = objConn
DA.SelectCommand.CommandType = CommandType.Text
DA.SelectCommand.CommandText = _
"SELECT primary_contact, entity_id, ISNULL(first_name, '') + ' ' + ISNULL(last_name, '') AS Name, ISNULL(company, '') " & _
"AS Company, ISNULL(business_phone, '') AS phone, ISNULL(home_phone, '') AS homePhone, ISNULL(pager, '') AS Pager, " & _
"ISNULL(mobile_phone, '') AS mobilePhone, ISNULL(business_fax, '') AS fax, ISNULL(email, '') AS email " & _
"FROM Contacts WHERE (status = 1) AND client_entity_id = " & client_entityID & " ORDER BY last_name, first_name"
DR = DA.SelectCommand.ExecuteReader
Dim y = 72
Dim primaryContact As Boolean
Dim entity As Int32
Dim fullName, phone, fax, homePhone, cellPhone, email, company, pager As String
Do While DR.Read()
primaryContact = DR.GetBoolean(0)
entity = DR.GetInt32(1)
fullName = DR.GetString(2)
company = DR.GetString(3)
phone = DR.GetString(4)
homePhone = DR.GetString(5)
pager = DR.GetString(6)
cellPhone = DR.GetString(7)
fax = DR.GetString(8)
email = DR.GetString(9)
'create a checked button
If primaryContact = True Then
Dim aImageButton As New Button
With aImageButton
Dim imagePath As String = Path.Combine(Application.StartupPath, "checkbox_checked.gif")
.Image = Image.FromFile(imagePath)
.Name = entity
.Text = ""
.ImageAlign = ContentAlignment.MiddleCenter
.FlatStyle = FlatStyle.Flat
.Location = New Point(10, y)
.Width = 20
.Height = 20
End With
' Attach the Click Event handler
AddHandler aImageButton.Click, AddressOf ImageButtonClickHandler
' Finally, add the control to the Form
tpgContact.Controls.Add(aImageButton)
Else
Dim aImageButton As New Button
With aImageButton
Dim imagePath As String = Path.Combine(Application.StartupPath, "checkbox_blank.gif")
.Image = Image.FromFile(imagePath)
.Name = entity
.Text = ""
.ImageAlign = ContentAlignment.MiddleCenter
.FlatStyle = FlatStyle.Flat
.Location = New Point(10, y)
.Width = 20
.Height = 20
End With
' Attach the Click Event handler
AddHandler aImageButton.Click, AddressOf ImageButtonClickHandler
' Finally, add the control to the Form
tpgContact.Controls.Add(aImageButton)
End If
Dim aButton As New Button
tpgContact.Controls.Add(aButton)
aButton.Text = " "
aButton.Name = entity
aButton.Location = New Point(38, y)
'aButton.DialogResult = DialogResult.OK
aButton.BackColor = Color.LightGray
aButton.Height = 20
aButton.Width = 30
aButton.Font = New System.Drawing.Font("Arial", 7.25!)
AddHandler aButton.Click, AddressOf ContactViewClickHandler
Dim aTextName As New Label
tpgContact.Controls.Add(aTextName)
aTextName.Text = fullName
aTextName.Location = New Point(75, y)
aTextName.Width = 189
aTextName.Height = 20
aTextName.BackColor = Color.White
aTextName.TextAlign = ContentAlignment.MiddleLeft
aTextName.Font = New System.Drawing.Font("Arial", 7.25!)
Dim aTextCompany As New Label
tpgContact.Controls.Add(aTextCompany)
aTextCompany.Text = company
aTextCompany.Location = New Point(267, y)
aTextCompany.Width = 149
aTextCompany.Height = 20
aTextCompany.BackColor = Color.White
aTextCompany.TextAlign = ContentAlignment.MiddleLeft
aTextCompany.Font = New System.Drawing.Font("Arial", 7.25!)
If phone <> "" And fax <> "" And cellPhone <> "" And pager <> "" And homePhone <> "" Then
Dim aCombobox As New ComboBox
tpgContact.Controls.Add(aCombobox)
Dim i = 0
If phone <> "" Or fax <> "" Or cellPhone <> "" Or pager <> "" Or homePhone <> "" Then
If phone <> "" Then
aCombobox.Text = "B: " & phone
End If
If fax <> "" Then
aCombobox.Items.Add("F: " & fax)
End If
If cellPhone <> "" Then
aCombobox.Items.Add("M: " & cellPhone)
End If
If pager <> "" Then
aCombobox.Items.Add("P: " & pager)
End If
If homePhone <> "" Then
aCombobox.Items.Add("H: " & homePhone)
End If
Else
aCombobox.Items.Clear()
End If
aCombobox.Location = New Point(419, y)
aCombobox.Font = New System.Drawing.Font("Arial", 7.25!)
aCombobox.Width = 120
aCombobox.Height = 20
Else
Dim aWhiteText As New Label
tpgContact.Controls.Add(aWhiteText)
aWhiteText.Text = " "
aWhiteText.Location = New Point(419, y)
aWhiteText.Width = 120
aWhiteText.Height = 18
aWhiteText.BackColor = Color.White
End If
If email <> "" Then
Dim aButtonEmail As New Button
tpgContact.Controls.Add(aButtonEmail)
aButtonEmail.Text = email
aButtonEmail.Location = New Point(542, y)
aButtonEmail.Width = 48
aButtonEmail.Height = 20
aButtonEmail.BackColor = Color.LightGray
aButtonEmail.Font = New System.Drawing.Font("Arial", 7.25!)
AddHandler aButtonEmail.Click, AddressOf EmailClickHandler
Else
Dim aWhiteText As New Label
tpgContact.Controls.Add(aWhiteText)
aWhiteText.Text = " "
aWhiteText.Location = New Point(542, y)
aWhiteText.Width = 48
aWhiteText.Height = 20
aWhiteText.BackColor = Color.White
End If
y += 25
Loop
DR.Close()
objConn.Close()
End Function
Private Sub ContactViewClickHandler(ByVal sender As System.Object, ByVal e As System.EventArgs)
results = CType(CType(sender, Button).Name, String)
'MessageBox.Show(results)
Dim contactView As New frmContactEdit
contactView.ShowDialog()
End Sub
Public Sub EmailClickHandler(ByVal sender As Object, ByVal e As System.EventArgs)
results = CType(CType(sender, Button).Text, String)
Dim mail = "mailto:" & results
'MessageBox.Show(mail)
System.Diagnostics.Process.Start(mail)
End Sub
Public Sub ImageButtonClickHandler(ByVal sender As Object, ByVal e As System.EventArgs)
results = CType(CType(sender, Button).Name, Int32)
'MessageBox.Show(results)
Dim DA As New OleDbDataAdapter
objConn.Open()
DA.SelectCommand = New OleDbCommand
DA.SelectCommand.Connection = objConn
DA.SelectCommand.CommandType = CommandType.Text
DA.SelectCommand.CommandText = "UPDATE Contacts set primary_contact = 0 WHERE client_entity_id = " & client_entityID
DA.SelectCommand.ExecuteNonQuery()
Dim DA2 As New OleDbDataAdapter
DA2.SelectCommand = New OleDbCommand
DA2.SelectCommand.Connection = objConn
DA2.SelectCommand.CommandType = CommandType.Text
DA2.SelectCommand.CommandText = "UPDATE Contacts set primary_contact = 1 WHERE entity_id = " & results
DA2.SelectCommand.ExecuteNonQuery()
objConn.Close()
ContactView()
End Sub
There are two problems in here, first, when I click the aImageButton, it didn't refresh to the update one. The contactView() in ImageButtonClickHandler not working. Second, IN ContactViewClickHandler, it opens a new forms to edit the info, after this window close, how to update the newest data and reload the dataReader?
Lisa
|
|
|
|
|
The DataReader object returns table rows in a "forward-only" manner. Meaning you can't rewind it and re-read the row that it just returned. The only way to get it to go backwards is to destroy the current DataReader object and create a new one, which will start returning rows from the beginning of the table again.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
where and how to destroy the current dataReader in my app?
Lisa
|
|
|
|
|
In your code, the DataReader that you create in the ContactView function is destroyed when execution reaches the end of the function. A new one is created and destroyed every time you execute ContactView.
In your code, though, you have no way of destroying all the controls you made so you can create new ones with the updated data. I get the feeling that your code IS getting the updated values from the database, but since you never destroyed the controls with the old data, the new controls your creating are being created BEHIND the controls you already have, and are therefore not visible.
IMHO, you've really got to use a DataGrid for this. You'll end up getting the functionality you want with about half the lines code that you've already written, and have yet to write more to get it to really work.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
I want to user DataGrid, but how can I have buttons and combobox inside the datagrid?
Lisa
|
|
|
|
|
I'm trying to find a good tutorial on the custom DataGrid's for Windows Forms, but have so far come up emtpy. I keep finding everything under the sun for the ASP.NET DataGrid, though. How sad is that?!
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|