TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Hussain Afridi
NA
1
1.7k
converting vb.net code into c#
Jul 24 2012 7:38 AM
salam sir i want to convert the following vb.net code into csharp...
Imports System
Imports System.Data
Imports System.Data.SqlClient
Public Class clsDML
Public conn As SqlConnection
Public Function DML(ByVal Query As String)
Try
Dim connectionstring As String
connectionstring = CreateConnection()
conn = New SqlConnection(connectionstring)
conn.Open()
Dim cmd As New SqlCommand
cmd.Connection = conn
cmd.CommandType = CommandType.Text
cmd.CommandText = Query
cmd.ExecuteNonQuery()
conn.Close()
Catch ex As Exception
MessageBox.Show(ex.ToString())
End Try
End Function
Public Function GetArray(ByVal Query As String, Optional ByVal LocalServer As String = "")
Try
Dim connectionstring As String
connectionstring = CreateConnection()
conn = New SqlConnection(connectionstring)
conn.Open()
Dim cmd As New SqlCommand
cmd.Connection = conn
cmd.CommandText = Query
Dim data As SqlDataReader = cmd.ExecuteReader() 'reader = command.ExecuteReader();
Dim i, j, x As Int32
While (data.Read())
i = i + 1
End While
Dim count As Int32
Dim A(i - 1, data.FieldCount - 1)
count = data.FieldCount
data.Close()
Dim data1 As SqlDataReader = cmd.ExecuteReader()
j = 0
While (data1.Read())
For x = 0 To count - 1
A(j, x) = data1.GetValue(x).ToString()
Next
j = j + 1
End While
data1.Close()
Return A
Catch ex As Exception
End Try
End Function
Public Function CreateConnection() As String
Dim source As String
source = "data source=(local);database=mdin;user id=sa; pwd=;Persist Security Info=False"
Return source
End Function
End Class
Attachment:
clsdml.zip
Reply
Answers (
3
)
Read data from rs232 port
operator overloading