|
iam using select case statement .in this iwant to work with two select statements by which one select statement works on the user eneterd value and other select statement should work for every select case ..is it possible
|
|
|
|
|
Like another control statement the case statement could also be nested but nested will give the complex code to you so i suggest you to call function so on select statement you could call the function according to the values entered by user.
With Regards
Yogesh Agarwal
|
|
|
|
|
Hi All
i have a grid control (Sheridan Grid) in my visual basic 6 application this grid has his first row as a checkbox column,
Now the problem is
I want to call a function when user check or uncheck the column but i unable to do the same i tried the aftercolupdate event but it will show the runtime error and my application will close after that error. The calculation goes fine but the problem is that run time error.
The error is :-
"Visual Basic has encountered a problem and needs to close. We are sorry for the inconvenience"
Then it display the message for sending the problem to microsoft with send and din't send button
plz help in resolving the problem ...
With Regards
Yogesh Agarwal
|
|
|
|
|
My Problem was solved, plz do not reply
with Regards
Yogesh Agarwal
|
|
|
|
|
Great job on completing it yourself. However, you should post the code that let to your solution, so if any other member here has the same problem, they may stumble upon your post and be able to fix theirs quickly!
I'm going to become rich when I create a device that allows me to punch people in the face over the internet.
"If an Indian asked a programming question in the forest, would it still be urgent?" - John Simmons / outlaw programmer
|
|
|
|
|
I use the Change Event for Grid Control and check the column Index if it the desire column then i call the function to do the task i suppose to do.
<br />
<br />
Private Sub gridOptional_Change()<br />
If gridOptional.Col = 0 Then<br />
calculateamt<br />
<br />
ElseIf gridOptional.Col = 5 Then<br />
gridOptional.Columns(6).Value = gridOptional.Columns(4).Value * gridOptional.Columns(5).Value<br />
calculateamt<br />
End If<br />
<br />
End Sub<br />
<br />
<br />
With Regards
Yogesh Agarwal
|
|
|
|
|
I hv downloaded following codes to save image from vb.net 2005 to Mysql.
Private Sub cmdSaveDB_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdSaveDB.Click
If picShowPicture.Image Is Nothing Then Exit Sub
Dim ms As MemoryStream = New MemoryStream
picShowPicture.Image.Save(ms, ImageFormat.Jpeg)
Dim bytBLOBData(ms.Length - 1) As Byte
ms.Position = 0
ms.Read(bytBLOBData, 0, ms.Length)
Dim prm As New MySql.Data.MySqlClient.MySqlParameter("@BLOBData", _
MySql.Data.MySqlClient.MySqlDbType.Blob, _
bytBLOBData.Length, ParameterDirection.Input, False, _
0, 0, Nothing, DataRowVersion.Current, bytBLOBData)
Dim ConnectionString As String = "SERVER=localhost;" & _
"PORT=3306;DATABASE=pictureDB;User Id=root;" & _
"PASSWORD=pass;"
Dim QueryString As String = "INSERT INTO blobtest ( BLOBData ) VALUES ( @BLOBData )"
MsgBox(QueryString)
Dim myConnection As New MySqlConnection(ConnectionString)
Dim myCommand As New MySqlCommand(QueryString)
myCommand.Connection = myConnection
myCommand.Parameters.Add(prm)
'Open the connection
myConnection.Open()
'Execute the query
myCommand.ExecuteNonQuery()
'Close the connection
myConnection.Close()
End Sub
But it is giving me a error saying imageformat is not declared.. How to solve it.. Plse help me..
|
|
|
|
|
Please read on how to ask good questions, 'please help me' is not a reasonable header. Everyone here wants help.
Which line gives the error ? As the word 'ImageFormat' does not appear in the code you pasted, I assume it's not one of these lines ? Have you tried using the debugger ?
This is what happens if you copy code off the web at random, articles and code snippets are great, but you need to take the time to understand them before you use them.
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
You have to import the namespaces that the code uses.
If you look up ImageFormat in the documentation, you see that it's in the System.Drawing.Imaging namespace.
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
|
How do I get the id (primary key) of a row that I just insertyed into the database, so that I can insert the id into the foreign key of another table?
|
|
|
|
|
How are you inserting your data? What database are you using?
If you are using SQL Server stored procedures, it is very easy to get using a return parameter set to @@identity.
|
|
|
|
|
I am using the Tables object in SQL Server 2005 Express. I am not using the stored procedures object.
I am using the insert statements that are generated using the data source configuration wizard in Visual Basic 2005.
Is there a way to do it in VB.NET.
|
|
|
|
|
Probably. I use stored procs exclusively, so don't know much about the generated stuff. Microsoft examples tend to revolve around the generated stuff, so you could try MSDN?
|
|
|
|
|
The only reliable way to do it, is to write a stored proc that returns the identity that was just inserted, unless your DB only ever has one user at a time. Throw that auto generated rubbish out and try to write some code instead.
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Christian Graus wrote: The only reliable way to do it, is to write a stored proc that returns the identity that was just inserted, unless your DB only ever has one user at a time.
Actually, as long as you use the same database connection, it's perfectly safe to run the query "select scope_identity()" to get the latest generated id for that connection.
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
IS that ID(primary key) an auto number?? If so you can get the max of that ID.
"Legacy code" often differs from its suggested alternative by actually working and scaling.
—Bjarne Stroustrup
|
|
|
|
|
It is an auto number. Do I just use a database query or is there another way?
|
|
|
|
|
You can use simple query : Select max(id) from table1
"Legacy code" often differs from its suggested alternative by actually working and scaling.
—Bjarne Stroustrup
|
|
|
|
|
There is another way. You can also write a trigger
"Legacy code" often differs from its suggested alternative by actually working and scaling.
—Bjarne Stroustrup
|
|
|
|
|
Yes, what you're being told will work, so long as there's never more than one user on the database at a time. Otherwise, it will not work properly.
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Nilesh Hapse wrote: If so you can get the max of that ID.
No, never do that. That doesn't work if there are more than one user in the system.
There is an easier and perfectly safe method (posted elsewhere in this thread) to get the last generated id, so there is no reason to use this unsafe method to do it. Code tends to be reused, so unless there is a significantly simpler way of doing something under certain conditions, it's always better to use a way that works under any condition.
Methods like using max() to get the id is especially treacherous, as it seems to work perfectly fine as long as you are testing the system with a low number of users, but in the live system it will cause more and more errors when the load increases.
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
And what about second suggestion to use trigger?? Is that safe?
"Legacy code" often differs from its suggested alternative by actually working and scaling.
—Bjarne Stroustrup
|
|
|
|
|
Yes, a trigger would be safe (provided of course that you write the trigger correctly).
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
Guffa wrote: Yes, a trigger would be safe (provided of course that you write the trigger correctly).
I thought about trigger after max . Not sure why?
"Legacy code" often differs from its suggested alternative by actually working and scaling.
—Bjarne Stroustrup
|
|
|
|