|
Oh, you'r estoring a bitmap ? In that case, yes, I'd store it in the DB, if it's sensitive. The file system won't let you stop anyone accessing those files.
Christian Graus - C++ MVP
'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert
|
|
|
|
|
I am trying to get the dates to insert correctly in a MySQL db. All of the date columns keep being inserted as 0000-00-00 instead of the date that suppose to be inserted. I was told to use a parameterized query which I am not quite familiar with but I tried some code but still did not work. Can someone look over my code and see what I am doing wrong as far as creating a parameterized query?
Here is some code that I tried but the dates are still being displayed as 0000-00-00 in db:
Dim myConnString As String = "DRIVER={MySQL ODBC 3.51 Driver};" & _
"SERVER=192.168.1.27;" & _
"DATABASE=testship;" & _
"USER=;" & _
"PASSWORD=;" & _
"OPTION=3;"
Dim MyConnection As New Odbc.OdbcConnection(myConnString)
MyConnection.Open()
Dim MyCommand As New Odbc.OdbcCommand
MyCommand.Connection = MyConnection
MyCommand.CommandText = "INSERT INTO ls_orderitems (OrderDate, OrderCustomer, OrderAcctNum, OrderType, OrderSoNum, OrderItemPartNum, OrderItemPartDesc, OrderItemQty, OrderItemQtyRec, OrderItemQtyDtRec, OrderItemBO, OrderItemBODt,OrderItemCanceled, OrderItemCanceledDt, OrderItemNotes, OrderItemPONum, OrderItemRetailPrice, OrderItemSalePrice, Status, InsertDate) VALUES ('" & OrderDate & "','" & OrderCustomer & "','" & OrderAcctNum & "','" & OrderType & "','" & OrderSoNum & "','" & OrderItemPartNum & "','" & OrderItemPartDesc & "','" & OrderItemQty & "','" & OrderItemQtyRec & "','" & OrderItemQtyDtRec & "','" & OrderItemBO & "','" & OrderItemBODt & "','" & OrderItemCanceled & "','" & OrderItemCanceledDt & "','" & OrderItemNotes & "','" & OrderItemPONum & "','" & OrderItemRetailPrice & "','" & OrderItemSalePrice & "','" & Status & "','" & InsertDate & "'" & ")"
MyCommand.Parameters.Add(New Odbc.OdbcParameter("OrderDate", OrderDate))
MyCommand.Parameters.Add(New Odbc.OdbcParameter("OrderCustomer", OrderCustomer))
MyCommand.Parameters.Add(New Odbc.OdbcParameter("OrderAcctNum", OrderAcctNum))
MyCommand.Parameters.Add(New Odbc.OdbcParameter("OrderType", OrderType))
MyCommand.Parameters.Add(New Odbc.OdbcParameter("OrderSoNum", OrderSoNum))
MyCommand.Parameters.Add(New Odbc.OdbcParameter("OrderItemPartNum", OrderItemPartNum))
MyCommand.Parameters.Add(New Odbc.OdbcParameter("OrderItemPartDesc", OrderItemPartDesc))
MyCommand.Parameters.Add(New Odbc.OdbcParameter("OrderItemQty", OrderItemQty))
MyCommand.Parameters.Add(New Odbc.OdbcParameter("OrderItemQtyRec", OrderItemQtyRec))
MyCommand.Parameters.Add(New Odbc.OdbcParameter("OrderItemQtyDtRec", OrderItemQtyDtRec))
MyCommand.Parameters.Add(New Odbc.OdbcParameter("OrderItemBO", OrderItemBO))
MyCommand.Parameters.Add(New Odbc.OdbcParameter("OrderItemBODt", OrderItemBODt))
MyCommand.Parameters.Add(New Odbc.OdbcParameter("OrderItemCanceled", OrderItemCanceled))
MyCommand.Parameters.Add(New Odbc.OdbcParameter("OrderItemCanceledDt", OrderItemCanceledDt))
MyCommand.Parameters.Add(New Odbc.OdbcParameter("OrderItemNotes", OrderItemNotes))
MyCommand.Parameters.Add(New Odbc.OdbcParameter("OrderItemPONum", OrderItemPONum))
MyCommand.Parameters.Add(New Odbc.OdbcParameter("OrderItemRetailPrice", OrderItemRetailPrice))
MyCommand.Parameters.Add(New Odbc.OdbcParameter("OrderItemSalePrice", OrderItemSalePrice))
MyCommand.Parameters.Add(New Odbc.OdbcParameter("Status", Status))
MyCommand.Parameters.Add(New Odbc.OdbcParameter("InsertDate", InsertDate))
MyCommand.ExecuteNonQuery()
MyConnection.Close()
|
|
|
|
|
OK. First, you're SQL is wrong. It's not written to accept parameters. You're still just building a string that represents an SQL statement and not doing it correctly. You have single and double quote marks interchanged and are probably violating how certain fields should be passed in. The way it's coded now, it looks like your passing in ALL of your values as strings, and that's not going to work. It should be something like this (at least in MS TSQL, I don't know how MySQL denotes a parameter):
MyCommand.CommandText = "INSERT INTO ls_orderitems (OrderDate, OrderCustomer, OrderAcctNum, " & _
"OrderType, OrderSoNum, OrderItemPartNum, OrderItemPartDesc, OrderItemQty, OrderItemQtyRec, " & _
"OrderItemQtyDtRec, OrderItemBO, OrderItemBODt,OrderItemCanceled, OrderItemCanceledDt, " & _
"OrderItemNotes, OrderItemPONum, OrderItemRetailPrice, OrderItemSalePrice, Status, InsertDate) " & _
"VALUES (@OrderDate, @OrderCustomer, @OrderAcctNum, @OrderType, @OrderSoNum, @OrderItemPartNum, " & _
"@OrderItemPartDesc, @OrderItemQty, @OrderItemQtyRec, @OrderItemQtyDtRec, @OrderItemBO, " & _
"@OrderItemBODt, @OrderItemCanceled, @OrderItemCanceledDt, @OrderItemNotes, @OrderItemPONum, " & _
"@OrderItemRetailPrice, @OrderItemSalePrice, @Status, @InsertDate)"
See all the "@" in front of the names? This tells TSQL that this is a named parameter. I have no idea if this is going to work with MySQL. I've never used MySQL.
Now, on to you're parameter objects. You've managed to create the parameters, but you did not tell each parameter what database type it is, preferrably maching the type you gave that column in the database. This is what is going to give the OdbcParameter object the information it needs to convert your data into something that the database is going to understand, like your dates. These example won't be accurate because I have no idea how you defined your columns in the database table:
MyCommand.Parameters.Add(New Odbc.OdbcParameter("@OrderDate", OdbcType.Date)).Value = OrderDate
MyCommand.Parameters.Add(New Odbc.OdbcParameter("@OrderCustomer", OdbcType.Int)).Value = OrderCustomer
MyCommand.Parameters.Add(New Odbc.OdbcParameter("@OrderAcctNum", OdbcType.Int)).Value = OrderAcctNum
.
.
.
Seriously, pickup a book on MySQL and learn to write and execute SQL statements by hand, before you try and get your code to do it for you. If you don't understand how the SQL works, it's impossible to write the code to do it.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Hi,
I'm new to vb.net, i was working on a college project, its just like a notepad.
similar to notepad, now i want to save a file as html file and i don't know how to do it. can any one help me.
Thanks in advance.
|
|
|
|
|
To save a file as html, just add the html extension to the file name. An html file is just a regular text file. Make sure that the encoding you use for the file is the same as specified in the html code.
What is it that you are going to write to the file? Do you have the html code, or do you have a text that you want to turn into html code?
---
Year happy = new Year(2007);
|
|
|
|
|
|
Does anyone know how to create a listview like the one used in Outlook 2003/2007 with expandable levels.
|
|
|
|
|
This is all I could find: Outlook Bar and Outlook Style Sidebar.
They're both in C# though.
Trinity: Neo... nobody has ever done this before.
Neo: That's why it's going to work.
|
|
|
|
|
Thanks for that but I was thinking about the listview on the right hand side of the screen in outlook - Inbox.
|
|
|
|
|
I don't use Outlook, so I'm not exactly sure what you are talking about. But I think it's just a regular ListView.
Trinity: Neo... nobody has ever done this before.
Neo: That's why it's going to work.
|
|
|
|
|
Can you add collapsable levels to a standard listview?
|
|
|
|
|
Sorry, that would be a TreeView. Like I said, I don't use Outlook so I wasn't sure what you were talking about.
Trinity: Neo... nobody has ever done this before.
Neo: That's why it's going to work.
|
|
|
|
|
I currently over do the redudancy checks in my code such as If Not IsNothing(variable) AndAlso If Not IsDBNull(variable) Then and I am wondering when and where the various types of "Nothing" occur.
When a value is sent to the database does it see "Nothing" as "NULL"?
When a value is returned from the DB does the code see "DBNull" as "Nothing" or "Null"?
Just curious, I dont want to type more than I have to.
Cleako
|
|
|
|
|
a db knows nothing about 'nothing' it knows only about 'null'
if are reading from a db you only need to check 'isdbnull' which is a function that checks if the value equals 'null'
|
|
|
|
|
When communicating with a database use DBNull to indicate that the value of the column should be null (or Nothing in VB).
The reason for this is that there is to distinguish two different types of nullness. For example if you have a query and use ExecuteScalar to get a result you need to distinguish between Nothing (or null in C#) and DBNull . Nothing means that your query return no results. DBNull means that the query returned a result, and that result was null . (i.e. the value of the column was null ).
|
|
|
|
|
To bring some order in the contradictory replies...
Null in VB is the same as System.DBNull , and is how a database null value is represented when it's handled in the code.
Nothing in VB is the same as null in most other languages, and is the value of a reference that isn't referencing any object. This has nothing to do with the database.
---
Year happy = new Year(2007);
|
|
|
|
|
I have a treeview as a menu in my Mdi form. I am seting all form locations to the right of the menu. When I minimize a form it goes behide the treeview control. How do I move the minimized form over to the right so I can see it. Any help will be greatly appreciated
|
|
|
|
|
MDI Child forms are rendered inside another control on the Parent form. This control is called the MDIClient. Search the Controls collection of the MDI Parent form and you can get a reference to the Client control. Once you have the reference you can manipulate the control just like any other control you drop on a form, even move and resize it so it leave you room on the left side of the MDI Parent form for your TreeView control.
For Each c As Control In Me.Controls
If TypeOf c Is MDIClient Then
Dim mdic As MdiClient = DirectCast(c, MdiClient)
mdic.Dock = DockStyle.None
mdic.Anchor = AnchorStyle.None
mdic.Location = New Point(20, 20)
mdic.Size = New Size(200, 200)
Exit For
End If
Next
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Hi All,
is it possible to search & find a specific MAC address of NIC card without knowing the IP address or any other details in VB .net?
B Regards
Ajith
Ajith
|
|
|
|
|
No, there isn't. If you can provide some kind of detail about the target machine, there's no way for your code find that specific machine. You're best bet would be the IP address. But, looking up the MAC address using the IP only works if the machine is on the same segment as the one looking up the MAC. If there is a router between you and the target machine, you'll end up getting the MAC address of the near-side of the router, not the machine you're trying to resolve.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Hi everyone, i am not sure if this is posible but i am asking anyway.
I am building an application that reads from a database and fills a dataset.
each time i click a next button in my program i am able to move to the next record..my coding works fine and everything but there is a lot of records.. i have a find function that finds any particular data in the database and thats fine too...but...
what i need is, how do i get my program to traverse through all the records by clicking and holding down the mouse pointer on my next button. that is, when i click and hold down the mouse pointer on the next button it continues showing the next record until i release the mouse pointer..
I hope this information was clear enough..please help..
Thanks in advance..
|
|
|
|
|
have you tried using the mousedown and mouseup events? put loop in the event checking a flag that is turned off by the mouseup event
----------------------------------
**mousedown event**
mbMouseIsDown=true
do while mbMouseIsDown and not eof
'get next record
'display record
application.doevents 'make sure form shows each record and windows can do some other stuff
loop
mbmouseisdown=false 'incase eof was hit
-----
**mouseup event**
mbmouseisdown=false
|
|
|
|
|
How does one make use of high quality icons in .Net?
I created my own icons which are of a high quality but when I use them in my winform they turn to moosh!
See sample here[^]
My icon files are 248 x 248 pixels, 96dpi, 32Bit Depth
you can't forget something you never knew...
"Watching Migthy Joe Young made me hate my life..................................I want a gorilla!" A. Havemann
|
|
|
|
|
It' because you are using a large icon to show as a small icon. Try resizing your icon to about 16x16 or 32x32 pixels, that should help.
If you need a good program, I would suggest Icon Sushi.
Trinity: Neo... nobody has ever done this before.
Neo: That's why it's going to work.
|
|
|
|
|
Hey guys,
I've tried looking everywhere and I can't seem to find a solution. Basically, I want to change the inside "box" of an MDI parent form (where an MDIChild can go) and round the corners there. I tried drawing a "border" around the MDIChild and forms, I also thought I could set the background colour to transparent of the MDI Parent, though this didn't work.
If someone could point me in the right direction or let me know it cannot be done, that would be great.
Thanks,
Daniel
|
|
|
|
|