|
hi Everybody
i am working on window application in vb.net
actually i want to show my form under the visio window means to make visio as parent window for that form, how can i do that .
if anybody know please help me.
Thanks
|
|
|
|
|
You can't. You cannot make your application a child window of another application.
If you want to do something like this, you'll have to write an Add-On for Visio.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
yes i know that it can be done by using set paarent window but it is not working or i used in the wrong way if anyone of you know please help me
Thanks
-- modified at 6:47 Friday 7th April, 2006
|
|
|
|
|
Once again, NO, YOU CAN'T DO THIS!!
You can NOT make your window a child window of another application!
Why? Because when the other application repaints it's own window, your window will never get repainted. This is because your window is not going to get, and can NOT get, the WM_PAINT messages it needs to tell it to repaint at the appropriate time.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
but in visual basic 6.0 i do this several time by using set parent API.
Is this APi doesnot work in vb.nrt
Thanks
|
|
|
|
|
Exactly!
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Hey,
Me : Newbie in VS.NET2005
Question :
I have an application in which i define a connectionstring, sqlconnection etc.
then i can use this connection on this form!
But on another form in the same project i need exactly the same DB (Connectionstring,...)
and I don't want to type this twice!
So if my DB changes of server or gets a new name when the appplication goes live, i only have to change this at one place!
I know you can do something like this in ASP.NET
special section in WEB.CONFIG,
But where do you do this for a normal Application!
Thnx
A.
|
|
|
|
|
APP.CONFIG
how vital enterprise application are for proactive organizations leveraging collective synergy to think outside the box and formulate their key objectives into a win-win game plan with a quality-driven approach that focuses on empowering key players to drive-up their core competencies and increase expectations with an all-around initiative to drive up the bottom-line. But of course, that's all a "high level" overview of things
--thedailywtf 3/21/06
|
|
|
|
|
And Where do i find this, how do i use it in my code?
|
|
|
|
|
Go to the Project menu, then click Add New Item. In the window that comes up, find and double-click Application Configuration File. A new file called app.config will be added to your project. Double-click this file to open it in an editor window. You'll see a bunch of XML stuff.
Under the <configuration> tag, add something that looks like this:
<configuration>
<configSections>
</configSections>
<appSettings>
<add key="myConnectionString" value="your connection string goes here!" />
</appSettings>
.
.
.
Now, to get this connection string from anywhere inside your app, just use:
Imports System.Configuration
.
.
.
Dim connString As String = ConfigurationSettings.AppSettings("myConnectionString")
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Hi
I want to dynamically cast to whatever type obj is. So I want to change the Boolean part to something like obj.GetType().
obj = CType(node.SelectSingleNode(name).InnerText, Boolean)
|
|
|
|
|
That's not going to work since there is no way to determine what the object type is from it's XML text representation. For example:
<xml version="1.0" encoding="utf-8" ?>
<ComplexNumber>
<R>3</R>
<I>5</I>
</ComplexNumber>
"3" can be anything. So you'll have to determine what that is SUPPOSED to be ahead of time before you attempt a conversion. Is that "3" really a string value containing a 3 character? Is it an Integer? Is it supposed to be a Double or a Decimal? How about a Byte? There's just no way to determine that.
You have to know ahead of time what that type is before you call CType, or any other conversion method, so you can supply the appropriate type name in the CType call. One method of doing this would be to attribute your XML elements with the Type name of the value, like this:
<xml version="1.0" encoding="utf-8" ?>
<ComplexNumber>
<R typename="System.Integer">3</R>
<I typename="System.Integer">5</I>
</ComplexNumber>
Retrieve the value of the typename attribute, then pass it into a conversion like this:
obj = Convert.ChangeType(xmldoc.SelectSingleNode(name).InnerText, Convert.GetTypeCode(typename))
But, you have another problem. What is defining obj ??? Anything you return from this line of code will get boxed, if possible, by the Type that is obj , like if obj was defined as Object . This is a nice little performance hit if you're doing this many times...
Dave Kreskowiak
Microsoft MVP - Visual Basic
-- modified at 16:05 Thursday 6th April, 2006
|
|
|
|
|
Hi Dave,
Thanks for the response. My question was probably not very clear. What I want to do is not cast using the xml innertext type but the obj(name) type.
I know this looks wired and I guess it is. What I’m doing (and I know when it comes to performance it is just wrong) is to map from the xml node to a property in the object using the name of the properties. Now it becomes even worse, I use reflection to get the properties names and I invoke them instead of setting the normal way. I know this is extremely inefficient in performance terms, but it is very dynamic and I like the simplicity of the code.
So what happens is:
1) An XML node is read
2) Loop over the child nodes
3) Set the object (Query) properties to the node value with the same name. (Dynamically casting to the property’s type)
Here is the function that does the trick.
<br />
'Builds a query from a xml node<br />
Private Function BuildQuery(ByRef node As XmlNode) As Query<br />
<br />
Try<br />
Dim obj As New Query<br />
<br />
'Map xmlnodes to properties where the names match<br />
For Each name As String In obj.Properties<br />
If Not node.SelectSingleNode(name) Is Nothing Then<br />
<br />
'Dynamically cast to the type of the property <br />
Dim code As Integer = CInt(Convert.GetTypeCode(obj(name)))<br />
obj(name) = Convert.ChangeType(node.SelectSingleNode(name).InnerText, code)<br />
<br />
End If<br />
Next<br />
<br />
Return obj<br />
Catch ex As Exception<br />
Throw New ApplicationException("Falied to build Databasequery object", ex)<br />
End Try<br />
End Function<br />
On a side note I only use this rarely in the code, for reading data into object and moving data from object into file or database. These are expensive operations anyway so the overhead is not that great compared to the actual workload. That is at least the theory, but I need to do some test to check if it is correct.
Thank you very much for your reply.
Johan Hertz
|
|
|
|
|
I guess I didn't understand what you were asking the first time around. I'm happy that you found a way to do it! I, personally, have never had the need to do something like this...
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Hi Dave,
To honest, I don’t really “need” to do it in this way either. But it is a nice little exercise, and I think it might even be usefully
Once again thanks for your help, it was very appreciated.
|
|
|
|
|
hi friends
i am working in vb6, i have a main form which contains a menu and deferent menu item liek add edit delte etc i want when i click menu itemm Add a form will open on it, i di dnot now how i can do this help me plz
regards
Farooq Azam
|
|
|
|
|
Handle the Click event of the menu item, then just create a new instance of your Add form and show it. Since this is in response to Adding something to a document, you'll probably want to show the form Modally.
Dim addForm As New MyAddForm
addForm.Show vbModal, Me
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
thanks friend Dave i will need ur help in future too regards bye
Farooq Azam
|
|
|
|
|
can anybody send me the code how to insert data into database using my form textbox values.
Aavesh
Aavesh
|
|
|
|
|
What database are you using?
|
|
|
|
|
i'm using mysql please give me the code i'm getting frustrated
thanx
|
|
|
|
|
Do you have a connection already established to your database?
|
|
|
|
|
yes i'm sending u my code in which i have a problem
Dim ConnStr As String = "Driver={MySQL ODBC 3.51 Driver};Server=localhost;Database=AgentImg;uid=root;pwd=;option=3"
Dim con As OdbcConnection = New OdbcConnection(ConnStr)
Dim ad As OdbcDataAdapter = New OdbcDataAdapter()
' Dim str As String = "insert into Category(Category_Name) Values(" + TextBox1.Text + ")"
'Dim str As String = "insert into Category values(@id,@Category_Name,'@Category_Img',@Category_Desc)"
Dim InsCom As OdbcCommand = New OdbcCommand(str, con)
ad.InsertCommand = InsCom
ad.InsertCommand.Parameters.Add(New OdbcParameter("@Category_Name", OdbcType.VarChar, 20))
ad.InsertCommand.Parameters("@Category_Name").Value = TextBox1.Text
ad.InsertCommand.Parameters.Add(New OdbcParameter("@Category_Img", OdbcType.VarChar, 20))
ad.InsertCommand.Parameters("@Category_Img").Value = TextBox2.Text
ad.InsertCommand.Parameters.Add(New OdbcParameter("@Category_Desc", OdbcType.VarChar, 20))
ad.InsertCommand.Parameters("@Category_Desc").Value = TextBox3.Text
con.Open()
ad.InsCom.ExecuteNonQuery()
con.Close()
please i have checked twice field names are correct.
but when i try to store the values .it stores null.
please give me a quick reply.
|
|
|
|
|
I think your problem might be this line.
Dim str As String = "insert into Category(Category_Name) Values(" + TextBox1.Text + ")"
Try changing it to Dim str As String = "insert into Category(Category_Name) Values (" & TextBox1.Text & ")"
Because if its inserting null values then it must be the parameter passing that is wrong.
|
|
|
|
|
And if that doesn't work. Stop using Value = TextBox3.Text. Specify a veriable like Dim txt as String = Textbox3.text. And make sure that it is actually holding a value before you pass it.
|
|
|
|