|
OK I try to use parameters thanks very much, but are you sure that work
|
|
|
|
|
ivo75 wrote: are you sure that work
See for yourself, that's what they are for
You could try something like this:
...
strQuery = "insert into data_pr values(?)"
aCmd = New OleDbCommand(strQuery, aCon)
aCmd.Parameters.AddWithValue("ColumName", DateTimePicker1.Value)
aCmd.ExecuteNonQuery()
...
|
|
|
|
|
not work give me this error again "Data type mismatch in criteria expression"
|
|
|
|
|
ivo75 wrote: "Data type mismatch in criteria expression"
This just means that the data type of the field in your database is not the same as the value that you are trying to write into it.
Did you try parametric method as suggested by Mika?
|
|
|
|
|
Could you post the code you're currently having.
|
|
|
|
|
Try this in your vb code:
CONVERT(DATETIME, '" & Format(datetimepicker1.value, "MM/dd/yyyy") & " 00:00:00', 102)
If this doesn't work change the code 102 to 101 or 103. It might be one of those codes that you need to use.
should do the trick
|
|
|
|
|
Tahnk You very much everybody this is the code who work
strCon = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & strAcessFilePath & ";User ID=Admin;Password="
aCon = New OleDbConnection(strCon)
aCon.Open()
strQuery = "insert into rabotnici values(?,?,?)"
param1 = New OleDbParameter("@rabotnik_name", OleDbType.VarWChar, 100)
param1.Value = ComboBox1.Text
param2 = New OleDbParameter("@obekt_name", OleDbType.VarWChar, 100)
param2.Value = ComboBox2.Text
param3 = New OleDbParameter("@data_rabota", OleDbType.Date)
param3.Value = DateTimePicker1.Value.ToShortDateString()
aCmd = New OleDbCommand(strQuery, aCon)
aCmd.Parameters.Add(param1)
aCmd.Parameters.Add(param2)
aCmd.Parameters.Add(param3)
aCmd.ExecuteNonQuery()
aCon.Close()
this is work with parameters, again thanks
|
|
|
|
|
I have a stream of text on display in a multiline textbox. I would line to insert the following new line of text ("TODAY 007") in the line just below every occurences of "PRV*PE*ZZ*1041C0700X~". So the result should be:
PRV*PE*ZZ*1041C0700X~
TODAY 007
This should repeat to the end of the file.
How do I start to code this? Please if anyone has a code sample. Thanks
|
|
|
|
|
Read the file line by line and if the current line matches your pattern, put a line break character and insert the required text.
|
|
|
|
|
Here is the code I have so far, but when I invoke, nothing happens.
Dim sReader As New IO.StreamReader("C:\\File.txt")<br />
Dim CurrentLine As String = "TODAY 007"<br />
Dim DataLines As New System.Collections.Specialized.StringCollection<br />
<br />
Do While sReader.EndOfStream = False<br />
CurrentLine = sReader.ReadLine<br />
If CurrentLine.Contains("PRV*PE") = False Then<br />
DataLines.Add(CurrentLine)<br />
End If<br />
Loop<br />
sReader.Close()<br />
sReader = Nothing<br />
<br />
Dim sWriter As New IO.StreamWriter("C:\\File.txt")<br />
<br />
For Each CurrentLine In DataLines<br />
sWriter.WriteLine(CurrentLine)<br />
Next<br />
sWriter.Close()<br />
sWriter = Nothing
Any suggestions?
|
|
|
|
|
IvanIT wrote: If CurrentLine.Contains("PRV*PE") = False Then
DataLines.Add(CurrentLine)
End If
So, what are you going to do if the contains method returns True ? Right now, you're just dropping the line and not doing anything with it. You've completely dropped your string of "TODAY 007" and the logic doesn't come close to following your specified requirements. Shouldn't your code read something more like:
Do While Not sReader.EndOfStream
DataLines.Add(CurrentLine)
If CurrentLine.Contains("PRV*PE") Then
DataLines.Add("TODAY 007")
End If
Loop
|
|
|
|
|
Dave, this is an excerpt of the code I used; the result is that the line is insert 1 time at the end of the text file rather than immediately after each occurence of my search string:
Private Sub btnTranslate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnTranslate.Click<br />
MessageBox.Show("you are about to translate file")<br />
<br />
'read the file to find data<br />
Dim sReader As New IO.StreamReader("C:\moviez_21.txt")<br />
Dim CurrentLine As String<br />
<br />
Dim DataLines As New System.Collections.Specialized.StringCollection<br />
<br />
CurrentLine = sReader.ReadLine<br />
If CurrentLine.StartsWith("PRV*PE*ZZ*") = True Then<br />
sReader.ReadToEnd()<br />
End If<br />
sReader.Close()<br />
<br />
'modifying the file<br />
Dim oError As System.IO.StreamWriter<br />
oError = New System.IO.StreamWriter("c:\moviez_21.txt", True)<br />
<br />
'text to be inserted in after PRV*PE*ZZ*<br />
oError.Write("REF*LU*") ' + file number<br />
oError.Close()<br />
End Sub
Where did I go wrong?
|
|
|
|
|
This is nowhere near what you wrote before. And frankly, you didn't follow the logic you wrote, line by line, nor did you even look at the example I already gave you.
|
|
|
|
|
Dave, you are correct that my logic and coding have changed. Trust me, I appreciate all the feedback that I have gotten from this forum. I keep tweaking the suggestions until I get something that works. At this point, the code above works, with the 2 exceptions. I now need to figure out a way to reference the text file dynamically. Secondly, I discovered that myString will have different ending characters from time to time. As I plow thru, I learn new stuff. Thanks
|
|
|
|
|
Hi All,
I have developed an application in vb.net 2005/ Mssql express 2005.
It works very fine on my machine, but give me problem when i am trying to run it on my remote machine. I am using LAN (Cross over Cable). It gives me an error "Login failed for user 'MyServerName\Guest' when i am trying to run it on my remote machine.
My Connection String is like following.
Conn = New SqlConnection("Server=myserver\SQLEXPRESS,1028;Trusted_Connection=yes;database=mydatabase")
I have done following steps.
Sql Server 2005 Surface Area Configuration.
I have set Remote Connections
Local and Remote Connections.
Using Both TCP/IP and Named Pipes.
Apply Done.
Stop Service and again restart.
Sql Server Configuration Manager
Sql Server 2005 Network Configuration
Protocols for SqlExpress
Shared memory = Enabled
Named Pipes = Enabled
TCP/IP = Enabled
Via = Enabled
Sql Server 2005 Services
Sql Server (SqlExpress) Running.
Sql Server Browser Running.
Stop and again restart.
Ms Sql Server Management Studio SqlExpress.
Set Security to Sql Server and windows Authentication mode.
But still i am facing the same problem.
Kindly help me.
Thanks in advance.
rmshah
Developer
|
|
|
|
|
Since you're using trusted connection, do you belong to a windows group that has access to that SQL Server and to that database or do you have that access granted to you personally? Now it seems that you're not granted the access so SQL Server uses Guest account which then again doesn't have access to the SQL Server instance.
|
|
|
|
|
hey guys, im building a media player using the MCiWND class in VB 6.0. im using the SendMessageAsString function to send commands to the Mci device.
it runs fine and all that, but after a song is done playing, the status of my window does not change. it keeps playing even after the file is done.
i.e i cant find a way to read the status change of the Mci device. ive set the flags to Notify Mode change..
now my problem is, i dont know how to read the mode change that occurs after the song is done playing. can i treat the mode change as an event? or anything else i can do?
here's what ive coded so far.:
'Create a MciWND class
Call MCIWndRegisterClass
flags = WS_CHILD And MCIWNDF_NOTIFYMODE Or MCIWNDF_NOTIFYALL
szFileName = Playlist1.Text
hMCIWnd = CreateWindowExAsString(0&, "MCIWndClass", "ORCA", flags, _
10&, 10&, 0&, 0&, _
Me.hwnd, _
0&, _
App.hInstance, _
szFileName)
Call SendMessageAsString(hMCIWnd, MCIWNDM_SENDSTRING, flags, "play")
here's a screenshot of the problem:
http://img33.picoodle.com/img/img33/3/1/24/f_scrnshtm_5a52658.jpg[^]
as u can see, its pretty basic.. lots of stuff to add :P
suggestions and criticism are welcome..
|
|
|
|
|
V.G wrote: suggestions and criticism are welcome
You're making work for yourself. VB6 is crap, and it's unsupported ( you should put VB6 in your subject line if you're using it, b/c hardly anyone does ). VB.NET has a media player control you just drop into a form and it works.
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
yes i know how that works, but im doing this for my college and they require VB 6. anything you can suggest regarding my problem..?
|
|
|
|
|
V.G wrote: but im doing this for my college and they require VB 6.
I'd start looking for a new university to go to. Something that doesn't teach you to use technology that's long been dead now.
Notifications come to you through window messages. You have to override the message handler (WndProc in a VB.NET app) and pick out the MCI message you get. VB6 and VB.NET will not automagically do this for you and create an event out of something it knows nothing about. So, you have to write the code to catch the message and generate the event.
Sorry, I don't have any VB6 examples of this. I stopped using VB6 7 years ago.
I did manage to find this example[^] that might help you do this...
|
|
|
|
|
Hello!
I need a quick intro, and some small sample code on using TcpListener and TcpClient.
Something really simple, for example send/recieve text messages like in chat.
Thanks!
|
|
|
|
|
|
I have an interface imported of Itaskbarlist3 (from pinvoke,http://www.pinvoke.net/default.aspx/shell32/ITaskbarList3.html[^])
I got the code to compile but how do I make use of the interface? I'm new to interfaces.
That pinvoke page is in c#. Here(http://pastebin.ca/1317369[^]) is my full vb.net version I'm using. It compiles but I don't know how to use the interfaces. Making a class that implements it doesn't seem to do anything.
How can I use the functions in this interface?
|
|
|
|
|
An Interface is what some external code is going to use to call your code. In this case, Windows is going to expect you to implement this interface so it can call your code.
Are you running your code under Windows 7?? Because this interface didn't show up until Windows 7 Beta 1. If your using Vista or XP, it's no surprise that your code isn't getting called. There's nothing calling it!
|
|
|
|
|
I'm using Windows 7 but I don't understand what to do. I'm trying to use a function of the interface itaskbarlist3 called SetProgressValue and SetProgressState but it isn't actually... doing anything.
|
|
|
|