|
I don't know what happen to my code, it can't go through the bolded code, are these database problem?or what?..PLease help me, i am mad with this problem
my code as below:
Dim connstring As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=Database.mdb"
Dim sqlquery As String = "Select * from StaffRecord where " & Field & " = '" & item & "'"
Dim aconnection As OleDbConnection = New OleDbConnection
aconnection.ConnectionString = connstring
Try
Dim adptPerson As New OleDbDataAdapter(sqlquery, aconnection)
Dim dsPerson As New DataSet
adptPerson.Fill(dsPerson, "PersonTable")
If dsPerson.Tables("dsPerson").Rows.Count > 0 Then
Dim dr As DataRow = dsPerson.Tables("PersonTable").Rows(0)
IC = dr.Item("IC")
Name = dr.Item("Names")
End IF
Catch ex As Exception
MsgBox(ex.Message.ToString)
End Try
|
|
|
|
|
Hello,
I miss a call to the "Open"-Method on the Connection-Object. Maybe you don't need it on a OleDbConnection, but I use ODBC- and/or SQLServer-Connections and there it must be.
Besides I think the access of the table is false and should be
dsPerson.Tables("PersonTable")
BR
Stephan
\\\| \\ - -
( @ @ )
+---------------oOOo-(_)-oOOo-----------------+
| Stephan Pilz stephan.pilz@stephan-pilz.de |
| <a href=www.stephan-pilz.de>www.stephan-pilz.de</a> |
| ICQ#: 127823481 |
+-----------------------Oooo------------------+
oooO ( )
( ) ) /
\ ( (_/
\_)
|
|
|
|
|
This is probably a really simple (dumb) question. I have a tabbed form with a datagrid on one of the tabs and the other tabs contain text boxes, etc.(fields) of the currently selected record. I allow the user to set filters for dates, status codes, etc. and then re-select the data from SQL into a dataset. Do I have to reset all of the databindings for the grid and text boxes on all of the tabs, or is there a refresh or other method I should be calling after the data is re-selected? I guess it boils down to, do I have to bind more than once or under what circumstances do I have to re-bind all of the datagrids and text boxes?
Auguy
|
|
|
|
|
I have a .dll (not even sure what type) that contains some functions. I'd like to call those functions from vb.net. I've heard that it is possible to write a "wrapper" to do this. How can I learn to do this? Alternatively, how would I best call those functions from vb.net itself?
I really need a basic tutorial -- can anyone point me in the right direction?
Thanks!
|
|
|
|
|
I should note that I cannot simply add this .dll as a reference to my project -- that does not work (I guess it is not a com dll)?
ty
|
|
|
|
|
You're looking for P/Invoke[^]. Calling an external, unmanaged library .DLL from managed code.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
as title.
I searched it by google but no expected results.
Anyone have solutions about this?
Thanks in advance.
|
|
|
|
|
Why would you want to do this? Are you looking for an automated means of removing the comments?
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
|
The question still stands...Why would you want to do this?
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Basically, Somethng like this..(I'm sure it can be Improved on..)
but you'll get the idea...
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
'Open and parse the source file..
TextBox1.Text = removeComments("c:\test.vb")
'
'Save your textbox to a file here..
'
End Sub
'
Private Function removeComments(ByVal strFilePath As String) As String
Dim sread As StreamReader = New StreamReader(strFilePath)
Dim count As Integer = 0
While sread.Peek >= 0
Dim s As String = sread.ReadLine
System.Math.Min(System.Threading.Interlocked.Increment(count), count - 1)
End While
sread.Close()
Dim sr As StreamReader = New StreamReader(strFilePath)
Dim fileData As String = ""
Dim fi As FileInfo = New FileInfo(strFilePath)
Dim i As Integer = 0
While i < count
Dim str As String = sr.ReadLine
If str.IndexOf("'") >= 0 Then
fileData += removeSingleComment(str)
Else
fileData += str & vbCrLf
End If
System.Math.Min(System.Threading.Interlocked.Increment(i), i - 1)
End While
Return fileData
End Function
'
Private Function removeSingleComment(ByVal str As String) As String
Dim length As Integer = str.Length - str.IndexOf("'")
str = str.Replace(str.Substring(str.IndexOf("'"), length), "")
Return str.Replace(" ", "")
End Function
|
|
|
|
|
|
hii Friends
I m new to vb.net. I have developed a small package by which we can enter customers information and search or find for customers. I have used sql as database. connectivity is done and working very finely. I wanted to know how to create dll or exe of my database while i deploy my application. I know custom action has to be used but i dont know the procedure in which we have to write a code to create database as i install it in client computer. Plez let me know the procedure.
Thanks
Bye
Nikhil Bandekar
Mumbai,
India
|
|
|
|
|
Personally, I just include an empty version of my database to be installed along with the .exe. You can do this in the File System Editor of a setup/deployment project in .net.
Here is an MSDN article that covers the basics.[^]
And I know I've read a few other articles here at codeproject that have been very helpful...but I don't have them saved so you'll have to do some searching.
Hope this helps.
|
|
|
|
|
how to share a vb.net application with mediaplayer to all machines
|
|
|
|
|
What do you mean? Sharing an application with mediaplayer? Is that application a mediaplayer or an extension to MediaPlayer?
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
I am trying to find a setup application which is easy to use for
application written in .net 1.1 framework. Specifically it should
do setup under Winxx platform only.
1. Detect and install OS and framework dependecies.
2. installs the main application and its dependencies.
3. uninstall the main app.
Can you suggest some setup app ?
Thanks
Subir
|
|
|
|
|
Google for ".net 1.1 setup bootstrap[^]" and you'll find several setup bootstrapper applications.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Hi,
I am trying to read two different lines from a text file into two seperate textboxs ie. line one of text file goes into textbox one and line two goes into text box two. Does anyone know how to do this.
Thanks
|
|
|
|
|
Here is one way:
'Declare a StreamReader object to read the text file line by line
Dim sReader As New System.IO.StreamReader("C:\MyTextFile.txt")
Dim strLine As String = String.Empty
'Read first line of text file
strLine = sReader.ReadLine
If Not strLine Is Nothing Then 'Make sure text file had a first line
txt1.Text = strLine 'Set first textbox
strLine = sReader.ReadLine 'Read second line of text file
If Not strLine Is Nothing Then 'Make sure text file had a second line
txt2.Text = strLine 'Set second textbox
End If
End If
sReader.Close() 'Close reader object to keep memory clean of garbage
|
|
|
|
|
Thanks you kindly for your help.
|
|
|
|
|
Hi,
I know its a long time since you posted this reply but I have one question. The text file I am reading the first line is blank. Will this code still work.
|
|
|
|
|
You may have to add another strLine = sReader.ReadLine to the code I gave you before. You will have to read in the first line (even if it is blank) but then just don't do anything with and read the second line right away. So in the spot where you read the first line of text, it would look more like this:
'Read first line of text file<br />
strLine = sReader.ReadLine<br />
<br />
'Don't do anything with the first line because it is blank<br />
'Read the second line<br />
strLine = sReader.ReadLine
Hope this helps.
|
|
|
|
|
I have a sub that is constructed to gather information from a number of XML-files. The XML-files are located in subfolders to the folder where Im running the sub. I have an XML for every website and if I get this code to work I can easely se all information in one Gridview. I can'tget it to work. I get an error at the row with "newRow = dsAllData.Tables(0).NewRow()". The errormessage is: "The reference for an object is not referencing to an instance of an object.". Does anyone have an idea? Se my code under. Im stucked ! Thanks for all help!
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim pathToFolder As String = ""
'Get the number of folders in pathToFolder and place the paths in Dataset
Dim dsAllPaths(200) As String
Dim k As Integer = Nothing
Dim j As Integer = Nothing
Dim s() As String
s = System.IO.Directory.GetDirectories(Server.MapPath(pathToFolder))
Do
If File.Exists(s.GetValue(k) & "\info.xml") Then
dsAllPaths(j) = (s.GetValue(k) & "\info.xml")
j = j + 1
End If
k = k + 1
Loop Until k = s.GetUpperBound(0) + 1
'ReDim array
ReDim Preserve dsAllPaths(j - 1)
'Places the right data in dsAllData from the info-file
Dim dsAllData As DataSet = Nothing
Dim i As Integer = 0
Do
Dim ds As New DataSet()
ds.ReadXml(dsAllPaths(i))
Dim newRow As DataRow
newRow = dsAllData.Tables(0).NewRow()
newRow.Item("Caption") = ds.Tables(0).Rows(0).Item(0)
newRow.Item("Status") = ds.Tables(0).Rows(0).Item(1)
newRow.Item("Information") = ds.Tables(0).Rows(0).Item(2)
newRow.Item("Buggs") = ds.Tables(0).Rows(0).Item(3)
newRow.Item("Wish") = ds.Tables(0).Rows(0).Item(4)
newRow.Item("Keywords") = ds.Tables(0).Rows(0).Item(5)
newRow.Item("Folder") = Replace(dsAllPaths(i), Server.MapPath("info.xml"), "")
dsAllData.Tables(0).Rows.Add(newRow)
i = i + 1
Loop Until i = dsAllPaths.GetLength(0)
'Bind datasource to gridview1
GridView1.DataSource = dsAllData
GridView1.DataBind()
End Sub
Best regards Richard Segerlund
|
|
|
|
|
You are referencing dsAllData.Tables(0)...but does your DataSet have a table in it yet? I'm not familiar with the DataSet.ReadXML so I wasn't sure if that would automatically setup the tables for you... I would set a breakpoint on the line that is causing the error and take a look at what your DataSet object contains.
Hope this helps.
|
|
|
|