Jump to content
Xtreme .Net Talk

lidds

Avatar/Signature
  • Posts

    211
  • Joined

  • Last visited

lidds's Achievements

Newbie

Newbie (1/14)

0

Reputation

  1. I am really struggling with getting the column names from a MS Access table, I have been googling for some time now and can not seem to find an example that works. Any help would be really apreshiated Thanks in advance Simon
  2. Hi, At the moment I am using the following code to populate a datatable using a stroed procedure, which return a large amount of information from my MS SQL table. What I would like to do is then apply an SQL select statement to the datatable so that I can filter down the data in the datatable further. The reason why I want to do this is instead of having a large number of stored procedures for each senario, is this possible Dim myDA As New OleDb.OleDbDataAdapter("spQryParentComments", myDB.myConn) myDA.SelectCommand.CommandType = CommandType.StoredProcedure myDA.SelectCommand.Parameters.Add(New OleDb.OleDbParameter("@projName", OleDb.OleDbType.VarChar)).Value = RISData.Instance.ProjectName myDA.SelectCommand.Parameters.Add(New OleDb.OleDbParameter("@userID", OleDb.OleDbType.VarChar)).Value = RISData.Instance.UserID Dim dataParentTable As DataTable = New DataTable("Parent") ' e.g. dataParentTable.selectcommand("SELECT * WHERE [column] = [XYZ]") myDA.Fill(dataParentTable) Thanks in advance Simon
  3. I am writing a image file to a stream and then add this to a picturebox using the following code: ' Converts comment image in zip file to bmp Dim bmp As New Bitmap(New System.IO.FileStream("C:\Orig.bmp", FileMode.Open, FileAccess.Read)) Me.pictureBox.Image = bmp The problem is that when I try to delete the file it gives me an error that the file is still in use. What I need to know is how I can release the image file. Thanks in advance Simon
  4. I have a propertygrid in my project and in this I have a text/string valve which the user can just enter text in. However I also have a text edit form that I have created, is there a way that I can customise the property value so that the user can enter text as normal but also display a button in the value field that if the user clicks on the button then it will display my custom text edit form form? If someone could help me with this then that would really be appreshiated, I have posted the current code below, and just for reference I am using VB.Net <CategoryAttribute("Text"), _ Browsable(True), _ [ReadOnly](False), _ BindableAttribute(False), _ DefaultValueAttribute("True"), _ DesignOnly(False), _ DescriptionAttribute("Specifies the current font content")> _ Public Property Text() As String Get Return m_Text End Get Set(ByVal Value As String) m_Text = Value End Set End Property Thanks in advance Simon
  5. The strange things is that when an item is placed if I go to modify the size of it or move the item it does not flicker, I don't know if that is any help Regards Simon
  6. I have managed to create an application that allows drawing of items on a screen capture, however some flicker appears when drawing items. The first item when drawn does not flicker but then after that any item when being drawn flickers, I have been trying to solve this for some time now with no luck. Would someone be able to help me with this? I have attached the whole project so you can see exacually what I am doing. Download from this link http://www.ticodi.com/temp/orig.zip Thanks in advance Simon
  7. I have a richtextbox and what I want to be able to do is to format each line, so one line would be say italic and another line would be bold. I have done the following code which changes the second line to bold, however if you click the button again to write some more text to the richtextbox the formatting of the previous text is lost: Private Sub btnClient_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClient.Click Dim line1 As String = "Client Says [" & Now().ToString & "]" Dim line2 As String = "[" & Now().ToString & "]" & " Simon - Hello how are you" Me.RichTextBox1.Text += line1 & vbNewLine textColour(line1, False) Me.RichTextBox1.Text += line2 & vbNewLine textColour(line2, True) Me.RichTextBox1.SelectionStart = Me.RichTextBox1.Text.Length End Sub Private Sub textColour(ByVal text As String, ByVal bold As Boolean) Dim newFont As Font RichTextBox1.SelectionStart = RichTextBox1.Find(text) If bold = True Then newFont = New Font(Me.cmbFont.Font, FontStyle.Bold) Else newFont = New Font(Me.cmbFont.Font, FontStyle.Regular) End If RichTextBox1.SelectionFont = newFont End Sub I obviously need some help one keeping the format, basically I want to acheive the type of formating style that msn messenger has. Thanks in advance Simon
  8. I am trying to create an application, one on a server and the other on a networked PC. What I want to do is send information from the PC app. to the server app. I have the following code which allow information to be sent when the applications are launched, so they are able to talk to each other. The only problem I have is that the applications both freeze. What I want to do is have the sockets running in a different thread so that PC app. can send information from the main form to the server app. and that information can then be displayed on the server main form e.g. information entered in a text field. Below is the code that creates the socket, and this passes information successfully, but as I said it freezes the applications. Imports System.Net.Sockets Imports System.Text Public Class Form1 Dim tcpClient As New System.Net.Sockets.TcpClient() Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load End Sub Private Sub runClient(ByVal message As String) Dim networkStream As NetworkStream = tcpClient.GetStream() If networkStream.CanWrite And networkStream.CanRead Then ' Do a simple write. Dim sendBytes As [byte]() = Encoding.ASCII.GetBytes(message) networkStream.Write(sendBytes, 0, sendBytes.Length) ' Read the NetworkStream into a byte buffer. Dim bytes(tcpClient.ReceiveBufferSize) As Byte networkStream.Read(bytes, 0, CInt(tcpClient.ReceiveBufferSize)) ' Output the data received from the host to the console. Dim returndata As String = Encoding.ASCII.GetString(bytes) Console.WriteLine("Host returned: " + returndata) Else If Not networkStream.CanRead Then Console.WriteLine("cannot not write data to this stream") tcpClient.Close() Else If Not networkStream.CanWrite Then Console.WriteLine("cannot read data from this stream") tcpClient.Close() End If End If End If ' pause so user can view the console output Console.ReadLine() End Sub Private Sub runServer() ' Must listen on correct port- must be same as port client wants to connect on. Const portNumber As Integer = 8000 Dim IP As System.Net.IPAddress IP = System.Net.IPAddress.Parse(Me.txtIP.Text) Dim tcpListener As New TcpListener(IP, portNumber) tcpListener.Start() Console.WriteLine("Waiting for connection...") Try 'Accept the pending client connection and return 'a TcpClient initialized for communication. Dim tcpClient As TcpClient = tcpListener.AcceptTcpClient() Console.WriteLine("Connection accepted.") ' Get the stream Dim networkStream As NetworkStream = tcpClient.GetStream() ' Read the stream into a byte array Dim bytes(tcpClient.ReceiveBufferSize) As Byte networkStream.Read(bytes, 0, CInt(tcpClient.ReceiveBufferSize)) ' Return the data received from the client to the console. Dim clientdata As String = Encoding.ASCII.GetString(bytes) Console.WriteLine("Client sent: " + clientdata) Dim responseString As String = "Connected to server." Dim sendBytes As [byte]() = Encoding.ASCII.GetBytes(responseString) networkStream.Write(sendBytes, 0, sendBytes.Length) Console.WriteLine("Message Sent /> : " + responseString) 'Any communication with the remote client using the TcpClient can go here. 'Close TcpListener and TcpClient. tcpClient.Close() tcpListener.Stop() Console.WriteLine("exit") Console.ReadLine() Catch e As Exception Console.WriteLine(e.ToString()) Console.ReadLine() End Try End Sub Private Sub Panel1_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Panel1.MouseMove Me.txtStatus.Text = "X: " & e.X.ToString & " Y: " & e.Y.ToString If Me.radClient.Checked = True Then runClient("X: " & e.X.ToString & " Y: " & e.Y.ToString) End If End Sub Private Sub btnConnect_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnConnect.Click If Me.radClient.Checked = True Then tcpClient.Connect(Me.txtIP.Text, 8000) runClient("Connect from machine with IP address " & Me.txtIP.Text) Else runServer() End If End Sub Private Sub btnDisconnect_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDisconnect.Click If Me.radClient.Checked = True Then tcpClient.Close() End If End Sub End Class Any help would be appreshiated Thanks Simon
  9. What I want to be able to do is create a new email withn the users default emaill app. the same as mailto command in html Regards Simon
  10. I am adding a image to an SQL server, which works fine, however when I try to update the image in the database I get the following error: operand type clash: image is incompatable with varchar By the looks of things it happens when trying to update the image in the database, however if I am inserting a new entry then everything works OK. Can anyone tell me what I am doing wrong, below is my vb.net code and stored procedure. I am using oledb instead of sql due to the fact that it works with botj SQL server and Oracle. VB.Net code 'Read image into byte ' save image to stream... Dim clsStream1 As New System.IO.MemoryStream Me.picNewImage.Image.Save(clsStream1, System.Drawing.Imaging.ImageFormat.Jpeg) ' read bytes from stream... Dim emptyByte As Byte = Nothing Dim b As Byte() = DirectCast(Array.CreateInstance(GetType(Byte), clsStream1.Length), Byte()) clsStream1.Position = 0 clsStream1.Read(b, 0, b.Length) clsStream1.Close() Dim myCmd As New OleDb.OleDbCommand("spUpdateCommAndImg") myCmd.CommandType = CommandType.StoredProcedure myCmd.Parameters.Add(New OleDb.OleDbParameter("@ID", OleDb.OleDbType.VarChar)).Value = MRCSData.Instance.historyID myCmd.Parameters.Add(New OleDb.OleDbParameter("@commTag", OleDb.OleDbType.VarChar)).Value = strTag myCmd.Parameters.Add(New OleDb.OleDbParameter("@commTitle", OleDb.OleDbType.VarChar)).Value = strTitle myCmd.Parameters.Add(New OleDb.OleDbParameter("@commDisp", OleDb.OleDbType.VarChar)).Value = strDisp myCmd.Parameters.Add(New OleDb.OleDbParameter("@commType", OleDb.OleDbType.VarChar)).Value = strType myCmd.Parameters.Add(New OleDb.OleDbParameter("@commDate", OleDb.OleDbType.VarChar)).Value = strDeadline myCmd.Parameters.Add(New OleDb.OleDbParameter("@commArea", OleDb.OleDbType.VarChar)).Value = strArea myCmd.Parameters.Add(New OleDb.OleDbParameter("@commModRef", OleDb.OleDbType.VarChar)).Value = strModRef myCmd.Parameters.Add(New OleDb.OleDbParameter("@commOrig", OleDb.OleDbType.VarChar)).Value = strOrig myCmd.Parameters.Add(New OleDb.OleDbParameter("@commDesc", OleDb.OleDbType.VarChar)).Value = strDesc myCmd.Parameters.Add(New OleDb.OleDbParameter("@commAction", OleDb.OleDbType.VarChar)).Value = strAction myCmd.Parameters.Add(New OleDb.OleDbParameter("@commObj", OleDb.OleDbType.VarChar)).Value = strObjectives myCmd.Parameters.Add(New OleDb.OleDbParameter("@modifyDate", OleDb.OleDbType.VarChar)).Value = Date.Now.ToString("dd/MM/yyyy hh:mm:ss tt") myCmd.Parameters.Add(New OleDb.OleDbParameter("@commImage", OleDb.OleDbType.LongVarBinary, b.Length, ParameterDirection.Input, False, emptyByte, emptyByte, "commImage", DataRowVersion.Current, b)) myCmd.Parameters.Add(New OleDb.OleDbParameter("@commWorkShare", OleDb.OleDbType.VarChar)).Value = strWorkShare Me.lblStatus.Text = "Saving information to database, please wait..." Me.progressStat.Value = 3 Try myDB.DoMyUpdate(myCmd) Catch ex As Exception myDB.DisConnect() MessageBox.Show(ex.Message) Me.lblStatus.Text = "Ready..." Me.progressStat.Value = 0 End Try Stored procedure: CREATE PROCEDURE [dbo].[spUpdateCommAndImg] @ID as varchar(4), @commTag as varChar(255), @commTitle as varchar(255), @commDisp as varchar(255), @commType as varchar(255), @commDate as varchar(25), @commArea as varchar(100), @commModRef as varchar(100), @commOrig as varchar(100), @commDesc as text, @commAction as text, @commObj as varchar(100), @modifyDate as varchar(50),@commWorkShare as varchar(100), @commImage as image AS UPDATE commentsTbl SET commTag=@commTag, commTitle=@commTitle, commDisp=@commDisp, commType=@commType, commDate=@commDate, commArea=@commArea, commModRef=@commModRef, commOrig=@commOrig, commDesc=@commDesc, commAction=@commAction, commObj=@commObj, modifyDate=@modifyDate, workShare=@commWorkShare, commImage=@commImage WHERE [iD]=@ID GO Thanks in advance Simon
  11. I need some help and advise. I am trying to create a database in the background when installed. I have the SQL script and I think SQLCMD is the way to go. I have downloaded SQLCMD and installed it in the following directory: C:\Program Files\Microsoft SQL Server\80\Tools\Binn however when I double click on the file it appears and then disappear again. Even though I want to run my SQL script on a batch type process, is this the correct path for it to be installed? and also is this the best way to do my task. I do not really want to write a .exe to do this task when MS provide apps. to do it for me. Thanks in advance Simon
  12. I have the following SQL code, but I want to check to see if the SQL user is already created before trying to run the create user code so as to avoid errors. Could someone tell me how I can do an if statement in SQL for this? EXECUTE sp_detach_db @dbname = N'MRCS', @skipchecks = N'TRUE' GO EXECUTE sp_attach_single_file_db @dbname = N'MRCS', @physname = N'C:\Program Files\Ticodi\MRCS\Database\MRCS_Data.mdf' GO [color="Red"]If user does not exist then do this code[/color] EXECUTE execute sp_addlogin @loginame = N'MRCSAdmin', @passwd = 'dragnet', @defdb = N'MRCS', @deflanguage = N'us_english' GO [color="red"]Endif statement[/color] Thanks in advance Simon
  13. Unfortunately this give the following error which I think is because the field is a TEXT field not a varchar field.... Invalid operator for data type. Operator equals add, type equals text. Thanks Simon
  14. Hi, I need some help, as always, I currently have a table called 'notificationMessageTbl' and I have a TEXT field called 'userReadID' what I want to do is add text to the end of current text within the field using SQL If I use the following code it just replaces the exsisting text with '12,' and does not append. UPDATE notificationMessageTbl SET userReadID = '12,' Thanks in advance Simon
  15. Can anyone please help me as I don't know why this is happening. I am using crystal reports and when I run my project within vs2005 it runs fine. However when I create my installer and install the software I get the following error when trying to run the application: Unknown Query Engine Error All the crystal dll's get installed and I have verified the database as per outher solutions that I have come across. But this still does not solve the problem, can anyone help? Thanks in advance Simon
×
×
  • Create New...