|
I think you need to create the .mdb file in MS Access. After that you can create tables using connection and command objects to execute SQL statements. Here is a quick example of what I'm talking about:
Dim strConn as String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source='C:\MyDatabase.mdb'"
Dim myConnection as System.Data.OleDb.OleDbConnection(strConn)
Dim myCommand as System.Data.OleDb.OleDbCommand
myCommand.Connection = myConnection
myCommand.CommandText = "CREATE TABLE MyTableName(Column1 varchar(20) NULL, Column2 decimal(5,2) NULL)"
Ooops...I work with VS 2003 and VS 2005, I'm not sure how this translates to VB6.
Hope this helps.
-- modified at 11:00 Friday 26th May, 2006
|
|
|
|
|
Hi all,
This is a very simple UserControl which only contains a button on it and when this button is clicked, it draws a Rectangle object on it. However, I am having a problem that this rectangle gets visually disappeared after it's covered by some other windows form(I hope you understand what I mean by this). I know that if I want to permanently maintain it I will have to draw it in the paint method because the paint method is called every time the control needs to redraw itself, however, I want to draw this rectangle only when the button is clicked so it doesn't seem appropriate if I place the code in the paint method.
So...would somebody please tell me the best way to resolve this problem that you can think of? I would love to know if there is more than one solution. Thank you very much to you all.
<br />
Partial Public Class UserControl1<br />
Inherits UserControl<br />
<br />
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click<br />
Me.CreateGraphics.DrawRectangle(Pens.Blue, New Rectangle(60, 60, 40, 40))<br />
End Sub<br />
End Class<br />
<br />
|
|
|
|
|
The UserControl will be redrawn by the OS when the form is refreshed or the control is invalidated.
Your method paints the rectangle when the button is clicked but, does not provide for repainting of the control when other events cause it to be invalidated. Placing additional code in the OnPaint event is the standard method for persisting the painting of a control
You can make your clicked event rectangle image persist by placing code in the Button1 OnPaint event that paints one image if the control has been clicked (selected) and a different image if it has not been clicked.
in OnPaint Event
If <Button1 is clicked> then
<draw clicked image>
else
<draw unclicked image>
end if
|
|
|
|
|
Thanks a lot. This seems a nice approach.
However, I am unable to find the method to determine if the button is clicked in the MSDN website. I was looking for something like IsClicked() or IsSelected() but I couldn't find it.
|
|
|
|
|
If the clicked button keeps the focus then you can use the focus property to determine how to paint the control. If it does not then you will need to create a boolean to store the clicked state. Initialize the boolean to false and in the buttons click event set it to true.
|
|
|
|
|
I am creating a picture gallery in which the user can scroll forward and backwards. How do I connect the pictures from my folder to the databse. What are the best controls and how to use them?
|
|
|
|
|
|
you can convert an image to a stream then store it to an access database
Dim ms As New MemoryStream<br />
PictureBox1.Image.Save(ms, PictureBox1.Image.RawFormat)<br />
Dim imageX() As Byte = ms.GetBuffer<br />
ms.Close()<br />
After this step you already have an image in bytes() - imageX
Now.. assuming you have an access database with three fields. Message, Name, and PiC (pic is an OLE Object in access)
You need to use an OledbCommand's Parameter to pass the values correctyl.
here's How to Do it.
<br />
oledbcommand1.Parameters.Clear()<br />
oledbcommand1.Parameters.Add(New OleDbParameter("@MESSAGE", OleDbType.WChar, 50)).Value = TextBox1.Text<br />
oledbcommand1.Parameters.Add(New OleDbParameter("@NAME", OleDbType.WChar, 50)).Value = TextBox2.Text<br />
oledbcommand1.Parameters.Add(New OleDbParameter("@PIC", OleDbType.Binary)).Value = image<br />
If VEN.Insert("INSERT INTO Table1 ( MESSAGE , NAME1 , PIC ) VALUES ( ? , ? , ? )") = 1 Then<br />
MessageBox.Show("Record Save!")<br />
Me.Close()<br />
End If<br />
ofcourse you need to setup a connection to an access database.
only images added trhough this method can be retireived.
to retrieve the image you need to reverse the step
<br />
Dim i As Integer<br />
If IsDBNull(TABLE.Rows(ROW)(iFIELD)) Then<br />
MsgBox("You Tried to View an Image from an empty record", MsgBoxStyle.OKOnly, "Unable to Display Image")<br />
Exit Sub<br />
End If<br />
Dim arrPicture() As Byte = CType(TABLE.Rows(ROW)("PIC"),byte())<br />
Dim ms As New MemoryStream(arrPicture)<br />
picturebox1.image = System.Drawing.Image.FromStream(ms)<br />
<br />
GUERVEN
Truth or Consequence
|
|
|
|
|
I am attempting to query my AD domain to determine a user's groups. Based on the group membership I can then redirect to a specific page/section. I'm using VB.NET to do the querying and have used numerous examples from this site and other sites.
My issue is related to the account that I'm using to query the domain. See my code below...
The only time that I'm able to retrieve any group membership is when the account (someacct) is a member of Domain Admins. I would like to use a generic account. What am I doing wrong?
<code>
Private Function UserADGroups(ByVal loginname As String) As String
Dim filterval As String, grplist As String, propval As String
Dim propcnt As Integer, I As Integer, eqpos As Integer, commapos As Integer
Dim adentry As New DirectoryEntry("LDAP://somedomain.com", "someacct", "somepassword")
Dim search As New DirectorySearcher(adentry)
filterval = "(sAMAccountName=" & loginname & ")"
search.Filter = filterval
Response.Write(filterval)
search.PropertiesToLoad.Add("memberOf")
Try
Dim srchresult As SearchResult = search.FindOne()
grplist = ""
If Not (srchresult Is Nothing) Then
propcnt = srchresult.Properties("memberOf").Count
For I = 0 To (propcnt - 1)
propval = srchresult.Properties("memberOf")(I)
eqpos = propval.IndexOf("=", 1)
commapos = propval.IndexOf(",", 1)
If (eqpos = -1) Then
grplist = ""
End If
grplist &= propval.Substring(eqpos + 1, (commapos - (eqpos + 1))) & "||"
Next
End If
Return grplist
Catch ex As Exception
If ex.GetType Is GetType(System.NullReferenceException) Then
Response.Write("NO GROUP FOR USER: " & loginname)
Else
Response.Write(ex.Message.ToString & "---" & ex.ToString)
End If
End Try
End Function
</code>
Josh Saiz
|
|
|
|
|
Hi ,
please i needed to compare two DataTables or even compare their two DataView attached to this datatables
i want that the record in the first line in the first column of the datatable1 beeing equal to the record in the first line i the first column in the datatable2
not just the first row other rows too
the same thing if it done just on dataviews
thank you very much
try to be good if you can't be the best
-- modified at 17:20 Thursday 25th May, 2006
|
|
|
|
|
|
thnx man , i did aproximately the same yesterday with that for it solved the problem but i was asking if it is a methode in a class that do this job
may be giving it the two tables as a parameter or something
understand now ??
anyway you are really gentel thank you for your answear
try to be good if you can't be the best
|
|
|
|
|
In design view i see the borders. When i run and view in web browser, there are no boarders, any idea how to fix this?
|
|
|
|
|
Border for what type of object?
|
|
|
|
|
I'm trying to use parameterized queries in VB6. I am using the Oracle ODBC driver version 9.02.00.00. All of the Oracle documentation states that I should be using a colon (: ) to identify the parameter (i.e. :myparam). However, I've found documentation that says I should be using a question mark (?). My code currently works if I have one parameter in a query (i.e. Select name, id, blah from tablename where id=? ). But if I have two parameters (i.e Select name, id, blah from tablename where id=? and blah=?), I receive the following error message.
Multiple-step OLE DB operation generated errors. Check each OLE DB status value, if available. No work was done
Of course this message doesn't help me at all.
Originally, I was expecting to create queries like "Select name,id,blah from tablename where (id= :Id and blah= :Blah) and then Append parameters to the Command object that is executing the query, but that doesn't seem to work.
Any thoughts or ideas are much appreciated.
-- modified at 16:11 Thursday 25th May, 2006
|
|
|
|
|
Hello, does anyone know if this is a bug or if I’m doing it wrong. I’m basically I’m using two For loops to filter out items from one list if they already exits on another (for dual list control). But when I remove a item from the list and I decrement the variable it looks like it does not decrement in memory therefore the inner loop will always read 23 even though I decrement the variable Sourcecounter. SO if outer loop has 2 items and inner loop has 23 and a item matches then I decrement the initial length of the inner loop by SourceLenght - 1. But the variable Sourcecounter will always go to 23 not 22.
Here is the sample
Dim DestinationLenght As Integer = 2
Dim SourceLenght As Integer = 23
Dim Destinationcounter As Integer
For Destinationcounter = 0 To DestinationLenght
Dim Sourcecounter As Integer
For Sourcecounter = 0 To SourceLenght
If Me.lstSource.Items(Sourcecounter).Text.ToString = Me.lstDestination.Items(Destinationcounter).Text.ToString Then
Me.lstSource.Items.RemoveAt(Sourcecounter)
Sourcecounter = Sourcecounter - 1
SourceLenght = SourceLenght - 1
End If
Next
Next
Thanks
|
|
|
|
|
The expressions in the For statement is calculated once when the loop is started, not every iteration.
---
b { font-weight: normal; }
|
|
|
|
|
your concept will work if you use a while loop for the inner loop.
Sourcecounter = 0
Sourcelength = 23
While Sourcecounter < Sourcelength
Sourcecounter +=1
If <condition> then
<do removal>
Sourcecounter -= 1
Sourcelength -= 1
End If
End While
|
|
|
|
|
|
Hi,
I have been using MMC in VB. Im using OCX view instead of MMC listview.
If anybody knows how to align ocx picture box in MMC control, pls let me know.
Thanks in Advance.
Shiva
yemshivakumar@gmail.com
|
|
|
|
|
how to make a textbox that the user can enter only text no numbers! help me please!
Adrian De Battista: .Net Programmer, Java Programmer and Web Designer.
|
|
|
|
|
Hope this helps: set the e.Handled flag to true in the KeyPress event if the value is in the range that you wnat to ignore.
Private Sub TextBox_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txt_user_name.KeyPress<br />
Select Case e.KeyChar<br />
Case "0", "1", "2", "3", "4", "5", "6", "7", "8", "9"<br />
e.Handled = True<br />
End Select<br />
End Sub
|
|
|
|
|
Hiya
I was surfing the web looking for an answer to the same problem and found an extremely low priced suite of controls called ITTeamControls .Net. It includes TextBox that has an AllowedKeys property. You can set it to allow text only, numbers only or all. So there is no code involved.
The web page is http://www.itteam.net/itteamcontrols.html[^]
They have a number of low priced utilities for .Net developers. We have bought stuff off them.
Hope this helps
Rob
-- modified at 5:59 Friday 26th May, 2006
|
|
|
|
|
Hi , it is just pretty simple i had this problem before but i solved it with this
just copy & past & it will work if you don't understand the code i can explain it for you too
Public Function FiltreStringASCII(ByVal var As Integer) As Boolean<br />
<br />
If var = 8 Or var = 32 Or var > 64 AndAlso var < 91 Then<br />
Return True<br />
ElseIf var > 96 AndAlso var < 123 Then<br />
Return True<br />
Else<br />
Return False<br />
End If<br />
<br />
End Function<br />
Public Sub Check(ByVal b As Boolean, ByVal e As System.Windows.Forms.KeyPressEventArgs)<br />
If b = True Then<br />
e.Handled = False<br />
Else<br />
e.Handled = True<br />
End If<br />
End Sub
and now call this methods in the keypress event of the text you want to write just text in :
Private Sub Textbox_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles Matr_Rec.KeyPress<br />
Check(FiltreStringASCII(Asc(e.KeyChar)), e)<br />
End Sub
you can change the visibility of the methods over i just used Public cuz i call those methodes from an other class
try to be good if you can't be the best
-- modified at 8:07 Friday 26th May, 2006
|
|
|
|
|
hello all,
i want to create runtime odbc for sql server. because i have many database in my sql server..my problem is that
for example :
i create my crystal report user database payroll and i create manually odbc for payroll.my problem is that if i not work in different database then my report not show me record. this is why i want to create odbc for runtime. pls help
vipin paliwal
|
|
|
|