Programming

Programming Questions? Ask a Programmer for Answers ASAP

Ask a Computer Expert,
Get an Answer ASAP!

Programming

I need to write something in VB that will connect to a SQL

Customer Question
Hello, I need to write...
Hello, I need to write something in VB that will connect to a SQL server, run a query that could have more than one result, then run a predefined command for the result(s)
JA: What programs and versions are you using?
Customer: visual studio
JA: What is your ideal outcome? How can we solve this for you?
Customer: my ideal outcome is to provide the code I need so I can insert it into my solution
JA: Anything else you want the programmer to know before I connect you?
Customer: not at this time, other than I am not an experienced developer
Submitted: 1 year ago.Category: Programming
Show More
Show Less
Ask Your Own Programming Question
Answered in 1 minute by:
10/8/2016
Programmer: LogicPro, Computer Software Engineer replied 1 year ago
LogicPro
LogicPro, Computer Software Engineer
Category: Programming
Satisfied Customers: 13,239
Experience: Expert in C, C++, Java, DOT NET, Python, HTML, Javascript, Design.
Verified

Hi

welcome

please elaborate.

Ask Your Own Programming Question
Customer reply replied 1 year ago
I already have a sqlconn but I have to rewrite for the purpose of performing a query, returning one or more results, then passing these results to a command that I want to run for each of the results
Customer reply replied 1 year ago
here is the sqlconn:
'SQLConn.ConnectionString = "Data Source=" & HostName & ";" & _
'"Initial Catalog=mvf;" & _
'"User ID=" & Session("db_name") & ";" & _
'"Password=" & Session("db_pass") & ";"
'SQLConn.Open()'For i As Integer = 0 To intLC - 1
'strCommand = "select convert (varchar, count (study_uid)) from mvf.dbo.dosr_study ms where study_uid = '" & arrResults(11, i) & "'"
strCommand = "Select series_uid from dosr_series where study_ref In (Select study_ref from dosr_study where study_uid = '" & arrResults(11, i) & "') and MODALITY !='SR'"
'Dim SQLCommand As New SqlClient.SqlCommand(strCommand, SQLConn)
'Dim reader As SqlDataReader = SQLCommand.ExecuteReader()
'While reader.Read()
'Response.Write(reader(0) & "<br />")
'If (Not reader(0) = 0) Then
'arrResults(12, i) = "1"
'End If
'Response.Write(i & " : " & arrResults(11, i) & " : " & arrResults(12, i) & "<br />")
'End While
'reader.Close()
'Next
'SQLConn.Close()
'End Sub
Customer reply replied 1 year ago
I want to use the following query:
"Select series_uid from dosr_series where study_ref In (Select study_ref from dosr_study where study_uid = '" & arrResults(11, i) & "') and MODALITY !='SR'"
Programmer: LogicPro, Computer Software Engineer replied 1 year ago

Zip your project and provide

Format is not easier to read

Ask Your Own Programming Question
Customer reply replied 1 year ago
ok
Programmer: LogicPro, Computer Software Engineer replied 1 year ago

Ok

Ask Your Own Programming Question
Customer reply replied 1 year ago
default.aspx.vb
Customer reply replied 1 year ago
I want to rewrite the sqlconn to my needs, and use this in line 291
Customer reply replied 1 year ago
the result of the query would be inserted here:
-k 0020,000E=<insert result here>
Customer reply replied 1 year ago
but there could be one or more results from the query, so it could have to be parsed 'x' number of times, 'x' being the result of the sql query
Programmer: LogicPro, Computer Software Engineer replied 1 year ago

I will check and reply in few hours

Ask Your Own Programming Question
Customer reply replied 1 year ago
right now the sqlconn is commented out because I do not want to use it for the purpose it was programmed and want to change it for my needs, I hope that makes sense
Programmer: LogicPro, Computer Software Engineer replied 1 year ago

Will review

Ask Your Own Programming Question
Customer reply replied 1 year ago
ok thanks!
Programmer: LogicPro, Computer Software Engineer replied 1 year ago

welcome

Ask Your Own Programming Question
Customer reply replied 1 year ago
hi there, any progress?
Programmer: LogicPro, Computer Software Engineer replied 1 year ago

I tried it a lot but lost.

My apologies, I am out of ideas and opting out for other Professionals to answer. Please wait. You will be notified by email as soon as any Professional joins you.

I would be happy to help you with your other questions though.

Thank you for your patience.

Ask Your Own Programming Question
Customer reply replied 1 year ago
ok thx
Programmer: Steve, Consultant replied 1 year ago
Steve
Steve, Consultant
Category: Programming
Satisfied Customers: 290
Experience: Steve is a consultant in the areas of computer software and programming, information management and networking.
Verified

Hi there, my name is***** haven't tested this code, but give this a try:

Public Function SQLConnect() As String
Dim db As New SqlConnection
Dim reader As SqlDataReader
Dim results() As Variant
Dim count As Integer

Try
db.ConnectionString = "Data Source=" & Hostname & __
";Initial Catalog=mvf" &__
";Persist Security Info=True" &__
";User ID=" & Session("db_name") & __
";Password=" & Session("db_pass")
Dim query As New SqlCommand("Select series_uid from dosr_series where study_ref In (Select study_ref from dosr_study where study_uid = '" & arrResults(11, i) & "') and MODALITY !='SR", db)
db.Open()

reader = query.ExecuteReader()

count = 0
While reader.Read()
results(count) = reader("series_uid")
count = count + 1
End While

Catch ex As Exception
MessageBox.Show("Error while connecting to SQL Server." & ex.Message)
Finally
db.Close()
End Try

Return "done"
End Function

Ask Your Own Programming Question
Ask Steve Your Own Question
Steve
Steve
Steve, Consultant
Category: Programming
Satisfied Customers: 290
290 Satisfied Customers
Experience: Steve is a consultant in the areas of computer software and programming, information management and networking.

Steve is online now

A new question is answered every 9 seconds

How JustAnswer works:

  • Ask an ExpertExperts are full of valuable knowledge and are ready to help with any question. Credentials confirmed by a Fortune 500 verification firm.
  • Get a Professional AnswerVia email, text message, or notification as you wait on our site. Ask follow up questions if you need to.
  • 100% Satisfaction GuaranteeRate the answer you receive.

JustAnswer in the News:

Ask-a-doc Web sites: If you've got a quick question, you can try to get an answer from sites that say they have various specialists on hand to give quick answers... Justanswer.com.
JustAnswer.com...has seen a spike since October in legal questions from readers about layoffs, unemployment and severance.
Web sites like justanswer.com/legal
...leave nothing to chance.
Traffic on JustAnswer rose 14 percent...and had nearly 400,000 page views in 30 days...inquiries related to stress, high blood pressure, drinking and heart pain jumped 33 percent.
Tory Johnson, GMA Workplace Contributor, discusses work-from-home jobs, such as JustAnswer in which verified Experts answer people’s questions.
I will tell you that...the things you have to go through to be an Expert are quite rigorous.

What Customers are Saying:

My Expert answered my question promptly and he resolved the issue totally. This is a great service. I am so glad I found it I will definitely use the service again if needed.

One Happy CustomerNew York

Wonderful service, prompt, efficient, and accurate. Couldn't have asked for more. I cannot thank you enough for your help.

Mary C.Freshfield, Liverpool, UK

This expert is wonderful. They truly know what they are talking about, and they actually care about you. They really helped put my nerves at ease. Thank you so much!!!!

AlexLos Angeles, CA

Thank you for all your help. It is nice to know that this service is here for people like myself, who need answers fast and are not sure who to consult.

GPHesperia, CA

I couldn't be more satisfied! This is the site I will always come to when I need a second opinion.

JustinKernersville, NC

Just let me say that this encounter has been entirely professional and most helpful. I liked that I could ask additional questions and get answered in a very short turn around.

EstherWoodstock, NY

Thank you so much for taking your time and knowledge to support my concerns. Not only did you answer my questions, you even took it a step further with replying with more pertinent information I needed to know.

RobinElkton, Maryland

< Previous | Next >

Meet the Experts:

ATLPROG

ATLPROG

Computer Software Engineer

7,677 satisfied customers

MS in IT.Several years of programming experience in Java C++ C C# Python VB Javascript HTML

LogicPro

LogicPro

Computer Software Engineer

13,239 satisfied customers

Expert in C, C++, Java, DOT NET, Python, HTML, Javascript, Design.

unvadim

unvadim

Computer Software Engineer

1,168 satisfied customers

Good knowledge of OOP principles. 3+ years of programming experience with Java and C++. Sun Certified Java Programmer 5.0.

lifesaver

lifesaver

Computer Software Engineer

950 satisfied customers

Several years of intensive programming and application development experience in various platforms.

ehabtutor

ehabtutor

Computer Software Engineer

936 satisfied customers

Bachelor of computer science, 5+ years experience in software development, software company owner

TheDoctor

TheDoctor

Software Engineer

893 satisfied customers

M.S. in Internet Information Systems

The-PC-Guy

The-PC-Guy

Software Engineer

789 satisfied customers

Extensive Knowledge in PHP, MYSQL, CSS & Javascript

< Previous | Next >

Related Programming Questions
I have a homework assignment that is similar to one already
i have a homework assignment that is similar to one already posted but the assignment needs to have a gui and be in visual studio 2012 … read more
George Sibiya
George Sibiya
PhD
194 satisfied customers
I need help with my dealer program as in how to create one.
i need help with my dealer program as in how to create one … read more
LogicPro
LogicPro
Computer Software Engineer
13,239 satisfied customers
Can you please help me with a C Programming project. It is a
Hi,Can you please help me with a C Programming project. It is a basic program that needs to read in information about modules, from a file and put into an array of structures.I can forward the specifi… read more
George Sibiya
George Sibiya
PhD
194 satisfied customers
I'm stuck on coding a calcButton in VB. Visual Studio
I'd like to have someone walk me through coding this button, I've got the rest of the form coded but I'm stumped on this one. … read more
George Sibiya
George Sibiya
PhD
194 satisfied customers
Just have a question with list box, visual studio 2015, I
I just confused with list box ,the question is select a workshop from one list box and a location from another list box … read more
LogicPro
LogicPro
Computer Software Engineer
13,239 satisfied customers
I dont know how to write a program that reads in integers
I dont know how to write a program that reads in integers and counts the number of those integers that are less than the average in C++ … read more
LogicPro
LogicPro
Computer Software Engineer
13,239 satisfied customers
Working in Visual Studio 2017 - can't find definitive
Working in Visual Studio 2017 - can't find definitive instructions on how to print the form on my screen. The common instruction is to use PrintForm but I don't have that I have PrintDocument. Tried l… read more
LogicPro
LogicPro
Computer Software Engineer
13,239 satisfied customers
On Microsoft VIsual Studio C++ need it in a C++ code that
On Microsoft VIsual Studio C++need it in a C++ code that works also use the way that starts with hello world please make sure code worksNotice in the updated UML diagram that the Employee class is des… read more
LogicPro
LogicPro
Computer Software Engineer
13,239 satisfied customers
On microsoft visual studio C++ The only change to the
On microsoft visual studio C++ The only change to the Employee class is that there is a new attribute: +benefit : Benefit Notice that there is a "+" for this attribute, meaning that it is public. Make… read more
George Sibiya
George Sibiya
PhD
194 satisfied customers
I have my Visual Studio Program done, but I need to get it
I have my Visual Studio Program done, but I need to get it all under the same path location. All of the files in My Project need to be added to the original folder. So once that is done if you could s… read more
LogicPro
LogicPro
Computer Software Engineer
13,239 satisfied customers
OKRP55211 POSTANSWER I am using Visual Studio 2015 C++ on
OKRP55211 POSTANSWER Hi I am using Visual Studio 2015 C++ on Windows 10. I have a problem with missing symbols when I migrate a GITHUB multi-project solution into a single project. I built the origina… read more
Steve
Steve
Consultant
290 satisfied customers
I am having trouble getting the visual Studio,visual basic
I am having trouble getting the visual Studio,visual basic forms program that uses a local Access database to distribute to stand alone desktop computers with Windows operating system to run correctly… read more
George Sibiya
George Sibiya
PhD
194 satisfied customers
Just having trouble with an assignment, Visual Studio 15,
this is part of the question: For this coding exercise, write the Visual Basic code for a pretest loop that uses an Integer variable named intEven to display the even integers from 2 through 20 in the lblEven control. … read more
LogicPro
LogicPro
Computer Software Engineer
13,239 satisfied customers
OKPR114211 Does visual studio c++ has its own GUI (graphic
OKPR114211 Does visual studio c++ has its own GUI (graphic user interface) creator? or i have to use a different program?… read more
Steve
Steve
Consultant
290 satisfied customers
Windows 10 with Visual Studio 10. I have a project that
Windows 10 with Visual Studio 10. I have a project that compiles and builds on another machine. When I move the project to the Windows 10 machine, I get a message the "The project type is not supporte… read more
LogicPro
LogicPro
Computer Software Engineer
13,239 satisfied customers
I have a question related to C# I am using visual studio
Actual i am looking for solution to a programming question, which is available in c++ but not in c# … read more
Satchi
Satchi
Bachelor\u0027s Degree
2,102 satisfied customers
I need help, microsoft visual studio 2012, i have a problem
i need help JA: What programs and versions are you using? Customer: microsoft visual studio 2012 JA: What is your ideal outcome? How can we solve this for you? Customer: i have a problem and you solve… read more
ATLPROG
ATLPROG
Computer Software Engineer
Master's Degree
7,677 satisfied customers
I have a SSIS 2014 Package created in Visual Studio 2013. I
I have a SSIS 2014 Package created in Visual Studio 2013. I have successfully performed a simple Data Flow from one table to another. I am now wondering how to apply additional logic: 1. Check for Exi… read more
Pete
Pete
Engineer
Bachelor\u0027s Degree
1,109 satisfied customers
Disclaimer: Information in questions, answers, and other posts on this site ("Posts") comes from individual users, not JustAnswer; JustAnswer is not responsible for Posts. Posts are for general information, are not intended to substitute for informed professional advice (medical, legal, veterinary, financial, etc.), or to establish a professional-client relationship. The site and services are provided "as is" with no warranty or representations by JustAnswer regarding the qualifications of Experts. To see what credentials have been verified by a third-party service, please click on the "Verified" symbol in some Experts' profiles. JustAnswer is not intended or designed for EMERGENCY questions which should be directed immediately by telephone or in-person to qualified professionals.

Disclaimer: Information in questions, answers, and other posts on this site ("Posts") comes from individual users, not JustAnswer; JustAnswer is not responsible for Posts. Posts are for general information, are not intended to substitute for informed professional advice (medical, legal, veterinary, financial, etc.), or to establish a professional-client relationship. The site and services are provided "as is" with no warranty or representations by JustAnswer regarding the qualifications of Experts. To see what credentials have been verified by a third-party service, please click on the "Verified" symbol in some Experts' profiles. JustAnswer is not intended or designed for EMERGENCY questions which should be directed immediately by telephone or in-person to qualified professionals.

Show MoreShow Less

Ask Your Question

x