|
Scubapro wrote: but I think mathematics won't do the trick here.
BS. Your drawing code still has to draw something from point A to point B. Whatever that something is, even if it's just a single point, you can still test for an intersection between either a line and a point (which side of the line the point is on), or if the point falls inside the area of the textarea.
|
|
|
|
|
The problem is I have over 6000 points and lines that are drawn first.
Then each textrectangle (100+) has to be printed at the right place.
|
|
|
|
|
I am already finish do my report, but I don't know how to connect my application VB.net to Crystal Report 10, may be anyone can help me please?
|
|
|
|
|
Hi,
You may try the below mentioned code snippet to connect your VB.Net application to Crystal Report using ADO.Net.
-------------------------------------------------------------------------
BEGIN CODE
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim rpt As New CrystalReport1() 'The report you created.
Dim myConnection As SqlConnection
Dim MyCommand As New SqlCommand()
Dim myDA As New SqlDataAdapter()
Dim myDS As New Dataset1() 'The DataSet you created.
Try
myConnection = New SqlConnection("Data Source=localhost;Integrated Security=SSPI;" & _
"Initial Catalog=northwind;")
MyCommand.Connection = myConnection
MyCommand.CommandText = "SELECT * FROM Customers"
MyCommand.CommandType = CommandType.Text
myDA.SelectCommand = MyCommand
myDA.Fill(myDS, "Customers")
rpt.SetDataSource(myDS)
CrystalReportViewer1.ReportSource = rpt
Catch Excep As Exception
MessageBox.Show(Excep.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
End Sub
END CODE
-------------------------------------------------------------------------
I hope this helps .
Regards,
John Adams
ComponentOne LLC
|
|
|
|
|
I have a code to print text which prints perfectly when i print through regular printer but when i use the same code to print through a point of sale printer it doesnot print at all.It seems like it has been in the continuous loop.
I am using e.Graphics.DrawString(.......) to print.
Does anybody has some idea in this topic? Can we use e.graphics.drawstring method to print through the point of sale application by changing some settings or something...???
|
|
|
|
|
It has nothing to do with the application itself, rather it would depend entirely on the printer you're using, how it's connected to the machine, are there drivers installed for it, and how you want to print.
Somehow, of all the POS printers I've seen used, very seldom would you go through the Windows printing system to print a page on one of these things. Normally, I've just seen direct printing to either a COM port or LPT port the printer is connected to. You can even printer to a USB based printer if it's drivers expose it on a COM port to applications.
|
|
|
|
|
Hi,
I am stuck on VB.NET 2005, in VB6 i was able to load objects at run-time.
Problem is I am asking user how many textboxes they want and then system will create an array of those textboxes.
Here's the code I was using in VB6. I already had one textbox on form and the index was set to 0.(can't even do that vb.net)
For i = 1 to iSelectedNum
Load TextBox(i)
TextBox(i).Visible = True
TextBox(i).Top = TextBox(i - 1).Top + TextBox(i - 1).Height
TextBox(i).Left = TextBox(i - 1).Left
TextBox(i).Text = ""
Next i
I tried Code Upgrade function from VS 2005 but did not worK!!! Anyone please HELP!!
|
|
|
|
|
Control arrays don't exist under VB.NET.
However, you can create your own quite easily.
Dim myTextBoxes As New List(Of TextBox)
For i = 1 to iSelectedNum
Dim newTextBox As New TextBox()
With newTextBox
.Top = calculated Top value
.Left = calculated Left value
.Text = "whatever text you want"
End With
myTextBoxes.Add(newTextBox)
Me.Controls.Add(newTextBox)
Next
|
|
|
|
|
Thanks a lot Dave. But there's one more question now!? How can i access them (textboxes)?
|
|
|
|
|
Private myTextBoxes As List(Of TextBox)
....
Private Sub CreateTextBoxes(ByVal count As Integer)
myTextBoxes = New Dictionary(Of String, TextBox)
For i As Integer = 1 To count
Dim newTextBox As New TextBox
With newTextBox
.Top = i * 20
.Left = 10
.Size = New Size(100, 18)
End With
myTextBoxes.Add(newTextBox)
Me.Controls.Add(newTextBox)
Next i
...
myTextBoxes(6).ForeColor = Color.Blue
|
|
|
|
|
Thanks for Reply. But there is still one problem in the example of code you wrote, and i cant figure it out why is it happening. It gives me following error
"Error1 -> Value of type 'System.Collections.Generic.Dictionary(Of String, System.Windows.Forms.TextBox)' cannot be converted to 'System.Collections.Generic.List(Of System.Windows.Forms.TextBox)'."
<code>myTextBoxes = New Dictionary(Of String, TextBox)</code>
|
|
|
|
|
Sorry, my mistake. That line should be:
myTextBoxes = New List(Of String)
|
|
|
|
|
In most, if not all, of the Multimedia examples that I'm studying that use MCI functions, alot of the variables are being declared as being of type Integer.
I was wondering why some of them aren't being declared as being variables of type Byte.
As an example: MIDI channels normally will only range from 1 up to 16 and cannot be a negative number.
Still these are being declared as being of type Integer, which takes 2 bytes of memory, if I'm right.
Does anyone know why these aren't being declared as type Byte (which takes only 1 Byte of memory)?
Thanks alot!
Jan
|
|
|
|
|
Jan34 wrote: I was wondering why some of them aren't being declared as being variables of type Byte.
That depends on the function being called and the limitations of VB6. If the function requires a 16-bit signed integer being passed in, a Byte just won't cover it. You MUST match the datatypes of the function being called as closely as possible, but in all cases, you have to pick a type that has a size matching the size of the type expected by the function call. If not, the stack corrupts and the cell will most likely fail, if not your entire application.
Why are you even starting with VB6?? It's a dead language with no further support from Microsoft. You can get VB.NET for free from MSDN.
|
|
|
|
|
I don't know for sure but 2 possible reasons are
1) They wanted to make sure they had a large enough datatype for different options.
2) Although this sounds counter intuitive smaller datatypes are sometimes slower than larger ones. CPUs are generally optimized for certain common datatypes and I think they are optimized for signed (positive or negative) datatypes and usually for datatypes of the processors word size. That would be 32 bits (4 bytes) for most processors out there altough I suppose the newer ones might be optimized for 64 bits.
Unless you have a really large array or something 1 byte of memmory really isn't going to matter much.
|
|
|
|
|
Hello everybody.
I hope this is the right place to post this .
Well, i need to read a stored procedure from vb.net, add some text and compile it.
In other words, i need to modify a stored procedure from vb.net and compile it.
I guess this is possible, but i am not sure how i could do this, maybe using SQLDMO
but i would like to know if someone around here has done this and could give me some advice.
Well i hope i was clear.
Thanks in advance for your time.
Henry de Sousa
|
|
|
|
|
HenrydeSousa wrote: i need to read a stored procedure from vb.net, add some text and compile it.
Are you asking how to read a stored procedure from an SQL Server database, modify that, then put it back in the database and compile it??
|
|
|
|
|
Yes.
For example:
i have this stored procedure:
Before:
CREATE PROCEDURE AddContacts
AS
INSERT INTO Contact
(ContactID, FirstName, LastName) SELECT EmployeeID, FirstName, LastName FROM Northwind.dbo.Employees
GO
i need to read that sp, modify it and put it back in the database and compile it from vb.net.
After:
CREATE PROCEDURE AddContacts
WITH ENCRYPTION
AS
INSERT INTO Contact
(ContactID, FirstName, LastName) SELECT EmployeeID, FirstName, LastName FROM Northwind.dbo.Employees
GO
As you may see i added the text WITH ENCRYPTION. This is what i need to do for every stored
procedure in the database.
modified on Wednesday, January 16, 2008 1:05:30 PM
|
|
|
|
|
OK. After playing around with the SQLDMO COM objects for a little while, it looks like this project will be pretty easy.
I just started with toying with it using this[^] single page and was easily able to connect to the server, enumerate the databases, tables in them, columns, stored procedures, ... I was even able to Script all of these objects very easily.
On the StoredProcedure objects, there's an Alter method that you can use to give the stored procedure a new script.
OOOOORRRRRR
If you're using SQL Server 2005, you can use SMO to do this instead. I think the SMO version is going to be a bit more documented.
|
|
|
|
|
OK. Thanks for your answer.
Let me try it tonight at home.
Henry de Sousa.
|
|
|
|
|
Hi everybody.
Here i want to post the complete code i have finally developed this days to do what i posted a few days ago. I have not found the way to compile the script dinamically, now i have to copy and paste the code in the query analizer, when i find the way to compile the script generated i'll post it here, if someone knows the way to do it, it would be great he/she posts it.
<br />
Imports System<br />
Imports System.IO<br />
Imports SQLDMO<br />
<br />
Public Class SQL_DMO<br />
<br />
Dim oSqlServer As New SQLServer<br />
<br />
Private Sub SQL_DMO_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load<br />
'txt_bd.Text = "Northwind"<br />
'txt_password.Text = "123"<br />
'txt_servidor.Text = "(local)"<br />
'txt_usuario.Text = "sa"<br />
<br />
Dim i As Integer<br />
Dim oNames As SQLDMO.NameList<br />
Dim oSQLApp As SQLDMO.Application<br />
oSQLApp = New SQLDMO.Application<br />
<br />
oNames = oSQLApp.ListAvailableSQLServers()<br />
For i = 1 To oNames.Count<br />
txt_servidor.Items.Add(oNames.Item(i))<br />
Next i<br />
txt_servidor.Focus()<br />
End Sub<br />
<br />
Private Sub CrearTxt()<br />
Dim fs As FileStream = New FileStream("C:\Script.txt", FileMode.OpenOrCreate, FileAccess.ReadWrite)<br />
Dim w As StreamWriter = New StreamWriter(fs)<br />
w.BaseStream.Seek(0, SeekOrigin.End)<br />
w.Write(txt_script.Text)<br />
w.Flush()<br />
w.Close()<br />
End Sub<br />
<br />
Private Sub cmd_conectar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmd_conectar.Click<br />
'Creamos la conexión<br />
Try<br />
oSqlServer.LoginSecure = False<br />
oSqlServer.Connect(txt_servidor.Text, txt_usuario.Text, txt_password.Text)<br />
'---------------------------------------------------------------------------<br />
Dim oDataBase As Database<br />
'Indicamos la BD a la cual deseamos conectarnos<br />
oDataBase = oSqlServer.Databases.Item(txt_bd.Text)<br />
<br />
'Leemos los procedimientos almacenados de la base de datos<br />
Dim oSP As StoredProcedure2<br />
For Each oSP In oDataBase.StoredProcedures<br />
lst_SPs.Items.Add(oSP.Name)<br />
Next<br />
'---------------------------------<br />
oSqlServer.DisConnect()<br />
cmd_aceptar.Enabled = True<br />
cmd_AT.Enabled = True<br />
cmd_A1.Enabled = True<br />
cmd_QT.Enabled = True<br />
cmd_Q1.Enabled = True<br />
Catch ex As Exception<br />
MsgBox("Ha ocurrido un error en la conexión con el servidor", MsgBoxStyle.Information, "Error")<br />
End Try<br />
End Sub<br />
<br />
Private Sub cmd_aceptar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmd_aceptar.Click<br />
If Me.lst_SPsAgr.Items.Count = 0 Then<br />
txt_StatusBar.Text = "NO ha seleccionado nigún procedimiento almacenado"<br />
txt_StatusBar.Refresh()<br />
MsgBox("NO ha seleccionado nigún procedimiento almacenado" & ControlChars.CrLf & "NO se la de de vivo, despiértese!!", MsgBoxStyle.Exclamation, "Atención")<br />
Return<br />
End If<br />
<br />
txt_StatusBar.Text = ""<br />
Try<br />
oSqlServer.LoginSecure = False<br />
oSqlServer.Connect(txt_servidor.Text, txt_usuario.Text, txt_password.Text)<br />
<br />
Dim oDataBase As Database<br />
Dim tot_proc As Integer<br />
tot_proc = 0<br />
'Indicamos la BD a la cual deseamos conectarnos<br />
oDataBase = oSqlServer.Databases.Item(txt_bd.Text)<br />
<br />
'Leemos los procedimientos almacenados de la base de datos<br />
Dim oSP As StoredProcedure2<br />
Dim Script As New System.Text.StringBuilder<br />
Script.Append("")<br />
For Each oSP In oDataBase.StoredProcedures<br />
If lst_SPsAgr.FindStringExact(oSP.Name, 0) <> -1 Then<br />
txt_StatusBar.Text = "Generando script " & Trim(Str(tot_proc + 1)) & " de " & Trim(Str(lst_SPsAgr.Items.Count)) & "... Procedimiento: " & oSP.Name<br />
txt_StatusBar.Refresh()<br />
<br />
Script.Append("/*-- Procedimiento # " & tot_proc + 1 & "--*/" & ControlChars.CrLf)<br />
Script.Append("if exists (select name from dbo.sysobjects where id = object_id(N'[dbo].[" & oSP.Name & "]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)" & ControlChars.CrLf & _<br />
" drop procedure [dbo].[" & oSP.Name & "]" & ControlChars.CrLf & _<br />
"GO" & ControlChars.CrLf & ControlChars.CrLf)<br />
Script.Append(oSP.Script())<br />
<br />
tot_proc = tot_proc + 1<br />
End If<br />
Next<br />
txt_StatusBar.Text = "Generando script final para un total de " & Trim(Str(tot_proc)) & " procedimientos, por favor espere..."<br />
txt_StatusBar.Refresh()<br />
<br />
txt_script.Text = Script.ToString<br />
<br />
oSqlServer.DisConnect()<br />
'txt_script.Text = Replace(txt_script.Text, ControlChars.CrLf & "AS", ControlChars.CrLf & "WITH ENCRYPTION" & ControlChars.CrLf & "AS", , , CompareMethod.Text)<br />
'txt_script.Text = Replace(txt_script.Text, "CREATE PROCEDURE", "ALTER PROCEDURE", , , CompareMethod.Text)<br />
cmd_seleccionar.Enabled = True<br />
''''CrearTxt()<br />
txt_StatusBar.Text = "Secuencia de comandos generada exitosamente para un total de " & Trim(Str(lst_SPsAgr.Items.Count)) & " procedimientos"<br />
txt_StatusBar.Refresh()<br />
MsgBox("Se generó exitosamente la secuencia de comandos" & ControlChars.CrLf & "para un total de " & tot_proc & " procedimientos almacenados", MsgBoxStyle.Information, "Información")<br />
Catch ex As Exception<br />
MsgBox("Ha ocurrido un error en la conexión con el servidor", MsgBoxStyle.Information, "Error")<br />
Finally<br />
End Try<br />
<br />
''If lst_SPsAgr.Items.Count > 0 Then<br />
'' Dim i As Integer<br />
'' Dim NombProce As String<br />
'' NombProce = ""<br />
'' i = 0<br />
'' For i = 0 To lst_SPsAgr.Items.Count - 1<br />
'' MsgBox(lst_SPsAgr.Items(i).ToString)<br />
'' Next<br />
''End If<br />
End Sub<br />
<br />
Private Sub cmd_seleccionar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmd_seleccionar.Click<br />
''txt_script.Select(0, Len(txt_script.Text))<br />
txt_script.SelectAll()<br />
txt_script.Copy()<br />
MsgBox("Se copió la secuencia de comandos en el portapapeles", MsgBoxStyle.Information, "Información")<br />
End Sub<br />
<br />
Private Sub lst_SPs_DoubleClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles lst_SPs.DoubleClick<br />
If lst_SPs.SelectedItems.Count > 0 Then<br />
lst_SPsAgr.Items.Add(lst_SPs.SelectedItem.ToString)<br />
lst_SPs.Items.Remove(lst_SPs.SelectedItem)<br />
End If<br />
End Sub<br />
<br />
Private Sub cmd_AT_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmd_AT.Click<br />
Dim i As Integer<br />
For i = 0 To lst_SPs.Items.Count - 1<br />
lst_SPsAgr.Items.Add(lst_SPs.Items(i).ToString)<br />
Next<br />
lst_SPs.Items.Clear()<br />
End Sub<br />
<br />
Private Sub cmd_A1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmd_A1.Click<br />
'lst_SPsAgr.Items.Add(lst_SPs.SelectedItem.ToString)<br />
'lst_SPs.Items.Remove(lst_SPs.SelectedItem)<br />
Dim i As Integer<br />
For i = 0 To lst_SPs.SelectedIndices.Count - 1<br />
lst_SPsAgr.Items.Add(lst_SPs.SelectedItems(0))<br />
lst_SPs.Items.RemoveAt(lst_SPs.SelectedIndices(0))<br />
Next<br />
End Sub<br />
<br />
Private Sub cmd_Q1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmd_Q1.Click<br />
Dim i As Integer<br />
For i = 0 To lst_SPsAgr.SelectedIndices.Count - 1<br />
lst_SPs.Items.Add(lst_SPsAgr.SelectedItems(0))<br />
lst_SPsAgr.Items.RemoveAt(lst_SPsAgr.SelectedIndices(0))<br />
Next<br />
End Sub<br />
<br />
Private Sub lst_SPsAgr_DoubleClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles lst_SPsAgr.DoubleClick<br />
If lst_SPsAgr.SelectedItems.Count > 0 Then<br />
lst_SPs.Items.Add(lst_SPsAgr.SelectedItem.ToString)<br />
lst_SPsAgr.Items.Remove(lst_SPsAgr.SelectedItem)<br />
End If<br />
End Sub<br />
<br />
Private Sub cmd_QT_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmd_QT.Click<br />
Dim i As Integer<br />
For i = 0 To lst_SPsAgr.Items.Count - 1<br />
lst_SPs.Items.Add(lst_SPsAgr.Items(i).ToString)<br />
Next<br />
lst_SPsAgr.Items.Clear()<br />
End Sub<br />
<br />
Protected Overrides Sub Finalize()<br />
oSqlServer.Close()<br />
MyBase.Finalize()<br />
End Sub<br />
<br />
Private Sub cmd_Salir_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmd_Salir.Click<br />
Close()<br />
End Sub<br />
<br />
End Class<br />
Henry de Sousa
|
|
|
|
|
Is it possible to change the size of a buttons in DataGridView ButtonColumn. That is, I want the width of the column to be wider than the width of the button in the column.
Thanks
EM
|
|
|
|
|
There is no property to change the size of the button. You'd probably have to make your own DataGridViewButtonColumn, and possibly, DataGridViewButtonCell classes to give you the ability to supply your own properties and drawing code to change the size of the button, without changing the size of the column.
Google for "custom DataGridViewButtonColumn" for examples.
|
|
|
|
|
Hi Friends,
I new to vb.net. In c#.net in GridView i use RowDataBound method and make a check if commandname is Delete i catch the linkbutton(Delete) by FindControl and on Click i give javascript method for Confirm. If Ok it goes to RowDeleting else Cancel.
I am trying something same in vb.net for DataGrid.
The button in DataGrid is
<asp:ButtonColumn Text="??a??af?" ButtonType="PushButton" CommandName="Delete"></asp:ButtonColumn>
Any idea how can Throw a Confirm Message on Click of This button?
Any help would be greatly appreicated
Thanks
Cheers
Menon
|
|
|
|
|
You should be asking this question in the ASP.NET forum.
To get a confirmation dialog, you'd probably be writing the code in JavaScript on the client-side.
|
|
|
|
|