|
i try to add datepicker to datagrid but i can see it, way?
Private Sub dg2_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles dg2.MouseDown
dtp.Dock = DockStyle.Fill
dtp.Cursor = Cursors.Arrow
dtp.SendToBack()
hitTestGrid = dg2.HitTest(e.X, e.Y)
If hitTestGrid.Column = 5 Then
datagridtextBox.TextBox.Controls.Add(dtp)
dtp.BringToFront()
End If
datagridtextBox.TextBox.BackColor = Color.Black
End Sub
|
|
|
|
|
liat1234 wrote: datagridtextBox.TextBox.Controls.Add(dtp)
You can't add a datetimepicker to a textbox. You can't add any controls to a textbox, unless you are using WPF
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 )
|
|
|
|
|
i try to update my data base but i get this error message
"the update command effected 0 of the expected 1 records"
the insertcommand is ok
my code is
Private Sub btnUPDT_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnUPDT.Click
'--------------------------------
'INSERT NEW ROWS
'--------------------------------
cmd.InsertCommand = New OleDbCommand()
Dim pCust_name1 As New OleDbParameter("@name1", OleDbType.VarChar)
pCust_name1.SourceColumn = "name"
Dim pCust_pass1 As New OleDbParameter("@pass1", OleDbType.VarChar)
pCust_pass1.SourceColumn = "pass"
Dim pCust_meried1 As New OleDbParameter("@meried1", OleDbType.Boolean)
pCust_meried1.SourceColumn = "meried"
Dim pCust_city1 As New OleDbParameter("@city1", OleDbType.VarChar)
pCust_city1.SourceColumn = "city"
Dim pCust_borndate1 As New OleDbParameter("@borndate1", OleDbType.Date)
pCust_borndate1.SourceColumn = "borndate"
cmd.InsertCommand.Parameters.Add(pCust_name1)
cmd.InsertCommand.Parameters.Add(pCust_pass1)
cmd.InsertCommand.Parameters.Add(pCust_meried1)
cmd.InsertCommand.Parameters.Add(pCust_city1)
cmd.InsertCommand.Parameters.Add(pCust_borndate1)
cmd.InsertCommand.Connection = Conn
cmd.InsertCommand.CommandText = "INSERT INTO users " & _
"(name, pass, meried, city, borndate)" & _
"VALUES (@name1, @pass1, @meried, @city, @borndate)"
'------------------------------------------
'UPDATE ROW
'------------------------------------
cmd.UpdateCommand = New OleDbCommand()
Dim pCust_id As New OleDbParameter("@id", OleDbType.Integer)
pCust_id.SourceColumn = "id"
Dim pCust_name As New OleDbParameter("@name", OleDbType.VarChar)
pCust_name.SourceColumn = "name"
Dim pCust_pass As New OleDbParameter("@pass", OleDbType.VarChar)
pCust_pass.SourceColumn = "pass"
Dim pCust_meried As New OleDbParameter("@meried", OleDbType.Boolean)
pCust_meried.SourceColumn = "meried"
Dim pCust_city As New OleDbParameter("@city", OleDbType.VarChar)
pCust_city.SourceColumn = "city"
Dim pCust_borndate As New OleDbParameter("@borndate", OleDbType.VarChar)
pCust_borndate.SourceColumn = "borndate"
cmd.UpdateCommand.Parameters.Add(pCust_id)
cmd.UpdateCommand.Parameters.Add(pCust_name)
cmd.UpdateCommand.Parameters.Add(pCust_pass)
cmd.UpdateCommand.Parameters.Add(pCust_meried)
cmd.UpdateCommand.Parameters.Add(pCust_city)
cmd.UpdateCommand.Parameters.Add(pCust_borndate)
cmd.UpdateCommand.Connection = Conn
cmd.UpdateCommand.CommandText = " UPDATE users SET [name]= @name, [pass]= @pass, [meried]=@meried WHERE [id] =@id"
cmd.Update(ds1, "users")
MsgBox("update table ended")
End Sub
|
|
|
|
|
hi
your code is fine, you have made it complicate you. in this cases, please use a Procedure to insert a new record into the table to avoid Sql injection. and i dont know how you gonna update a datagrid like that. check this article on how to update a datagrid.
.
http://www.codeproject.com/useritems/N-Tier_Application_VB.asp[^]
Hope i helps
Vuyiswa Maseko,
Sorrow is Better than Laughter, it may Sadden your Face, but It sharpens your Understanding
VB.NET/SQL7/2000/2005
http://vuyiswamb.007ihost.com
http://Ecadre.007ihost.com
vuyiswam@tshwane.gov.za
|
|
|
|
|
i wrote this code but always row index 0 is deleted
where i wrong????
Private Sub btnDel_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDel.Click
Dim i As Integer
Dim usrId As String
ds1.GetChanges()
i = dg2.CurrentRowIndex()
usrId = dg2.Item(i, 0)
'delete from dataset
ds1.Tables(0).Rows(i).Delete()
cmd.DeleteCommand = New OleDbCommand()
cmd.DeleteCommand.Connection = Conn
cmd.DeleteCommand.CommandText = "delete * from users where id =" & usrId
'delete from database
cmd.Update(ds1, "users")
End Sub
liat
|
|
|
|
|
liat1234 wrote: i = dg2.CurrentRowIndex()
The current row index must be 0. If you want to delete a different row, select the row you want to delete by setting this property.
Paul Marfleet
"No, his mind is not for rent
To any God or government"
Tom Sawyer - Rush
|
|
|
|
|
Hi,
You may try to do this in the following manner.
Dim con As SqlConnection
Dim adap As SqlDataAdapter
Dim ds As New DataSet
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
binddata()
End Sub
Dim i As Integer
Dim s As String
Private Sub DataGrid1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles DataGrid1.Click
i = DataGrid1.CurrentRowIndex
s = DataGrid1.Item(i, 0)
End Sub
Sub binddata()
Try
con = New SqlConnection("server=200.100.100.139;user id=sa;pwd=hello;database=pubs;")
con.Open()
adap = New SqlDataAdapter("select * from employee", con)
adap.Fill(ds)
DataGrid1.DataSource = ds.Tables(0)
Catch ex As Exception
MsgBox(ex.Message)
Finally
con.Close()
End Try
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Try
con = New SqlConnection("server=200.100.100.139;user id=sa;pwd=hello;database=pubs;")
con.Open()
Dim cmd As New SqlCommand
cmd = New SqlCommand("delete from employee where emp_id='" & s & "'", con)
cmd.ExecuteNonQuery()
binddata()
Catch ex As Exception
MsgBox(ex.Message)
Finally
con.Close()
End Try
End Sub
I hope this helps.
Regards,
John Adams
ComponentOne LLC
|
|
|
|
|
Hello every one...
I am developing a application in vb.net, i want the text in mask box to be selected when a user enters in it..
I was able to do the same with Vb6, i am not able to do in VB.net 2005 Express..
Is the same also possible with text box??
Regards
Nishkarsh
|
|
|
|
|
Yes, you can set the selection index and selection length of the textbox when the focus/enter event occurs
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 )
|
|
|
|
|
Hi all
Plz give me a sample about read a barcode from scanner and save it to database.
Thanks
|
|
|
|
|
Do you have a barcode scanner ? If not, how will you use the code ? If so, have you read the manual that came with it, explaining how to interact with it in code ?
We don't do people's work here, we help people who have tried and are stuck. It sounds to me like you want to do two well defined things, both of them easily answered with resources you should have ( a scanner with a manual and google )
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 )
|
|
|
|
|
Barcode scanners typically emulate keyboard input... and are not a seperate device! They plug right into the Keyboard jack in parallel!
I designed and built a complete Point-of-Sale system in VBA for Access.
|
|
|
|
|
Hi,
In VB.Net how can I declare an varible in one line and instantiate it in another?
such this that can do in C#:
DataTable dt;
dt = new DataTable();
Best wishes
|
|
|
|
|
yes if it is a local variable it goes something like this. If not just replace dim with private or public or whatever.
dim dt as DataTable<br />
dt = new DataTable()
|
|
|
|
|
While you have your answer, you shouldn't do this. Always assign a variable a default value the moment you create it.
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 )
|
|
|
|
|
woul u pls subscribe us sample code of hospital management information system.we'll be very garateful.thanks
with regards
|
|
|
|
|
The depressing thing is that I can't tell if you're joking. If this is homework, you need to do your own homework. If this is paid work, can you tell me the hospital, so I can make sure never to go there ?
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: If this is paid work, can you tell me the hospital, so I can make sure never to go there ?
Same here, I'll make sure I stay away from there.
"Any sort of work in VB6 is bound to provide several WTF moments." - Christian Graus
|
|
|
|
|
trimp wrote: pls subscribe us sample code of hospital management information system
Nope. Do your own work.
"You posted your question here, indicating that you're so thick you couldn't find the VB Forum if it was licking your bung hole." - John Simmons / outlaw programmer
|
|
|
|
|
Wow. Normally I ignore posts asking people to do whole subsystems for them. An entire hospital management information system? That takes the cake as craziest request so far :P
|
|
|
|
|
Can someone tell me whats wrong with this code: Im getting the following error from vbscript runtime:
Line: 18
Char 1
Error: Object required:"
Code: 800A01A8
This is line 18
* If Lcase(Right(objFile.Name,3))="sln" Then *
-Code-
Option Explicit
'==========================Variable declaration & Initialization================================
Dim objFSO, objFolder, objSubFolder, objSubFile, objFile, objShell, colFiles, colFolders, strFolder
strFolder = "C:\Program Files\Visual Studio 2005 SDK"
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFolder = objFSO.GetFolder(strFolder)
Set colFiles = objFolder.Files
Set objShell = CreateObject("WScript.Shell")
'===============================================================================================
For Each objFile in colFiles
Set objFile = objFSO.GetFile(strFolder & "\" & File.Name)
Next
If Lcase(Right(objFile.Name,3))="sln" Then
objShell.Run "devenv /build" & objFile
End If
ScanSubFolders(objFolder)
Sub ScanSubFolders(objFolder)
Set colFolders = objFolder.SubFolders
For Each objSubFolder In colFolders
Set colFiles = objSubFolder.Files
For Each objFile in colfiles
If lcase(Right(objFile.Name,3)) = "sln" Then
objShell.Run "devenv /build" & objFile
End If
Next
ScanSubFolders(objSubFolder)
Next
|
|
|
|
|
You seem to be testing the objFile.Name AFTER you have completed the For...Next loop.
The For...Next loop will retreive each file in the folder and when it finds nothing then exits the loop IE it is EMPTY! Try the following
For Each objFile in colFiles<br />
Set objFile = objFSO.GetFile(strFolder & "\" & File.Name)<br />
<br />
If Lcase(Right(objFile.Name,3))="sln" Then<br />
objShell.Run "devenv /build" & objFile<br />
End If<br />
Next
Quote from Great Outdoors:
its a confident traveller who farts in India
|
|
|
|
|
Hello everyone,
I generally look at Google and other websites before I post a question, but trust me I still cannot find and answer to this problem.
I'm using VB.net (2005) . My problem being is that I don't know how to redirect the serial port output to a selected file. I looked in the forum but no luck.
Here is the sequence of events.
User selects a file to write to. No problem here.
Sends a command to the equipment to start outputting text. No problem here.
At the moment the text is going to text box. Is easy to wait for the output to finish and then save the file. But I do not want this. The user does not need to see the text. Just some sort of indication that data is being sent. No Problem here.
Is more like a Serial Port Data Log.
Friend Sub DataReceived(ByVal sender As Object, ByVal e As SerialDataReceivedEventArgs)
Dim newReceivedData As String
Try
' Get data from the COM port.
newReceivedData = selectedPort.ReadExisting
' Save the number of characters received.
receivedDataLength += newReceivedData.Length
RaiseEvent UserInterfaceData("AppendToMonitorTextBox", newReceivedData, Color.Black)
' I guess I could choose to Write the line to the file instead.
Catch ex As Exception
DisplayException(ModuleName, ex)
End Try
End Sub
Any suggestions? Thanks!
|
|
|
|
|
Since you're already adding the text to a TextBox, it's trivial to convert that code to write to a file instead. What's the problem? A TextBox just shows the contents of a String. A file just stores the very same String.
|
|
|
|
|
Dave, Thanks for your reply.
Well, that is what I'm trying to avoid. I do not want the text displayed while data is being output. I can do that already and save it to a file.
Right now I can stop the data from being displayed by removing the appropriate code but can't seem to figure out how to pass it to a file. What I want to do is save each port.readline() to a file file.writeline()
Is like a serial port data log. I hope this clears things a bit. Thanks.
|
|
|
|